WCF and Document Literal vs. RPC Encoding#

Document Literal vs. RPC Encoding is the big endian-little endian of connected systems. There has been a lot said about the differences (see reference section for details) however this post is about how elegant it looks in WCF. Traditionally we had two ways to represent them;

As a web method

[WebMethod]
public int Add(int p1, int p2)
{
return p1+p2;
}
[WebMethod]
[SoapRpcMethod]
public int Add(int p1, int p2)
{
return p1+p2;
}

Or as a SoapDocumentMethod

SoapDocumentMethod(
"http://www.dotnetsmith.com/DocumentLiteral",
RequestNamespace="http://www.dotnetsmith.com",
ResponseNamespace="http://www.dotnetsmith.com",
Use=SoapBindingUse.Literal)]
public string DocumentLiteral(Address1 address, bool useZipPlus4) {

[SoapDocumentMethod(
"http://www.dotnetsmith.com/DocumentEncoded",
RequestNamespace="http://www.dotnetsmith.com",
ResponseNamespace="http://www.dotnetsmith.com",
Use=SoapBindingUse.Encoded)]
public string DocumentEncoded(Address address, bool useZipPlus4) {

With WCF's seperation of Data and Service Contracts, it has become much more cleaner and clear.

[ServiceContract]
[DataContractFormat(Style=OperationFormatStyle.Document)] //Or Rpc
public interface IOrderEntry {...}

[ServiceContract]
[XmlSerializerFormat(Style=OperationFormatStyle.Document,
Use=OperationFormatUse.Literal)] //Or Encoded
public interface IOrderEntry {...}

and the one way attribute as an operation contract.

public interface IOrderEntry
{
[OperationContract(IsOneWay = true)]
void PlaceOrder(PurchaseOrder order);
}

Remember that RPC/encoded is not WS-I compliant!

Following is difference in the output from the two different


References





Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

All content © 2008, Adnan Masood
About the Author
On this page
Calendar
<November 2008>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456
Archives
Sitemap
Blogroll OPML
microsoft
Blogroll
Disclaimer

Powered by: newtelligence dasBlog 1.8.5223.2

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts