<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Silverlight Web Services Team : soap</title><link>http://blogs.msdn.com/silverlightws/archive/tags/soap/default.aspx</link><description>Tags: soap</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Improving the performance of web services in SL3 Beta</title><link>http://blogs.msdn.com/silverlightws/archive/2009/06/07/improving-the-performance-of-web-services-in-sl3-beta.aspx</link><pubDate>Mon, 08 Jun 2009 06:30:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9707403</guid><dc:creator>SLWSTeam</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/silverlightws/comments/9707403.aspx</comments><wfw:commentRss>http://blogs.msdn.com/silverlightws/commentrss.aspx?PostID=9707403</wfw:commentRss><description>&lt;p&gt;Silverlight 3 Beta introduces a new way to improve the performance of web services. You have all probably used the &lt;em&gt;Silverlight-enabled WCF Service&lt;/em&gt; item template in Visual Studio to create a WCF web service, and then used the &lt;em&gt;Add Service Reference&lt;/em&gt; command in your Silverlight application project in order to access the web service. In SL3, the item template has undergone a small change that turns on the new &lt;strong&gt;binary message encoder&lt;/strong&gt;, which significantly improves the performance of the WCF services you build. Note that this is the same binary encoder which has been available in .Net since the release of WCF, so all WCF developers will find the object model very familiar.&lt;/p&gt;  &lt;p&gt; The best part is that this is done entirely in the service configuration file (&lt;em&gt;Web.config&lt;/em&gt;) and does not affect the way you use the service. (Check out &lt;a href="http://blogs.msdn.com/silverlightws/archive/2009/03/20/what-s-new-with-web-services-in-silverlight-3-beta.aspx"&gt;this post&lt;/a&gt; for a brief description of exactly what the change is.)&lt;/p&gt;  &lt;p&gt;I wanted to share some data that shows exactly how noticeable this performance improvement is, and perhaps convince some of you to consider migrating your apps from SL2 to SL3. &lt;/p&gt;  &lt;p&gt;When Silverlight applications use web services, XML-based messages (in the SOAP format) are being exchanged. In SL2, those messages were always encoded as plain text when being transmitted; you could open a HTTP traffic logger and you would be able to read the messages. However using plain text is far from being a compact encoding when sending across the wire, and far from being fast when decoding on the server side. When we use the binary encoder, the messages are encoded using a WCF binary encoding, which provides two main advantages: increased server throughput and decreased message size.&amp;#160; &lt;/p&gt;  &lt;h3&gt;Increased server throughput&lt;/h3&gt;  &lt;p&gt;Let’s examine the following graph (hat tip to &lt;a title="Greg Leake&amp;#39;s blog" href="http://blogs.msdn.com/gregleak/"&gt;Greg Leake&lt;/a&gt; of &lt;a title="StockTrader website" href="http://msdn.microsoft.com/stocktrader"&gt;StockTrader&lt;/a&gt; fame for collecting this data). Here is the scenario we measure: the client sends a payload, the server receives it and sends it back to the client. Many clients are used to load the service up to its peak throughput. We run the test once using the text-based encoding and once using the new binary encoding and compare the peak throughput at the sever. We do this for 2 message sizes: in the smaller size the payload an array with 20 objects, and in the bigger one the payload is an array with 100 objects.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Some more details for the curious: &lt;/strong&gt;The service is configured to ensure no throttling is happening, and a new instance of the service is created for every client call (known as PerCall instancing). There are ten physical clients driving load, each running many threads hitting service in tight loop (but with small 0.1 second think time between requests) using a shared channel to reduce client load. The graph measures peak throughput on the service at 100% CPU saturation. Note that in this test we did not use Silverlight clients but regular .Net clients. Since we are measuring &lt;em&gt;server throughput&lt;/em&gt; it is not significant what the clients are. &lt;/p&gt;  &lt;p&gt;&lt;img src="http://blogs.msdn.com/photos/silverlightws/images/9703322/original.aspx" /&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;When sending the smaller message we see a &lt;strong&gt;24% increase in server throughput&lt;/strong&gt;, and with the larger message size we see a &lt;strong&gt;71% increase in server throughput&lt;/strong&gt;. As the message complexity continues to grow, we should see even more significant gains from using the binary encoder.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;What does that mean to you?&lt;/strong&gt; If you run a service that is being used by Silverlight clients and you exchange non-trivial messages, you can support significantly more clients if the clients use SL3’s binary encoding. As usage of your service increases, that could mean being able to save on buying and deploying extra servers.&lt;/p&gt;  &lt;h3&gt;Decreased message size&lt;/h3&gt;  &lt;p&gt;Another feature of the binary encoder is that since messages sent on the wire are no longer plain-text, you will see a reduction in their average size. Let’s clarify this point: the main reason you would use the binary encoding is to increase the service throughput, as discussed in the previous section. The decrease in message size is a nice side-effect, but let’s face it: you can accomplish the same effect by turning on compression on the HTTP level.&lt;/p&gt;  &lt;p&gt;This test was far less comprehensive than the previous one and we did it ad-hoc on my co-worker’s office machine. We took various objects inside a Silverlight control, and turned them into the same kind of SOAP messages that get sent to the service. We did this using the plain-text encoding and using binary encoding and then we compared the size of the messages in bytes. Here are our results:&lt;/p&gt;  &lt;p&gt;&lt;img src="http://blogs.msdn.com/photos/silverlightws/images/9703323/original.aspx" /&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;The takeaway here is that the reduction of message size depends on the nature of the payload: sending large instances of system types (for example a long String) will result in a modest reduction, but &lt;strong&gt;the largest gains occur when complex object graphs are being encoded &lt;/strong&gt;(for example objects with many members, or arrays).&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;What does this mean to you?&lt;/strong&gt; If you run a web service and you pay your ISP for the traffic your service generates, using binary encoding will reduce the size of messages on the wire, and hopefully lower your bandwidth bills as traffic to your service increases.&lt;/p&gt;  &lt;h3&gt;Conclusion&lt;/h3&gt;  &lt;p&gt;We are confident that binary encoding is the right choice for most &lt;strong&gt;backend WCF service&lt;/strong&gt; scenarios: you should never see a regression over text encoding when it comes to server throughput or message size; hopefully you will see performance gains in most cases. This is why the binary encoder is the new default in the &lt;em&gt;Silverlight-enabled WCF Service&lt;/em&gt; item template in Visual Studio.&lt;/p&gt;  &lt;p&gt;An important note: binary encoding is only supported by WCF services and clients, and so it is not the right choice if you aren’t using WCF end-to-end. If your service needs to be accessed by non-WCF clients, using binary encoding may not be possible. The binary AMF encoding used by Adobe Flex is similarly restricted to services that support it.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9707403" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/silverlightws/archive/tags/wcf/default.aspx">wcf</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/soap/default.aspx">soap</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/binary/default.aspx">binary</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/performance/default.aspx">performance</category></item><item><title>What's new with web services in Silverlight 3 Beta</title><link>http://blogs.msdn.com/silverlightws/archive/2009/03/20/what-s-new-with-web-services-in-silverlight-3-beta.aspx</link><pubDate>Fri, 20 Mar 2009 13:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9492252</guid><dc:creator>SLWSTeam</dc:creator><slash:comments>14</slash:comments><comments>http://blogs.msdn.com/silverlightws/comments/9492252.aspx</comments><wfw:commentRss>http://blogs.msdn.com/silverlightws/commentrss.aspx?PostID=9492252</wfw:commentRss><description>&lt;P&gt;Silverlight 3 beta comes with a set of exciting web services features that address key customer requests.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Binary message encoding&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;In Silverlight 2 the only supported binding was BasicHttpBinding, which encodes outgoing messages as text and sends them over an HTTP transport. This binding is great for interoperability with SOAP 1.1 services and is also easily debuggable since messages can be viewed in plain text on the wire using HTTP debugging tools such as &lt;A title="Fiddler HTTP debugger" href="http://www.fiddlertool.com/" mce_href="http://www.fiddlertool.com/"&gt;Fiddler&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;However as Silverlight applications go into production and grow to scale, service developers start getting concerned with the cost of hosting services. Two things in particular that we are about:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Increased server throughput&lt;/STRONG&gt; - more clients can be&amp;nbsp;connected to a&amp;nbsp;server, which means fewer servers need to be purchased.&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Decreased message size&lt;/STRONG&gt; - smaller message sizes exchanged on the wire means lower bandwidth bills&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Silverlight 3 introduces a binary message encoder, which produces significant improvements in both of the above indicators. A follow-up post is coming with some specific data on the improvements that can be expected.&lt;/P&gt;
&lt;P&gt;Binary encoding is implemented as a custom binding, there is no out-of-the-box binary binding. &lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt"&gt;&amp;lt;bindings&amp;gt;&lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;customBinding&amp;gt;&lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;binding name="binaryHttpBinding"&amp;gt;&lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;binaryMessageEncoding /&amp;gt;&lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;httpTransport /&amp;gt;&lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;/binding&amp;gt;&lt;BR&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;/customBinding&amp;gt;&lt;BR&gt;&amp;lt;/bindings&amp;gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt"&gt;&amp;lt;endpoint address="" binding="customBinding" bindingConfiguration="binaryHttpBinding"&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;contract="Service" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;
&lt;P&gt;The BinaryMessageEncodingBindingElement can be used as part of any custom binding and so it composes easily to create things like a binary duplex binding.&lt;/P&gt;
&lt;P&gt;The binary encoder offers performance gains over the text encoder, and there should never be any regressions. This is why binary is the new default in backend service scenarios, such as where the &lt;STRONG&gt;Silverlight-enabled WCF Service&lt;/STRONG&gt; item template is used. Therefore the template has been modified to use binary. The interop cases is where binary should not be used (if the client is talking to a non-WCF service), since binary is a WCF-specific encoding: please continue to use BasicHttpBinding with text encoding in those scenarios (for example accessing ASMX services).&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Duplex object model simplification&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Duplex is an innovative Silverlight 2 feature which allows the service to send data to the client without the client manually polling for the data ("smart" polling still occurs on the network layer, but the user does not need to know).&amp;nbsp;However there were two significant limitations in the Silverlight&amp;nbsp;2 duplex&amp;nbsp;object model:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Channel programming had to be used and&lt;/LI&gt;
&lt;LI&gt;Serialization was not supported so a Message programming model had to be used.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Silverlight 3 lifts these restrictions and introduces &lt;STRONG&gt;Add Service Reference support for duplex services&lt;/STRONG&gt;.&amp;nbsp;Familiar-looking proxies are now generated, greatly reducing&amp;nbsp;the amount of&amp;nbsp;Silverlight code that is needed to access a duplex service. A simple stock ticker client implementation, which previously took 203 lines of code, &lt;STRONG&gt;can now be reduced to a mere 48 lines of code, a 76% reduction in code size.&lt;/STRONG&gt; Not to mention that the channel-based code was complex and very error-prone due to its use of async patterns. Here is a snippet showing the crux of the new object model, in the context of the stock ticker example:&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-no-proof: yes"&gt;private&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; Button_Click(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, System.Windows.RoutedEventArgs e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ServiceClient proxy = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; ServiceClient(binding, address);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;proxy.ReceiveCallbackCompleted += &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;EventHandler&lt;/SPAN&gt;&amp;lt;ReceiveCallbackCompletedEventArgs&amp;gt;(proxy_ReceiveCallbackCompleted);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;proxy.StartAsync(symbol.Text);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-no-proof: yes"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-no-proof: yes"&gt;void&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-no-proof: yes"&gt; proxy_ReceiveCallbackCompleted(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, ReceiveCallbackCompletedEventArgs e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (e.Error == &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;price.Text = e.price.ToString();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-no-proof: yes"&gt;}&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 9pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;
&lt;P&gt;Note that receiving the callback from the server is now just a matter of attaching a callback to an event. Also note the fact that we are working with CLR types and not Message objects, so serialization is now enabled. We have updated &lt;A title="Duplex documentation" href="http://msdn.microsoft.com/en-us/library/dd470105(VS.96).aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd470105(VS.96).aspx"&gt;our documentation&lt;/A&gt; with&amp;nbsp;a walkthrough of how to use the new object model. In addition, &lt;A title="Duplex chat server" href="http://code.msdn.microsoft.com/silverlightws/Release/ProjectReleases.aspx?ReleaseId=2401" mce_href="http://code.msdn.microsoft.com/silverlightws/Release/ProjectReleases.aspx?ReleaseId=2401"&gt;Eugene's duplex chat server implementation&lt;/A&gt;, which has proven very popular, has also been updated with the new OM.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Faults support&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;In Silverlight 2 if an unexpected exception occurred in the service, the fault would not be propagated to the Silverlight client. Instead of getting&amp;nbsp;the exception propagated to the user,&amp;nbsp;Silverlight would throw an unhelpful&amp;nbsp;&lt;STRONG&gt;CommunicationException&lt;/STRONG&gt; which carries no useful information.&amp;nbsp;There were two reasons for this: (1) faults are returned with a 500 status code, and the browser networking stack prevents Silverlight from reading the body of such a response, and (2) Silverlight did not support he necessary client-side logic to convert the fault message into an exception that can be surfaced to the user. These limitation made it very difficult to debug services from Silverlight. &lt;/P&gt;
&lt;P&gt;In Silverlight 3 Beta&amp;nbsp;limitation (1) is unfortunately still present.&amp;nbsp;To work around this issue&amp;nbsp;&lt;A title="Faults documentation" href="http://msdn.microsoft.com/en-us/library/dd470096(VS.96).aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd470096(VS.96).aspx"&gt;our documentation&lt;/A&gt;&amp;nbsp;provides a WCF endpoint behavior, which can be applied to your WCF service to switch the response code from 500 to 200. With this response code the message will be accessible to Silverlight and we can address limitation (2). In Silverlight 3, we have added the necessary client-side OM to surface faults to the user. Look out for helpful &lt;STRONG&gt;FaultException &lt;/STRONG&gt;and &lt;STRONG&gt;FaultException&amp;lt;ExceptionDetail&amp;gt; &lt;/STRONG&gt;exceptions which will help you debug your service. Also please see the documentation page linked earlier for a full description of the faults object model in Silverlight.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;New security mode&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;A common scheme used to secure services for use by Silverlight clients is browser-based authentication. However browser-based authetnication is not safe to use if your service is accessible from any domain via a cross-domain policy file. This would expose your service to &lt;A title="Cross Site Request Forgery" href="http://en.wikipedia.org/wiki/Cross-site_request_forgery" mce_href="http://en.wikipedia.org/wiki/Cross-site_request_forgery"&gt;CSRF&lt;/A&gt; type attacks, where cached browser credentials can be used by malicious apps to access your sercure service without the user's knowledge. &lt;/P&gt;
&lt;P&gt;Silverlight 3 introduces a new security mode called &lt;STRONG&gt;TransportSecurityWithMessageCredential &lt;/STRONG&gt;to address this configuration. In this mode, the credentials are included in every outgoing message to the service, and the service verifies those credentials on the SOAP layer. However since the credentials are in plain text inside the message the transport needs to be secure so we use HTTPS.&lt;/P&gt;
&lt;P&gt;A more detailed walktrhough of valid Silverlight security configurations will follow.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Command-line proxy generation&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;In Silverlight 2 &lt;STRONG&gt;Add Service Reference &lt;/STRONG&gt;as part of Visual Studio is the only way to generate proxies for Silverlight clients. In Silverlight 3 we are introducing a command-line tool called &lt;STRONG&gt;slsvcutil.exe&lt;/STRONG&gt;, which allows customized command-line proxy generation. Using the tool, proxies can now be generated as part of your build process for greater robustness. The slsvcutil.exe tool is fully described in this &lt;A title="slsvcutil.exe documentation" href="http://msdn.microsoft.com/en-us/library/dd470117(VS.96).aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd470117(VS.96).aspx"&gt;documentation topic&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Thanks for reading through this, and please stay tuned for some in-depth posts about these new features.&lt;/P&gt;
&lt;P&gt;Yavor Georgiev&lt;BR&gt;Program Manager, Silverlight Web Services Team&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9492252" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/silverlightws/archive/tags/mix/default.aspx">mix</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/samples/default.aspx">samples</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/soap/default.aspx">soap</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/duplex/default.aspx">duplex</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/security/default.aspx">security</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/binary/default.aspx">binary</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/faults/default.aspx">faults</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/slsvcutil/default.aspx">slsvcutil</category></item><item><title>New Web Services Features in Silverlight 2 RTW</title><link>http://blogs.msdn.com/silverlightws/archive/2008/10/20/new-web-services-features-in-sl2-rtw.aspx</link><pubDate>Mon, 20 Oct 2008 16:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9001471</guid><dc:creator>SLWSTeam</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/silverlightws/comments/9001471.aspx</comments><wfw:commentRss>http://blogs.msdn.com/silverlightws/commentrss.aspx?PostID=9001471</wfw:commentRss><description>&lt;P&gt;Here is an overview of the new features added since Beta 2.&lt;/P&gt;
&lt;H3&gt;SOAP Headers&lt;/H3&gt;
&lt;P&gt;SOAP headers were a big customer request, so we have added&amp;nbsp;headers support in this release. There are two methods to use headers, depending on the customer scenario.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The &lt;U&gt;easier method&lt;/U&gt; is useful when you need to get/set a header while invoking a single operation on the service.&amp;nbsp;&lt;/STRONG&gt;You can&amp;nbsp;use the&amp;nbsp;&lt;A class="" title="OperationContext class" href="http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontext(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontext(VS.95).aspx"&gt;OperationContext&lt;/A&gt; class, and specifically the &lt;A class="" title="OperationContext.IncomingMessageHeaders property" href="http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontext.incomingmessageheaders(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontext.incomingmessageheaders(VS.95).aspx"&gt;IncomingMessageHeaders&lt;/A&gt; or &lt;A class="" title="OperationContext.OutgoingMessageHeaders property" href="http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontext.outgoingmessageheaders(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontext.outgoingmessageheaders(VS.95).aspx"&gt;OutgoingMessageHeaders&lt;/A&gt; property to receive or send a header. Below is a code example where the client sends the header &lt;CODE&gt;&amp;lt;MyClientHeader xmlns="http://silverlight.net"&amp;gt;...&amp;lt;/MyClientHeader&amp;gt;&lt;/CODE&gt; to the service.&lt;/P&gt;&lt;CODE&gt;
&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; Page()&lt;BR&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent();&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;// Instantiate generated proxy&lt;BR&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;Service1Client&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; proxy = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;Service1Client&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;// Hook up an event handler when operation completes&lt;BR&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;proxy.DoWorkCompleted += &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;EventHandler&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;DoWorkCompletedEventArgs&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;gt;(proxy_DoWorkCompleted);&lt;/FONT&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;using&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;OperationContextScope&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; ocs = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;OperationContextScope&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;(proxy.InnerChannel))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;// We can add "MyClientHeader" SOAP header to the outgoing message. It is important that this comes before calling the operation.&lt;BR&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;OperationContext&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.Current.OutgoingMessageHeaders.Add(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;MessageHeader&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.CreateHeader(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"MyClientHeader"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"http://silverlight.net"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"..."&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;));&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;// Call an operation on the service&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proxy.DoWorkAsync(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"foo"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;/CODE&gt;Now assume we want to get at a header that the service sent back.&amp;nbsp;In this example, the service sent the &lt;CODE&gt;&amp;lt;MyServiceHeader xmlns="http://silverlight.net"&amp;gt;...&amp;lt;/MyServiceHeader&amp;gt;&lt;/CODE&gt; header to the client. &lt;STRONG&gt;Note: &lt;/STRONG&gt;The old Begin*/End* async pattern needs to be used with &lt;STRONG&gt;OperationContext &lt;/STRONG&gt;&lt;U&gt;if you are retrieving the headers sent in a service reply&lt;/U&gt;. The event-based async pattern (using *Completed&amp;nbsp;event and *Async method) is currently not supported. Also, please be sure to use exact order of calls demonstrated below.&lt;/P&gt;&lt;CODE&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; Page()&lt;BR&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent();&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;// Instantiate generated proxy&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;Service1Client&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; proxy = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;Service1Client&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;// Call an operation on the service using Begin/End async pattern&lt;BR&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;((&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;Service1&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;)proxy).BeginDoWork(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"foo"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;, doWorkCallback, proxy);&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;// Receive callback when the service responds&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; doWorkCallback(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;IAsyncResult&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; result)&lt;BR&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;Service1&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; proxy = (&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;Service1&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;)result.AsyncState;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;using&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;OperationContextScope&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; ocs = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;OperationContextScope&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;(((&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;Service1Client&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;)proxy).InnerChannel))&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;// Get the service response. This needs to happen before we access the headers.&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;string&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; response = proxy.EndDoWork(result);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;// Now we can access the headers of the incoming message. In this case we assume the header "MyServiceHeader" was sent by the service.&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;string&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; headerContents = &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;OperationContext&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.Current.IncomingMessageHeaders.GetHeader&amp;lt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"MyServiceHeader"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"http://silverlight.net"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;// Do something with response and header&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/FONT&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The &lt;U&gt;harder method&lt;/U&gt;&amp;nbsp;can be used when you want to get/set headers upon invoking any operation on the service. &lt;/STRONG&gt;In that case you would have to use &lt;STRONG&gt;OperationContext&lt;/STRONG&gt; every time you call a service operation, which is very clunky. Instead, what would be useful is functionality similar to that provided by WCF message inspectors and the &lt;A class="" title="IClientMessageInspector class" href="http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.iclientmessageinspector.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.iclientmessageinspector.aspx"&gt;IClientMessageInspector&lt;/A&gt; class. Using a client message inspector you can get access to the &lt;A class="" title="Message class" href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.message(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.message(VS.95).aspx"&gt;Message&lt;/A&gt; instance just received from or about to be sent to the service, and manipulate the headers directly on the instance. &lt;STRONG&gt;IClientMessageInspector&lt;/STRONG&gt; is not part of SL 2, but &lt;A class="" title="Message Inspectors code sample" href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=silverlightws&amp;amp;DownloadId=3473" mce_href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=silverlightws&amp;amp;DownloadId=3473"&gt;this code sample&lt;/A&gt; demonstrates how to accomplish the same functionality. In the sample, we add a header to every message sent to the service, and the header contains the IP address of the client which is calling the service.&lt;/P&gt;
&lt;H3&gt;SOAP Faults&lt;/H3&gt;
&lt;P&gt;&lt;A class="" title="Eugene's blog" href="http://eugeneos.blogspot.com/" mce_href="http://eugeneos.blogspot.com/"&gt;Eugene&lt;/A&gt; &lt;A class="" title="Eugene on Silverlight SOAP faults" href="http://eugeneos.blogspot.com/2008/09/faults-and-exceptions-when-using-web.html" mce_href="http://eugeneos.blogspot.com/2008/09/faults-and-exceptions-when-using-web.html"&gt;posted about faults&lt;/A&gt; just a couple of weeks back. Faults are another major request but unfortunately they are not supported out of the box in SL 2. However,&amp;nbsp;using the same client message inspectors approach and some extra configuration on the&amp;nbsp;WCF service side,&amp;nbsp;rudimentary faults can&amp;nbsp;be enabled. The &lt;A class="" title="Message Inspectors code sample" href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=silverlightws&amp;amp;DownloadId=3473" mce_href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=silverlightws&amp;amp;DownloadId=3473"&gt;same code sample linked above&lt;/A&gt; demonstrates how to do this. I will put together a more detailed post about the sample in the coming weeks.&lt;/P&gt;
&lt;H3&gt;Reusing existing types in "Add Service Reference"&lt;/H3&gt;
&lt;P&gt;If you use "Add Service Reference" to add a reference to the service in your client, it will by default generate a duplicate of any type used by your service operation. Frequently when developing a WCF service and a Silverlight client, you want to declare your types in only one place. Alternatively, maybe your data contract types contain internal logic that you would like to preserve and that logic is lost when "Add Service Reference" generates the duplicate types in the client.&lt;/P&gt;
&lt;P&gt;&lt;IMG title="Reusing types in Add Service Reference" style="WIDTH: 454px; HEIGHT: 421px" height=421 alt="Reusing types in Add Service Reference" src="http://blogs.msdn.com/photos/silverlightws/images/9001562/original.aspx" width=454 align=absMiddle mce_src="http://blogs.msdn.com/photos/silverlightws/images/9001562/original.aspx"&gt;&lt;/P&gt;
&lt;P&gt;To prevent duplicate types from being generated in the client, you would normally declare the data contract types in a new project, which is referenced by both your WCF service and the Silverlight client. Then when adding a reference to the service, you would&amp;nbsp;select the correct option in the "Add Service Reference" dialog. This way "Add Service Reference" would find the types already referenced in the shared project, and not generate duplicates.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Note:&lt;/STRONG&gt;&amp;nbsp;In Silverlight the shared project that contains the data contract types has to be a "Silverlight Library", which can be referenced by both Silverlight projects and regular desktop framework projects. If the shared project is of any other type, you will not be able to reference it from within a "Silverlight Application" project.&lt;/P&gt;
&lt;P&gt;This option was already there in the Silverlight version of "Add Service Reference", but it did not work up until this release.&lt;/P&gt;
&lt;H3&gt;Duplex Services&lt;/H3&gt;
&lt;P&gt;We have made improvements to the duplex channel shipped in Beta 2:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Client and server side duplex components are now &lt;STRONG&gt;ready for production use&lt;/STRONG&gt;, with improved stability, security, etc. In Beta 2 the server-side duplex component was under an "evaluation" license.&lt;/LI&gt;
&lt;LI&gt;Server-side duplex component may now be &lt;STRONG&gt;hosted in Partial Trust&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Default timeouts and timeout behavior is “smarter”&lt;/STRONG&gt; – no changes should be required for common scenarios&lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;In addition, &lt;A class="" title="Eugene's blog" href="http://eugeneos.blogspot.com/" mce_href="http://eugeneos.blogspot.com/"&gt;Eugene&lt;/A&gt; has developed &lt;A class="" title="Duplex Receiver sample" href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=silverlightws&amp;amp;DownloadId=3472" mce_href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=silverlightws&amp;amp;DownloadId=3472"&gt;a great sample&lt;/A&gt; on top of the raw duplex channel model, to simplify duplex usage. On the client side you can use the &lt;STRONG&gt;DuplexReceiver &lt;/STRONG&gt;class:&lt;/P&gt;&lt;CODE&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;class&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;DuplexReceiver&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;{&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;// Opens a channel to the service to receive messages using the default PollingDuplexBinding&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;public&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; DuplexReceiver(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;Uri&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; address, &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;IEnumerable&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;Type&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;gt; possibleTypes);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;// Opens a channel to the service to receive messages using the default PollingDuplexBinding&lt;BR&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; DuplexReceiver(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;EndpointAddress&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; address, &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;IEnumerable&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;Type&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;gt; possibleTypes);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;// Sends a message to a Duplex service. (The first time a message is sent, connection will be established to the service).&lt;BR&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; SendMessageAsync(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;object&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; message);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;// Event that will be called after a message has been sent&lt;BR&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;event&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;EventHandler&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;AsyncCompletedEventArgs&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;gt; SendMessageCompleted;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;// Event that will be called for each received message&lt;BR&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;event&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;EventHandler&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;ReceivedMessageEventArgs&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;gt; MessageReceived;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;// Disconnects from a Duplex service (can later reconnect again). To permanently close, first call DisconnectAsync and then call Close&lt;BR&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; DisconnectAsync();&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;// Closes the Duplex connection&lt;BR&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; Close();&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;// Other methods and properties omitted for brevity...&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;}&lt;/P&gt;&lt;/FONT&gt;&lt;/CODE&gt;
&lt;P&gt;Instead of using the channel model directly, you can use the &lt;STRONG&gt;SendMessageAsync&lt;/STRONG&gt; method to send messages to the service. The &lt;STRONG&gt;MessageReceived&lt;/STRONG&gt; event is fired when the service sends the client a message. Note that the DuplexReceiver contructor takes the list of types that can possibly be sent. The sample also provides a server-side &lt;STRONG&gt;DuplexService&lt;/STRONG&gt; object, which keeps track of connected clients and can relay messages to the correct recipient, or broadcast messages to all clients.&lt;/P&gt;
&lt;H3&gt;Support for ChannelFactory&amp;lt;T&amp;gt;&lt;/H3&gt;
&lt;P&gt;This is an advanced use case: say you want to use a service without generating a proxy to it. Perhaps you are connecting to a complex service and you manually copied over/shared all the contracts and types that the service uses (for example in order to preserve the internal logic of these types). But you never&amp;nbsp;used the&amp;nbsp;"Add Service Reference" wizard so you don't have a proxy class to the service. In this case ChannelFactory&amp;lt;T&amp;gt; can be used to communicate&amp;nbsp;with a service which&amp;nbsp;implements&amp;nbsp;the service contract &amp;lt;T&amp;gt;, as shown&amp;nbsp;below.&amp;nbsp;&lt;/P&gt;&lt;CODE&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; Page()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent();&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;ChannelFactory&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;Service1Channel&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;gt; factory = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;ChannelFactory&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;Service1Channel&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;gt;(&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;new&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;BasicHttpBinding&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;(),&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;EndpointAddress&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"http://localhost:49507/Service1.svc"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;));&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;Service1Channel&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; channel = factory.CreateChannel();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; channel.BeginDoWork(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;AsyncCallback&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;(doWorkCallback), channel);&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; doWorkCallback(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;IAsyncResult&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; result)&lt;BR&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;Service1Channel&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; channel = (&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;Service1Channel&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;)result.AsyncState;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;string&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; response = channel.EndDoWork(result);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;// Do something with response&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;}&lt;/P&gt;&lt;/FONT&gt;&lt;/CODE&gt;
&lt;P&gt;Note that using this approach, the event-based async pattern is not supported.&lt;/P&gt;
&lt;H3&gt;Other&lt;/H3&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Types generated from ADO.NET Entity Data Models (.edmx files)&amp;nbsp;&lt;/STRONG&gt;in WCF services intended for Silverlight consumption are now supported. Just use the type generated from a .edmx model as an argument in&amp;nbsp;a service operation.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Internal types and internal members &lt;/STRONG&gt;may now be serialized by the &lt;A class="" title="DataContractSerializer class" href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractserializer(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractserializer(VS.95).aspx"&gt;DataContractSerializer&lt;/A&gt; and the &lt;A class="" title="DataContractJsonSerializer class" href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.json.datacontractjsonserializer(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.json.datacontractjsonserializer(VS.95).aspx"&gt;DataContractJsonSerializer&lt;/A&gt; (on a per-assembly opt-in basis)&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;JSON/XML Mapping&lt;/STRONG&gt; is now supported (through System.Runtime.Serialization.Json.dll in the SDK), by using the &lt;A class="" title="JsonReaderWriterFactory class" href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.json.jsonreaderwriterfactory(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.json.jsonreaderwriterfactory(VS.95).aspx"&gt;JsonReaderWriterFactory&lt;/A&gt; class.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;JAXB-style object references &lt;/STRONG&gt;in XML are now supported by &lt;STRONG&gt;DataContractSerializer&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Have fun using our new feature set!&lt;/P&gt;
&lt;P&gt;Yavor Georgiev&lt;BR&gt;Program Manager, Connected Framework Team&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9001471" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/silverlightws/archive/tags/wcf/default.aspx">wcf</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/soap/default.aspx">soap</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/duplex/default.aspx">duplex</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/tools/default.aspx">tools</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/channels/default.aspx">channels</category></item><item><title>Detailed Overview of Silverlight 2 Beta 2 Web Service Features</title><link>http://blogs.msdn.com/silverlightws/archive/2008/06/10/detailed-overview-of-silverlight-2-beta-2-web-service-features.aspx</link><pubDate>Tue, 10 Jun 2008 11:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8589374</guid><dc:creator>SLWSTeam</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/silverlightws/comments/8589374.aspx</comments><wfw:commentRss>http://blogs.msdn.com/silverlightws/commentrss.aspx?PostID=8589374</wfw:commentRss><description>&lt;P&gt;As&amp;nbsp;you have probably read already (in &lt;A class="" title="ScottGu's blog" href="http://weblogs.asp.net/scottgu/archive/2008/06/06/silverlight-2-beta2-released.aspx" mce_href="http://weblogs.asp.net/scottgu/archive/2008/06/06/silverlight-2-beta2-released.aspx"&gt;Scott&lt;/A&gt; or &lt;A class="" title="Tim Heuer's blog" href="http://timheuer.com/blog/archive/2008/06/06/changes-to-accessing-services-in-silverlight-2-beta-2.aspx" mce_href="http://timheuer.com/blog/archive/2008/06/06/changes-to-accessing-services-in-silverlight-2-beta-2.aspx"&gt;Tim's&lt;/A&gt; posts), Silverlight 2 Beta 2 provides a set of new and improved web service features. This post will go over our Beta 2 scenarions in more detail, and we intend to follow up over the next couple of weeks and drill down into particualr features.&lt;/P&gt;
&lt;H4&gt;Duplex Communication (Server Push)&lt;/H4&gt;
&lt;P&gt;This has been the most requested feature from our customers since the release of Beta 1, and it enables some useful scenarios like building chat and monitoring apps. Duplex allows the client to expose a set of operations that the server can call to send (push) information to the client. Previously addressing the browser-based client was not possible using the web service stack, so we are very excited to ship this feature in Beta 2.&lt;/P&gt;
&lt;P&gt;Duplex support is delivered in two assemblies: one that plugs into your WCF service, and the other one which plugs in to the Silverlight client. Once you install the Beta 2 SDK, you will get the following assemblies:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Server\Evaluation\System.ServiceModel.PollingDuplex.dll&lt;BR&gt;&lt;BR&gt;&lt;/STRONG&gt;This is the server-side assembly. For details on it usage and how to build a duplex WCF service, &lt;A class="" title="How to: Build a Duplex Service" href="http://msdn.microsoft.com/en-us/library/cc645027(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc645027(VS.95).aspx"&gt;see this topic in the documentation&lt;/A&gt;. The assembly provides you with the server-side &lt;STRONG&gt;PollingDuplexBindingElement&lt;/STRONG&gt;, which allows you to build a custom binding, You can then build a custom &lt;A class="" title=System.ServiceModel.ServiceHost href="http://msdn.microsoft.com/en-us/library/system.servicemodel.servicehost.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.servicemodel.servicehost.aspx"&gt;&lt;STRONG&gt;ServiceHost&lt;/STRONG&gt;&lt;/A&gt;, which uses the custom binding to host your service contract. A service contract hosted this way will support &lt;A class="" title=ServiceContractAttribute.CallbackContract href="http://msdn.microsoft.com/en-us/library/system.servicemodel.servicecontractattribute.callbackcontract.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.servicemodel.servicecontractattribute.callbackcontract.aspx"&gt;&lt;STRONG&gt;ServiceContractAttribute.CallbackContract&lt;/STRONG&gt;&lt;/A&gt;, which is how you specify the client operations that the service can call. The topic referenced above goes through all these details and shows you a finished duplex WCF service.&lt;BR&gt;&lt;BR&gt;You may have noticed the "Evaluation" folder name in the path. This assembly is provided on a different license than the rest of the Beta 2 product, and is not meant for production apps. We intend to put some more work into the API and tune the performance before this component is ready for production environments.&lt;BR&gt;&lt;BR&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Client\System.ServiceModel.PollingDuplex.dll&lt;BR&gt;&lt;BR&gt;&lt;/STRONG&gt;This is the client-side duplex assembly. For details on its usage and how to build a Silverilght client for a WCF duplex service, &lt;A class="" title="How to: Access a Duplex Service with the Channel Model" href="http://msdn.microsoft.com/en-us/library/cc645028(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc645028(VS.95).aspx"&gt;see this topic in the documentation&lt;/A&gt;. The assembly provides you with the client-side &lt;A class="" title=PollingDuplexHttpBinding href="http://msdn.microsoft.com/en-us/library/system.servicemodel.pollingduplexhttpbinding(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.servicemodel.pollingduplexhttpbinding(VS.95).aspx"&gt;&lt;STRONG&gt;PollingDuplexHttpBinding&lt;/STRONG&gt;&lt;/A&gt;, which can be used to create a channel to talk to the WCF duplex service. This is covered by the above topic.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;You might remember &lt;A class="" title='"Pushing" Data to a Silverlight Application' href="http://eugeneos.blogspot.com/2008/04/pushing-data-to-silverlight-application.html" mce_href="http://eugeneos.blogspot.com/2008/04/pushing-data-to-silverlight-application.html"&gt;Eugene's blog post&lt;/A&gt;, which talks about a typed "receiver" experience, which also takes care of deserialization. We are working on this and will likely release it as a code sample on silverlight.net in the coming weeks.&lt;/P&gt;
&lt;H4&gt;LINQ over JSON&lt;/H4&gt;
&lt;P mce_keep="true"&gt;Many web services provide APIs which return JSON data instead of POX or SOAP, and we want to make sure Silverlight provides great support for these types of services. So far the only way to interact with JSON in Silverlight has been to deserialize it into a type, which we have defined already to match the structure of the JSON. However this becomes impractical for APIs that return a lot of JSON data. Take Facebook for example: just asking for a user's information returns almost a page of JSON, and it would be impractical for a Silverilght developer to have to construct a type to match this JSON, especially if the Silverlight app is a mashup and interacts with multiple complex JSON APIs. In situations like this, we would prefer to "dot into" the JSON object and treat it&amp;nbsp;as more of&amp;nbsp;a dictionary, as opposed through the&amp;nbsp;deserialization mechanism.&lt;/P&gt;
&lt;P mce_keep="true"&gt;Beta 2 introduces a brand new feature called &lt;A class="" title=JsonObject href="http://msdn.microsoft.com/en-us/library/system.json.jsonobject(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.json.jsonobject(VS.95).aspx"&gt;JsonObject&lt;/A&gt;, which is also new to the .Net platform. JsonObject allows you to "parse" a JSON string and then use it as a dictionary in Silverlight, as shown in &lt;A class="" title="Working with JSON Data" href="http://msdn.microsoft.com/en-us/library/cc197957(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc197957(VS.95).aspx"&gt;this documentation topic&lt;/A&gt;. Using the following JSON string as an example,&lt;/P&gt;&lt;CODE&gt;[{"IsMember" : true, "Name" : "John", "Age" : 24}, &lt;BR&gt;{"IsMember" : false, "Name" : "Paul", "Age" : 44},&lt;BR&gt;{"IsMember" : true, "Name" : "George", "Age" : 12}]&lt;BR&gt;&lt;/CODE&gt;
&lt;P&gt;we can parse it into the &lt;STRONG&gt;JsonObject users&lt;/STRONG&gt;, and then access its members this way: &lt;CODE&gt;&lt;FONT size=2&gt;users[0][&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"Name"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;]&lt;/FONT&gt;, &lt;FONT size=2&gt;users[1][&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"Age"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;]&lt;/FONT&gt;&lt;/CODE&gt;, etc. We can then construct LINQ expressions such as &lt;/P&gt;&lt;CODE&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;var&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; members = &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;from&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; member &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;in&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; users&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;where&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; member[&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;FONT color=#a31515&gt;"IsMember"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt;]&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;select&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; member;&lt;/FONT&gt;&lt;/P&gt;&lt;/CODE&gt;
&lt;P mce_keep="true"&gt;The &lt;A class="" title="FoodFinder Sample" href="http://silverlight.net/samples/2b2/foodfinder/run/default.html" mce_href="http://silverlight.net/samples/2b2/foodfinder/run/default.html"&gt;FoodFinder sample on silverlight.net&lt;/A&gt; provides a real usage example of the Yahoo! Local JSON API (&lt;A class="" title="FoodFinder Sample Source Code" href="http://silverlight.net/samples/2b2/foodfinder/foodfinder.zip" mce_href="http://silverlight.net/samples/2b2/foodfinder/foodfinder.zip"&gt;download the source code&lt;/A&gt;). The following LINQ query is used by the sample to dynamically filter the results returned by the service based on two sliders that the user controls.&lt;/P&gt;&lt;CODE&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;var&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; members = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;from&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; restaurant &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;in&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;JsonArray&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;)results[&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"ResultSet"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;][&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"Result"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;]&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;where&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;float&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.Parse(restaurant[&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"Rating"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;][&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"AverageRating"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;]) &amp;gt;= rating.Value&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;float&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.Parse(restaurant[&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"Distance"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;]) &amp;lt; distance.Value&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;select&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; restaurant;&lt;/FONT&gt;&lt;/P&gt;&lt;/CODE&gt;
&lt;H4&gt;Configuration Support&lt;/H4&gt;
&lt;P&gt;In Beta 1, the binding and endpoint address had to be specified in code and passed as parameters to the proxy constructor. &lt;/P&gt;&lt;CODE&gt;
&lt;P&gt;&lt;FONT color=#2b91af size=2&gt;BasicHttpBinding&lt;/FONT&gt;&lt;FONT size=2&gt; binding = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;BasicHttpBinding&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;EndpointAddress&lt;/FONT&gt;&lt;FONT size=2&gt; address = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;EndpointAddress&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;A href="http://localhost/service.svc"&gt;http://localhost/service.svc&lt;/A&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;BR&gt;&lt;FONT color=#2b91af&gt;ServiceClient&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp;&lt;/FONT&gt;proxy = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;ServiceClient&lt;/FONT&gt;&lt;FONT size=2&gt;(binding, address);&lt;/FONT&gt;&lt;/P&gt;&lt;/CODE&gt;
&lt;P&gt;In Beta 2 the "Add Service Reference" feature in Visual Studio will generate a &lt;STRONG&gt;ServiceReference.clientConfig &lt;/STRONG&gt;file, which will contain the binding and address configuration informaton, and the proxy can be constructed with its default constructor.&lt;/P&gt;&lt;CODE&gt;
&lt;P&gt;&lt;FONT color=#2b91af&gt;ServiceClient&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp;&lt;/FONT&gt;proxy = &lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;&lt;FONT color=#2b91af size=2&gt;ServiceClient&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;/FONT&gt;&lt;/P&gt;&lt;/CODE&gt;
&lt;P&gt;This allows us to change the binding/address without needing to recompile the Silverlight control. In addition configuration exposes some&amp;nbsp;knobs on the binding, which can be tweaked for security or performance reasons:&lt;/P&gt;&lt;CODE&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;binding &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&lt;FONT color=#ff0000 size=2&gt;name&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;BasicHttpBinding_IService&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;" &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&lt;FONT color=#ff0000 size=2&gt;closeTimeout&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;00:59:00&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;" &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&lt;FONT color=#ff0000 size=2&gt;openTimeout&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;00:53:00&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&lt;FONT color=#ff0000 size=2&gt;receiveTimeout&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;00:15:00&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;" &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&lt;FONT color=#ff0000 size=2&gt;sendTimeout&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;00:21:00&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;" &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&lt;FONT color=#ff0000 size=2&gt;maxBufferSize&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;65530&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&lt;FONT color=#ff0000 size=2&gt;maxReceivedMessageSize&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;65531&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;" &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&lt;FONT color=#ff0000 size=2&gt;textEncoding&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;utf-8&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt; /&amp;gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/CODE&gt;
&lt;P&gt;&lt;A class="" title="Configuring Web Service Usage in Silverlight Clients" href="http://msdn.microsoft.com/en-us/library/cc197941(VS.95).aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc197941(VS.95).aspx"&gt;This documentation topic &lt;/A&gt;explains the different settings available.&lt;/P&gt;
&lt;H4&gt;Tooling Improvements&lt;/H4&gt;
&lt;P&gt;We have added the "Silverlight-enalbled WCF Service" Item template.&amp;nbsp;When a WCF service is added using this template, the binding&amp;nbsp;in the service configuration is automatically switched to basicHttpBinding.&lt;/P&gt;
&lt;P&gt;&lt;IMG title="Silverlight-enabled WCF Service Item Template" style="WIDTH: 630px; HEIGHT: 527px" height=527 alt="Silverlight-enabled WCF Service Item Template" src="http://blogs.msdn.com/photos/silverlightws/images/8589685/original.aspx" width=630 mce_src="http://blogs.msdn.com/photos/silverlightws/images/8589685/original.aspx"&gt;&lt;/P&gt;
&lt;P&gt;IntelliSense over .clientConfig files is now supported. As you start editing the file you will get useful popups with the supported schema.&lt;/P&gt;
&lt;P&gt;&lt;IMG title="IntelliSense over .clientConfig" style="WIDTH: 638px; HEIGHT: 185px" height=185 alt="IntelliSense over .clientConfig" src="http://blogs.msdn.com/photos/silverlightws/images/8589683/original.aspx" width=638 mce_src="http://blogs.msdn.com/photos/silverlightws/images/8589683/original.aspx"&gt;&lt;/P&gt;
&lt;H4&gt;SOAP Improvements&lt;/H4&gt;
&lt;P&gt;We have made some general SOAP improvements in Beta 2:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Custom SOAP headers and faults in service - ignored and don't generate uncompilable code&lt;/LI&gt;
&lt;LI&gt;“Wildcard” schema in service (like xsd:any or xsd:anyattribute) - now works and doesn't generate uncompilable code&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;And specifically if your service is a WCF (or in some cases .ASMX) service:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;XML types like XmlElement/XElement/XmlNode[]/XmlAttribute/etc in service - now&amp;nbsp;work and don't generate uncompilable code&lt;/LI&gt;
&lt;LI&gt;Types that implement ISerializable in your service (except for collections) - now work and don't generate uncompilable code&lt;/LI&gt;
&lt;LI&gt;Stream type in service - now works and doesn't generate uncompilable code&lt;/LI&gt;
&lt;LI&gt;MessageHeaderAttribute in Message Contracts - ignored and doesn't generate uncompilable code&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Please keep an eye on this blog for more specifics in the next couple of weeks.&lt;/P&gt;
&lt;P&gt;Cheers,&lt;BR&gt;-Yavor Georgiev&lt;BR&gt;Program Manager, Connected Framework Team&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8589374" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/silverlightws/archive/tags/json/default.aspx">json</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/soap/default.aspx">soap</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/duplex/default.aspx">duplex</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/tools/default.aspx">tools</category></item><item><title>Debugging Web Service Usage in Silverlight 2</title><link>http://blogs.msdn.com/silverlightws/archive/2008/04/16/debugging-web-service-usage-in-silverlight-2.aspx</link><pubDate>Wed, 16 Apr 2008 21:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8399338</guid><dc:creator>SLWSTeam</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/silverlightws/comments/8399338.aspx</comments><wfw:commentRss>http://blogs.msdn.com/silverlightws/commentrss.aspx?PostID=8399338</wfw:commentRss><description>&lt;P&gt;(Cross-posted from &lt;A href="http://eugeneos.blogspot.com/2008/04/debugging-web-service-usage-in.html"&gt;http://eugeneos.blogspot.com/2008/04/debugging-web-service-usage-in.html&lt;/A&gt;)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Silverlight 2 Beta1 makes it easy to use Web Services based on either the WCF technology (Windows Communication Foundation), the “.asmx” technology (ASP.NET Web Services), or practically any other SOAP platform. &lt;/P&gt;
&lt;P&gt;Unfortunately, when something goes wrong with service consumption, you often run into cryptic and incomprehensible error messages that don’t help you much. We are looking into various ways to make this better by the time we fully ship Silverlight 2, but for now I hope that this post will be useful in helping you debug common problems. Here are the things you can try:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;SPAN style="FONT-SIZE: 130%"&gt;Does your proxy compile?&lt;/SPAN&gt;&lt;/U&gt; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;After you use the “Add Service Reference” dialog to add a reference to a service, try building your project. If you get compilation issues in the generated proxy code, you are probably using a service that uses some feature that is not supported in Beta1. We are trying to fix all or most of these by the time we ship, but for now the easiest thing to do is to find the offending code in the generated proxy and just remove it – naturally this workaround does not work in all cases :) Some common things that will cause non-compilable proxies in Beta1: &lt;/P&gt;
&lt;P&gt;- Using custom SOAP headers in your service &lt;BR&gt;- Using custom SOAP faults &lt;BR&gt;- Using “wildcard” schema in your service like &lt;STRONG&gt;xsd:any&lt;/STRONG&gt; or &lt;STRONG&gt;xsd:anyattribute&lt;/STRONG&gt; &lt;/P&gt;
&lt;P&gt;And specifically if your service is a WCF (or in some cases .ASMX) service: &lt;/P&gt;
&lt;P&gt;- Using XML types like XmlElement/XElement/XmlNode[]/XmlAttribute/etc. in your service &lt;BR&gt;- Using Datasets in your service &lt;BR&gt;- Using types that implement ISerializable in your service (except for collections) &lt;BR&gt;- Using WCF Transactions features &lt;BR&gt;- Using the Stream type in your service &lt;BR&gt;- Using MessageHeaderAttribute in Message Contracts &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;SPAN style="FONT-SIZE: 130%"&gt;Check the Configuration&lt;/SPAN&gt;&lt;/U&gt;&lt;/STRONG&gt; &lt;/P&gt;
&lt;P&gt;The next step is to check whether the service is configured correctly. You should have a file called &lt;STRONG&gt;&lt;EM&gt;ServiceReferences.ClientConfig &lt;/EM&gt;&lt;/STRONG&gt;generated by Add Service Reference. It actually doesn’t do anything at all in Beta1! This (understandably) confuses a lot of people. Starting with Beta2, we will actually start using this file, but for now any changes that you’ll make in it won’t actually affect anything. &lt;/P&gt;
&lt;P&gt;However, the file is still useful for debugging. Look in the file – it should look something like this: &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="COLOR: #000099"&gt;&amp;lt;configuration&amp;gt;&lt;BR&gt;&amp;lt;system.serviceModel&amp;gt; &lt;BR&gt;&amp;lt;client&amp;gt; &lt;BR&gt;&lt;STRONG&gt;&amp;lt;endpoint address="&lt;SPAN style="COLOR: #990000"&gt;http://localhost:5678/TestService.svc&lt;/SPAN&gt;" binding="&lt;SPAN style="COLOR: #990000"&gt;basicHttpBinding&lt;/SPAN&gt;" contract="MyProject.ITestService" name="default" /&amp;gt; &lt;BR&gt;&lt;/STRONG&gt;&amp;lt;/client&amp;gt; &lt;BR&gt;&amp;lt;/system.serviceModel&amp;gt; &lt;BR&gt;&amp;lt;/configuration&amp;gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="COLOR: #000099"&gt;&lt;SPAN style="FONT-FAMILY: Courier New"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;Notice that it has exactly one &lt;STRONG&gt;&lt;EM&gt;endpoint&lt;/EM&gt;&lt;/STRONG&gt; element for the service you just added a reference to, and the binding is basicHttpBinding. &lt;/P&gt;
&lt;P&gt;If you don’t see an &lt;STRONG&gt;&lt;EM&gt;endpoint&lt;/EM&gt;&lt;/STRONG&gt; element for your service, chances are your service wasn’t actually configured correctly for Silverlight consumption. Silverlight can only talk to simple SOAP services at this point – only SOAP 1.1, without any advanced WS-* protocols like WS-Addressing or WS-Security. If you are using “.ASMX” web services, they should just default to this simple configuration. If you are using WCF services, you need to check the configuration on the service side. Open &lt;STRONG&gt;&lt;EM&gt;web.config &lt;/EM&gt;&lt;/STRONG&gt;in your service-side project and find a place that looks like the following (usually towards the end): &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="COLOR: #000099"&gt;&amp;lt;system.serviceModel&amp;gt; &lt;BR&gt;... &lt;BR&gt;&amp;lt;services&amp;gt; &lt;BR&gt;&amp;lt;service name="MyProject.TestService"&amp;gt; &lt;BR&gt;&lt;STRONG&gt;&amp;lt;endpoint address="" binding="&lt;SPAN style="COLOR: #990000"&gt;basicHttpBinding&lt;/SPAN&gt;" contract="&lt;SPAN style="COLOR: #990000"&gt;MyProject.ITestService&lt;/SPAN&gt;" /&amp;gt; &lt;BR&gt;&lt;/STRONG&gt;&amp;lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&amp;gt; &lt;BR&gt;... &lt;BR&gt;&amp;lt;/service&amp;gt; &lt;BR&gt;&amp;lt;/services&amp;gt; &lt;BR&gt;&amp;lt;/system.serviceModel&amp;gt;&lt;/SPAN&gt; &lt;/P&gt;
&lt;P&gt;Find the &lt;STRONG&gt;&lt;EM&gt;endpoint&lt;/EM&gt;&lt;/STRONG&gt; whose “contract” attribute refers to your service. Make sure that the “binding” attribute is set to “basicHttpBinding”. Unfortunately the default for WCF is “wsHttpBinding”, but it doesn’t work with Silverlight. We are hoping to ship a Visual Studio item template in the future (“Add New Item… Silverlight-enabled WCF Service”) that will have a number of Silverlight-friendly defaults, including the correct binding. &lt;/P&gt;
&lt;P&gt;It is ok to have other &lt;STRONG&gt;&lt;EM&gt;endpoint&lt;/EM&gt;&lt;/STRONG&gt; elements for other contracts with other bindings - for example, do not change the "mexHttpBinding" in the second &lt;STRONG&gt;&lt;EM&gt;endpoint&lt;/EM&gt;&lt;/STRONG&gt; element above. &lt;/P&gt;
&lt;P&gt;You should check your service-side configuration even if the client-side &lt;STRONG&gt;&lt;EM&gt;ServiceReferences.ClientConfig &lt;/EM&gt;&lt;/STRONG&gt;appears to be correct. &lt;/P&gt;
&lt;P&gt;If &lt;STRONG&gt;&lt;EM&gt;ServiceReferences.ClientConfig &lt;/EM&gt;&lt;/STRONG&gt;contains more than one &lt;STRONG&gt;&lt;EM&gt;endpoint&lt;/EM&gt;&lt;/STRONG&gt; for your service, you may need to use a more complicated constructor to new up your service proxy – the one that takes a Binding and an EndpointAddress. Not to worry – just pass a new BasicHttpBinding() and a new EndpointAddress built from the URL of your service. &lt;/P&gt;
&lt;P&gt;By the way, our long-term (post-Beta1) plans for the config file are described here: &lt;A href="http://blogs.msdn.com/suwatch/archive/2008/04/07/tutorial-using-silverlight-web-service-client-configuration.aspx" mce_href="http://blogs.msdn.com/suwatch/archive/2008/04/07/tutorial-using-silverlight-web-service-client-configuration.aspx"&gt;http://blogs.msdn.com/suwatch/archive/2008/04/07/tutorial-using-silverlight-web-service-client-configuration.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;SPAN style="FONT-SIZE: 130%"&gt;Check if the Service is Running&lt;/SPAN&gt;&lt;/U&gt;&lt;/STRONG&gt; &lt;/P&gt;
&lt;P&gt;Before looking for problems on the Silverlight side, it is useful to first check whether the service itself is working. A quick-and-dirty way to check is to just type the service address into a web browser (not the address you typed into the “Add Service Reference” dialog, but the address you can find in &lt;STRONG&gt;&lt;EM&gt;ServiceReferences.ClientConfig&lt;/EM&gt;&lt;/STRONG&gt;). In many cases, the “service help page” feature will be turned on and you will see either a page indicating that the service is running, or an error page which you can use as a starting point for debugging. &lt;/P&gt;
&lt;P&gt;A more reliable way to test whether the service is working is to use a test tool such as the WCF Test Client (&lt;A href="http://msdn2.microsoft.com/en-us/library/bb552364.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/bb552364.aspx"&gt;http://msdn2.microsoft.com/en-us/library/bb552364.aspx&lt;/A&gt;) to try and talk to the service. &lt;/P&gt;
&lt;P&gt;Finally, an almost sure-fire but sometimes lengthy way of finding out whether the problem is with the Silverlight code or with the service code is to try using the service without Silverlight :) Just create a new project of type “Console Application”, do an Add Service Reference to that project just like in Silverlight, and write service consumption code inside Main() – again, just like in Silverlight. Use Console.WriteLine to show the results. &lt;STRONG&gt;&lt;U&gt;&lt;SPAN style="FONT-SIZE: 130%"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;SPAN style="FONT-SIZE: 130%"&gt;Check for Cross-Domain Issues&lt;/SPAN&gt;&lt;/U&gt;&lt;/STRONG&gt; &lt;/P&gt;
&lt;P&gt;Start your Silverlight application. Note the URL that appears in the browser (e.g. &lt;STRONG&gt;http://localhost:1111/something/MyGraphicalApp.aspx&lt;/STRONG&gt;) – this is your “Application URL”. (Actually, what matters here is the URL of the XAP file, e.g. &lt;STRONG&gt;http://localhost:1111/somethingelse/MyGraphicalApp.xap&lt;/STRONG&gt;, but in most simple cases this URL would be in the same domain as the hosting web page, so I’m ignoring the difference for now). Then, look at the URL in the ServiceReferences.ClientConfig file – e.g. &lt;STRONG&gt;http://localhost:5678/foo/TestService.svc &lt;/STRONG&gt;or &lt;STRONG&gt;local.live.com/SearchService/LocalSearch.asmx&lt;/STRONG&gt; - this is your “Service URL”. &lt;/P&gt;
&lt;P&gt;In Beta1, both the “Application URL” and the “Service URL” must be HTTP URLs (not HTTPS) for service consumption to work. This is the first thing to check. &lt;/P&gt;
&lt;P&gt;Also, a common mistake is to run your Silverlight application from a &lt;STRONG&gt;file:// &lt;/STRONG&gt;Application URL, resulting in cross-domain issues. Sometimes, you run into this if you just hit F5 to run your Silverlight app – instead, right-click on the .aspx page in your project and choose “View in Browser”. &lt;/P&gt;
&lt;P&gt;Now you need to figure out the domains for these URLs. The domain is just the basically everything between &lt;STRONG&gt;http:// &lt;/STRONG&gt;and the first slash &lt;STRONG&gt;/ &lt;/STRONG&gt;after that, including the port number (assumed to be 80 if not present). If the domain of the Application URL is different in any way from the domain of the Service URL in any way (even if it’s just a port number difference, or just one part of the domain name is different), you have a cross-domain situation. For example, if your app is at &lt;STRONG&gt;http://localhost:1111/something/MyGraphicalApp.aspx &lt;/STRONG&gt;and it is trying to call into &lt;STRONG&gt;http://localhost:5678/foo/TestService.svc&lt;/STRONG&gt;, you have a cross-domain situation because &lt;STRONG&gt;localhost:1111 &lt;/STRONG&gt;is different from &lt;STRONG&gt;localhost:5678&lt;/STRONG&gt;. &lt;/P&gt;
&lt;P&gt;Silverlight documentation tells you that if you are in a cross-domain situation, you need to have a “cross-domain policy file” (&lt;STRONG&gt;&lt;EM&gt;clientaccesspolicy.xml &lt;/EM&gt;&lt;/STRONG&gt;or &lt;STRONG&gt;&lt;EM&gt;crossdomain.xml&lt;/EM&gt;&lt;/STRONG&gt;) present if you want services to work. There is an easy way to check if you have everything set up correctly: Just open a browser and browse to &lt;STRONG&gt;http://&lt;/STRONG&gt;&lt;EM&gt;service_domain&lt;/EM&gt;&lt;STRONG&gt;/clientaccesspolicy.xml &lt;/STRONG&gt;and &lt;STRONG&gt;http://&lt;/STRONG&gt;&lt;EM&gt;service_domain&lt;/EM&gt;&lt;STRONG&gt;/crossdomain.xml&lt;/STRONG&gt;. If at least one of these is present, valid and allows cross-domain access – you’re fine. If not, you need to make sure at least one of these files is present. &lt;/P&gt;
&lt;P&gt;A common mistake is to put the cross-domain policy file not directly at the root of the domain – for example, at &lt;STRONG&gt;http://localhost:5678/foo/clientaccesspolicy.xml &lt;/STRONG&gt;instead of at &lt;STRONG&gt;http://localhost:5678/clientaccesspolicy.xml&lt;/STRONG&gt;. It is easy to run into this situation when working with older (.NET 2.0) projects – see &lt;A href="http://timheuer.com/blog/archive/2008/04/09/silverlight-cannot-access-web-service.aspx" mce_href="http://timheuer.com/blog/archive/2008/04/09/silverlight-cannot-access-web-service.aspx"&gt;http://timheuer.com/blog/archive/2008/04/09/silverlight-cannot-access-web-service.aspx&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;Also, make sure to check the syntax of these files – an error in parsing will be treated essentially the same way as if the file was not there. Also note that &lt;STRONG&gt;&lt;EM&gt;clientaccesspolicy.xml &lt;/EM&gt;&lt;/STRONG&gt;and &lt;STRONG&gt;&lt;EM&gt;crossdomain.xml &lt;/EM&gt;&lt;/STRONG&gt;have different syntax – make sure you use the appropriate content for the file you choose. &lt;/P&gt;
&lt;P&gt;A neat trick for adding cross-domain policy files to WCF services that are not hosted in IIS is described here: &lt;A href="http://blogs.msdn.com/carlosfigueira/archive/2008/03/07/enabling-cross-domain-calls-for-silverlight-apps-on-self-hosted-web-services.aspx" mce_href="http://blogs.msdn.com/carlosfigueira/archive/2008/03/07/enabling-cross-domain-calls-for-silverlight-apps-on-self-hosted-web-services.aspx"&gt;http://blogs.msdn.com/carlosfigueira/archive/2008/03/07/enabling-cross-domain-calls-for-silverlight-apps-on-self-hosted-web-services.aspx&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;SPAN style="FONT-SIZE: 130%"&gt;Enable Exceptions&lt;/SPAN&gt;&lt;/U&gt;&lt;/STRONG&gt; &lt;/P&gt;
&lt;P&gt;Normally, Silverlight does not give you much information in exception messages. This decision was made to make the Silverlight download size smaller (exceptions take up a lot of space, especially once they’re translated into all of the languages Silverlight supports). You can read more about this, and find out how to turn on full exceptions for debugging, here: &lt;A href="http://blogs.msdn.com/silverlightws/archive/2008/04/06/getting-full-exceptions-in-silverlight-2-beta-1.aspx" mce_href="http://blogs.msdn.com/silverlightws/archive/2008/04/06/getting-full-exceptions-in-silverlight-2-beta-1.aspx"&gt;http://blogs.msdn.com/silverlightws/archive/2008/04/06/getting-full-exceptions-in-silverlight-2-beta-1.aspx&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Also, if you are using a WCF service, WCF does not normally return much information about server-side exceptions. This is a security measure: you normally don’t want to expose internal information about your service to the outside world. However, during debugging, you can change this by following the steps here: &lt;A href="http://blogs.devdeo.com/carlos.medina/PermaLink,guid,b3bff742-0ec9-4f5c-a178-625220a46652.aspx" mce_href="http://blogs.devdeo.com/carlos.medina/PermaLink,guid,b3bff742-0ec9-4f5c-a178-625220a46652.aspx"&gt;http://blogs.devdeo.com/carlos.medina/PermaLink,guid,b3bff742-0ec9-4f5c-a178-625220a46652.aspx&lt;/A&gt;. Make sure to turn it off once you’re done debugging! &lt;/P&gt;
&lt;P&gt;Finally, this seems obvious but a lot of people forget about it for some reason - when you get an exception, don’t just look at the exception itself - look at its innerException, and the innerException inside it, etc. Especially in web service scenarios, the truly useful exceptions are often “wrapped” in several layers. &lt;/P&gt;
&lt;P&gt;Unfortunately, even with all of the steps above, you often still won’t see much useful information when a web service call fails. This is due to a pretty fundamental limitation of Silverlight Beta1 (that unfortunately may stay around even after the Beta) – the lack of support for SOAP Faults. So, to truly debug, you need to see what is actually going on – this is what the next section is about. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;SPAN style="FONT-SIZE: 130%"&gt;Getting Down to the Wire&lt;/SPAN&gt;&lt;/U&gt;&lt;/STRONG&gt; &lt;/P&gt;
&lt;P&gt;The ultimate way to debug Silverlight service consumption issues is by using an “HTTP spying” tool such as &lt;A href="http://www.fiddlertool.com/fiddler/" mce_href="http://www.fiddlertool.com/fiddler/"&gt;http://www.fiddlertool.com/fiddler/&lt;/A&gt; or &lt;A href="http://projects.nikhilk.net/webdevhelper/" mce_href="http://projects.nikhilk.net/webdevhelper/"&gt;http://projects.nikhilk.net/webdevhelper/&lt;/A&gt; that shows you the actual HTTP traffic as it happens. Before using it, make sure to enable server-side exceptions (see above). Start your Silverlight app and your tool side-by-side, and make your app do a web service call. Here are some common patterns you will see: &lt;/P&gt;
&lt;P&gt;&lt;U&gt;1.Nothing&lt;/U&gt; &lt;BR&gt;- Your HTTP spying tool may be misconfigured (try running another, non-Silverlight app, like a regular web browser, to make sure it works) &lt;BR&gt;- Your app may be broken – put a breakpoint where you invoke the service, make sure it’s hit &lt;BR&gt;- You may have a configuration issue – see Configuration section above &lt;BR&gt;- You may be trying to host your application from a &lt;STRONG&gt;file:// &lt;/STRONG&gt;or &lt;STRONG&gt;https:// &lt;/STRONG&gt;URL, or trying to call an &lt;STRONG&gt;https:// &lt;/STRONG&gt;service &lt;/P&gt;
&lt;P&gt;&lt;U&gt;2. Just a service request &lt;BR&gt;&lt;/U&gt;- Congratulations – you’ve avoided a cross-domain situation if you see the actual request to the service on the wire. &lt;BR&gt;- Is the address what you expected it to be? &lt;BR&gt;- Look at what’s coming back. Is it timing out or are you getting a 404? Your service or even WCF itself may not be set up correctly. &lt;BR&gt;- Are you getting a SOAP fault back? If so, read carefully what’s in the fault – it will usually have enough information to debug the issue. &lt;BR&gt;- In general, look very carefully at both the request and the reply (including the body and HTTP headers) &lt;BR&gt;- Did you remove anything to get the proxy to compile? The service may actually require some items that you removed (e.g. may require certain SOAP headers) &lt;/P&gt;
&lt;P&gt;&lt;U&gt;3. A request to &lt;STRONG&gt;&lt;EM&gt;clientaccesspolicy.xml &lt;/EM&gt;&lt;/STRONG&gt;(and possibly &lt;STRONG&gt;&lt;EM&gt;crossdomain.xml &lt;/EM&gt;&lt;/STRONG&gt;afterwards), followed by a request to the service&lt;/U&gt; &lt;BR&gt;- Congratulations – you have a cross-domain situation but you have successfully set up your cross-domain policy files &lt;BR&gt;- This is now equivalent to situation #2 above &lt;/P&gt;
&lt;P&gt;&lt;U&gt;4. Just a request to &lt;STRONG&gt;&lt;EM&gt;clientaccesspolicy.xml &lt;/EM&gt;&lt;/STRONG&gt;and nothing else&lt;/U&gt; &lt;BR&gt;- Most likely a malformed &lt;STRONG&gt;&lt;EM&gt;clientaccesspolicy.xml&lt;/EM&gt;&lt;/STRONG&gt;, or one that contains a policy that forbids cross-domain access &lt;/P&gt;
&lt;P&gt;&lt;U&gt;5. A request to &lt;STRONG&gt;&lt;EM&gt;clientaccesspolicy.xml&lt;/EM&gt;&lt;/STRONG&gt;, then &lt;STRONG&gt;&lt;EM&gt;crossdomain.xml&lt;/EM&gt;&lt;/STRONG&gt;, then nothing else&lt;/U&gt; &lt;BR&gt;- Basically, something went wrong with cross-domain policy files. &lt;BR&gt;- Are you getting 404s back? Check if you’re hosting the files correctly and at the correct locations &lt;BR&gt;- Are you getting the actual files back? They may be malformed or may forbid cross-domain access &lt;/P&gt;
&lt;P&gt;&amp;nbsp;-- Eugene Osovetsky, Program Manager, Silverlight Web Services team&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8399338" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/silverlightws/archive/tags/wcf/default.aspx">wcf</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/crossdomain/default.aspx">crossdomain</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/debugging/default.aspx">debugging</category><category domain="http://blogs.msdn.com/silverlightws/archive/tags/soap/default.aspx">soap</category></item></channel></rss>