<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Whaly&#039;s World &#187; rpc</title>
	<atom:link href="http://baleinoid.com/whaly/tag/rpc/feed/" rel="self" type="application/rss+xml" />
	<link>http://baleinoid.com/whaly</link>
	<description>tail -f /var/log/whaly</description>
	<lastBuildDate>Wed, 10 Mar 2010 20:19:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>WCF WSDL SOAP binding: Rpc or Document, Encoded or Literal</title>
		<link>http://baleinoid.com/whaly/2009/10/wcf-wsdl-soap-binding-rpc-or-document-encoded-or-literal/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=wcf-wsdl-soap-binding-rpc-or-document-encoded-or-literal</link>
		<comments>http://baleinoid.com/whaly/2009/10/wcf-wsdl-soap-binding-rpc-or-document-encoded-or-literal/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 19:38:02 +0000</pubDate>
		<dc:creator>whaly</dc:creator>
				<category><![CDATA[Microsoft .NET]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[document]]></category>
		<category><![CDATA[encoded]]></category>
		<category><![CDATA[literal]]></category>
		<category><![CDATA[rpc]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[wcf]]></category>
		<category><![CDATA[wsdl]]></category>

		<guid isPermaLink="false">http://baleinoid.com/whaly/?p=92</guid>
		<description><![CDATA[Yeah, my new WebService must be Rpc/Encoded. What ???? Hopefully this page from Ibm explain the different style/use in SOAP message. A WSDL document describes a Web service. A WSDL binding describes how the service is bound to a messaging protocol, particularly the SOAP messaging protocol. A WSDL SOAP binding can be either a Remote [...]]]></description>
			<content:encoded><![CDATA[<p>Yeah, my new WebService must be <strong>Rpc/Encoded</strong>. What ????</p>
<p>Hopefully this <a href="http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/">page</a> from Ibm explain the different style/use in SOAP message.</p>
<blockquote><p>A WSDL document describes a Web service. A WSDL binding describes how the service is bound to a messaging protocol, particularly the SOAP messaging protocol. A WSDL SOAP binding can be either a Remote Procedure Call (RPC) style binding or a document style binding. A SOAP binding can also have an encoded use or a literal use.</p></blockquote>
<p>Ok now I know that four style/use models:<br />
RPC/Encoded, RPC/literal, <del>Document/encoded</del> or Document/literal</p>
<p>But how do I do that in WCF C# ?? It's very easy, just use the [<a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.xmlserializerformatattribute.aspx">XmlSerializerFormat</a>] attribute.</p>
<p>Here is a very very simple test to check the different result in the soap message:</p>
<p><strong>Interface of the Wcf service used :</strong></p>
<pre class="brush: csharp; light: true;">
using System.ServiceModel;

namespace WcfService1
{
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        [XmlSerializerFormat(Style = OperationFormatStyle.Rpc, Use = OperationFormatUse.Encoded)]
        string TestRpcEncoded(int value);

        [OperationContract]
        [XmlSerializerFormat(Style = OperationFormatStyle.Rpc, Use = OperationFormatUse.Literal)]
        string TestRpcLiteral(int value);

        //[OperationContract]
        //[XmlSerializerFormat(Style = OperationFormatStyle.Document, Use = OperationFormatUse.Encoded)]
        //string TestDocumentEncoded(int value);

        [OperationContract]
        [XmlSerializerFormat(Style = OperationFormatStyle.Document, Use = OperationFormatUse.Literal)]
        string TestDocumentLiteral(int value);
    }
}
</pre>
<p><strong>Result captured on the network with fiddler:</strong></p>
<p><em>For clarity, I have removed:</p>
<ul>
<li>s:Envelope tag</li>
<li>xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"</li>
<li>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"</li>
<li>xmlns:xsd="http://www.w3.org/2001/XMLSchema"</li>
<li>xmlns="http://tempuri.org/"</li>
</ul>
<p></em></p>
<p><strong>RPC / Encoded call</strong></p>
<pre class="brush: xml; light: true;">
&lt;!-- Request --&gt;
&lt;s:Body s:encodingStyle=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;&gt;
  &lt;q1:TestRpcEncoded&gt;
    &lt;value xsi:type=&quot;xsd:int&quot;&gt;42&lt;/value&gt;
  &lt;/q1:TestRpcEncoded&gt;
&lt;/s:Body&gt;

&lt;!-- Response --&gt;
&lt;s:Body s:encodingStyle=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;&gt;
  &lt;q1:TestRpcEncodedResponse&gt;
    &lt;TestRpcEncodedResult xsi:type=&quot;xsd:string&quot;&gt;You entered: 42&lt;/TestRpcEncodedResult&gt;
  &lt;/q1:TestRpcEncodedResponse&gt;
&lt;/s:Body&gt;
</pre>
<p><strong>RPC / Literal call</strong></p>
<pre class="brush: xml; light: true;">
&lt;!-- Request --&gt;
&lt;s:Body&gt;
  &lt;TestRpcLiteral&gt;
    &lt;value xmlns=&quot;&quot;&gt;42&lt;/value&gt;
  &lt;/TestRpcLiteral&gt;
&lt;/s:Body&gt;

&lt;!-- Response --&gt;
&lt;s:Body&gt;
  &lt;TestRpcLiteralResponse&gt;
    &lt;TestRpcLiteralResult xmlns=&quot;&quot;&gt;You entered: 42&lt;/TestRpcLiteralResult&gt;
  &lt;/TestRpcLiteralResponse&gt;
&lt;/s:Body&gt;
</pre>
<p><strong>Document / Encoded call</strong><br />
If you add the TestDocumentEncoded you will get an InvalidOperationException.<br />
This combination is not supported.</p>
<p><strong>Document / Literal call</strong></p>
<pre class="brush: xml; light: true;">
&lt;!-- Request --&gt;
&lt;s:Body&gt;&lt;/code&gt;
  &lt;TestDocumentLiteral&gt;&lt;value&gt;42&lt;/value&gt;&lt;/TestDocumentLiteral&gt;
&lt;/s:Body&gt;

&lt;!-- Response --&gt;
&lt;s:Body&gt;
  &lt;TestDocumentLiteralResponse&gt;
    &lt;TestDocumentLiteralResult&gt;You entered: 42&lt;/TestDocumentLiteralResult&gt;
  &lt;/TestDocumentLiteralResponse&gt;
&lt;/s:Body&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://baleinoid.com/whaly/2009/10/wcf-wsdl-soap-binding-rpc-or-document-encoded-or-literal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
