<?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>A Cup of Silverlight, RIA &amp; Interoperability : D2D</title><link>http://blogs.msdn.com/silverlight_plus_java/archive/tags/D2D/default.aspx</link><description>Tags: D2D</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>How-To : Silverlight accessing Java SOAP services (Part 2 – No Cross Domain : Tomcat/Eclipse)</title><link>http://blogs.msdn.com/silverlight_plus_java/archive/2008/08/14/how-to-silverlight-accessing-java-soap-services-part-2-no-cross-domain-tomcat-eclipse.aspx</link><pubDate>Thu, 14 Aug 2008 16:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8903377</guid><dc:creator>Steve SFARTZ</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/silverlight_plus_java/comments/8903377.aspx</comments><wfw:commentRss>http://blogs.msdn.com/silverlight_plus_java/commentrss.aspx?PostID=8903377</wfw:commentRss><description>&lt;P mce_keep="true"&gt;The &lt;A href="http://blogs.msdn.com/silverlight_plus_java/archive/tags/How-to/default.aspx" mce_href="http://blogs.msdn.com/silverlight_plus_java/archive/tags/How-to/default.aspx"&gt;HowTo&lt;/A&gt; series demo Silverlight accessing Web Services in various configuration. In this post, we will demonstrate you a SOAP service consumed by a Silverlight client application where the Site of Origin hosts the Web Services. This scenario is categorized as a &lt;A href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/28/scenario-d2d-developer-env.aspx" mce_href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/28/scenario-d2d-developer-env.aspx"&gt;D2D scenario&lt;/A&gt; &lt;STRONG&gt;without cross-domain policy&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;The SOAP service Eclipse project and the Silverlight Eclipse project are available as an attachment to this post.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Technical Environment&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;SOAP services are built with the JAX-WS and JAX-B Api and hosted in Tomcat&lt;/LI&gt;
&lt;LI&gt;The Silverlight application is also hosted in Tomcat&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_DF27/image_2.png" mce_href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_DF27/image_2.png"&gt;&lt;IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=378 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_DF27/image_thumb.png" width=480 border=0 mce_src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_DF27/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Because the Site of Origin and the Web Service reside in the same host, no Cross Domain policy is required.&lt;/P&gt;
&lt;H4&gt;Hosting the Web Service in Tomcat&lt;/H4&gt;
&lt;P&gt;In case you haven’t done the &lt;A href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/08/04/how-to-silverlight-accessing-java-soap-services-part-1-cross-domain-iis-tomcat.aspx" mce_href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/08/04/how-to-silverlight-accessing-java-soap-services-part-1-cross-domain-iis-tomcat.aspx"&gt;How-To : Silverlight accessing Java SOAP services (Part 1 – Cross Domain : IIS + Tomcat)&lt;/A&gt;, you can directly import the SOAP-Sum service Eclipse project into your Eclipse Workspace.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Export it as a WAR in %TOMCAT_INSTALL%/webapps folder&lt;/LI&gt;
&lt;LI&gt;go to &lt;A href="http://localhost:8080/SOAP-SumService/services/sum" mce_href="http://localhost:8080/SOAP-SumService/services/sum"&gt;http://localhost:8080/SOAP-SumService/services/sum&lt;/A&gt; (assuming that Tomcat is running on port 8080) to access the service.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_DF27/image_4.png" mce_href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_DF27/image_4.png"&gt;&lt;IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=215 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_DF27/image_thumb_1.png" width=325 border=0 mce_src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_DF27/image_thumb_1.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;H4&gt;Hosting the Silverlight Application using a Servlet&lt;/H4&gt;
&lt;P&gt;In the &lt;A href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/08/06/how_2D00_to-silverlight-accessing-java-rest-services-part-2-no-cross-domain-tomcat.aspx" mce_href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/08/06/how_2D00_to-silverlight-accessing-java-rest-services-part-2-no-cross-domain-tomcat.aspx"&gt;REST way&lt;/A&gt;, we showed you how to host a Silverlight Application using a JSP. Now we are going to host a Silverlight application using a Servlet&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;In Eclipse, create a new dynamic web project named &lt;STRONG&gt;Silverlight-SOAP-SumService_NOSSL&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;In &lt;STRONG&gt;WebContent&lt;/STRONG&gt; folder, add a folder named &lt;STRONG&gt;ClientBin&lt;/STRONG&gt; and copy in the latter, the xap file in the attachment. The Silverlight Application is already configured to access the SOAP service at &lt;A href="http://localhost:8080/SOAP-SumService/services/sum?wsdl" mce_href="http://localhost:8080/SOAP-SumService/services/sum?wsdl"&gt;http://localhost:8080/SOAP-SumService/services/sum?wsdl&lt;/A&gt;. &lt;/LI&gt;
&lt;LI&gt;Add a Servlet named SilverlightServlet to a package ‘&lt;STRONG&gt;servlet&lt;/STRONG&gt;’ and add the following code :&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Instance of Silverlight plugin :&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; responseHandler(HttpServletResponse response) throws IOException{&lt;/PRE&gt;&lt;PRE&gt;    PrintWriter pw = response.getWriter();&lt;/PRE&gt;&lt;PRE class=alt&gt;    pw.println(&lt;SPAN class=str&gt;""&lt;/SPAN&gt; +&lt;/PRE&gt;&lt;PRE&gt;            &lt;SPAN class=str&gt;"&amp;lt;div id=\"silverlightControlHost\"&amp;gt;"&lt;/SPAN&gt; +&lt;/PRE&gt;&lt;PRE class=alt&gt;            &lt;SPAN class=str&gt;"    &amp;lt;object data=\"data:application/x-silverlight,\""&lt;/SPAN&gt; +&lt;/PRE&gt;&lt;PRE&gt;            &lt;SPAN class=str&gt;"             type=\"application/x-silverlight-2-b2\""&lt;/SPAN&gt; +&lt;/PRE&gt;&lt;PRE class=alt&gt;            &lt;SPAN class=str&gt;"             width=\"100%\" height=\"100%\"&amp;gt;"&lt;/SPAN&gt; +&lt;/PRE&gt;&lt;PRE&gt;            &lt;SPAN class=str&gt;"       &amp;lt;param name=\"source\" value=\"ClientBin/SOAP-Sum.xap\"/&amp;gt;"&lt;/SPAN&gt; +&lt;/PRE&gt;&lt;PRE class=alt&gt;            &lt;SPAN class=str&gt;"       &amp;lt;param name=\"background\" value=\"white\" /&amp;gt;"&lt;/SPAN&gt; +&lt;/PRE&gt;&lt;PRE&gt;            &lt;SPAN class=str&gt;"       &amp;lt;a href=\"http://go.microsoft.com/fwlink/?LinkID=115261\""&lt;/SPAN&gt; +&lt;/PRE&gt;&lt;PRE class=alt&gt;            &lt;SPAN class=str&gt;"          style=\'text-decoration: none;\'&amp;gt;'&lt;/SPAN&gt; +&lt;/PRE&gt;&lt;PRE&gt;            &lt;SPAN class=str&gt;"         &amp;lt;img src=\"http://go.microsoft.com/fwlink/?LinkId=108181\""&lt;/SPAN&gt;+&lt;/PRE&gt;&lt;PRE class=alt&gt;            &lt;SPAN class=str&gt;"              alt=\"Get Microsoft Silverlight\""&lt;/SPAN&gt; +&lt;/PRE&gt;&lt;PRE&gt;            &lt;SPAN class=str&gt;"              style=\'border-style: none\'/&amp;gt;'&lt;/SPAN&gt; +&lt;/PRE&gt;&lt;PRE class=alt&gt;            &lt;SPAN class=str&gt;"        &amp;lt;/a&amp;gt;"&lt;/SPAN&gt; +&lt;/PRE&gt;&lt;PRE&gt;            &lt;SPAN class=str&gt;"    &amp;lt;/object&amp;gt;"&lt;/SPAN&gt; +&lt;/PRE&gt;&lt;PRE class=alt&gt;            &lt;SPAN class=str&gt;"    &amp;lt;iframe style='visibility:hidden;height:0;width:0;border:0px'&amp;gt;'&lt;/SPAN&gt; +&lt;/PRE&gt;&lt;PRE&gt;            &lt;SPAN class=str&gt;"&amp;lt;/iframe&amp;gt;"&lt;/SPAN&gt; +&lt;/PRE&gt;&lt;PRE class=alt&gt;            &lt;SPAN class=str&gt;"&amp;lt;/div&amp;gt;"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE&gt;    pw.close();&lt;/PRE&gt;&lt;PRE class=alt&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;protected&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; doGet(HttpServletRequest request, HttpServletResponse response)&lt;/PRE&gt;&lt;PRE&gt;  throws ServletException, IOException {&lt;/PRE&gt;&lt;PRE class=alt&gt;    responseHandler(response);&lt;/PRE&gt;&lt;PRE&gt;    super.doGet(request, response);&lt;/PRE&gt;&lt;PRE class=alt&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;UL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;Export the project as a WAR file in %TOMCAT_INSTALL%/webapps folder.&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;Go to &lt;A title=http://localhost:8080/Silverlight-SOAP-SumService_NOSSL/SilverlightServlet href="http://localhost:8080/Silverlight-SOAP-SumService_NOSSL/SilverlightServlet" mce_href="http://localhost:8080/Silverlight-SOAP-SumService_NOSSL/SilverlightServlet"&gt;http://localhost:8080/Silverlight-SOAP-SumService_NOSSL/SilverlightServlet&lt;/A&gt; (because In the web.xml file located in WebContent/WEB-INF directory, the servlet is configured to handle every requests made on /SilverlightServlet/*)&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Silverlight will access the SOAP-Sum service without cross-domain&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_DF27/image_6.png" mce_href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_DF27/image_6.png"&gt;&lt;IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=304 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_DF27/image_thumb_2.png" width=459 border=0 mce_src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_DF27/image_thumb_2.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;- &lt;A href="http://www.linkedin.com/in/ronnykwon" target=_blank mce_href="http://www.linkedin.com/in/ronnykwon"&gt;Ronny Kwon&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8903377" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/silverlight_plus_java/attachment/8903377.ashx" length="25967" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/SOAP_2F00_RPC/default.aspx">SOAP/RPC</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/Implementation/default.aspx">Implementation</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/How-to/default.aspx">How-to</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/D2D/default.aspx">D2D</category></item><item><title>Tip : Cross Domain Policy when Self-Hosting your Services</title><link>http://blogs.msdn.com/silverlight_plus_java/archive/2008/08/11/tips-cross-domain-policy-files-in-self-hosted-services.aspx</link><pubDate>Mon, 11 Aug 2008 15:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8848024</guid><dc:creator>Steve SFARTZ</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/silverlight_plus_java/comments/8848024.aspx</comments><wfw:commentRss>http://blogs.msdn.com/silverlight_plus_java/commentrss.aspx?PostID=8848024</wfw:commentRss><description>&lt;P&gt;This &lt;A href="http://blogs.msdn.com/silverlight_plus_java/archive/tags/Tips/default.aspx" mce_href="http://blogs.msdn.com/silverlight_plus_java/archive/tags/Tips/default.aspx"&gt;tip&lt;/A&gt; is about self hosting of services with the .Net WCF&amp;nbsp;or Java Restlet framework. &lt;A href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/31/Cross-Domain-_3A00_-Trouble-while-accessing-Web-Services.aspx" mce_href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/31/Cross-Domain-_3A00_-Trouble-while-accessing-Web-Services.aspx"&gt;Cross-domain access&lt;/A&gt;&amp;nbsp;is mandatory here since the Site of Origin does not host the services.&lt;/P&gt;
&lt;P&gt;Self hosting a service represents a quick &amp;amp; easy&amp;nbsp;way to expose a Web Service for tests purpose. Yet, customization is extermely limited since self hosting does not provide you all the capabilities of Web Servers such as delivering static content (cross domain policy file).&lt;/P&gt;
&lt;P&gt;The first thing you need to know is that when Silverlight attempts to access services in cross-domain, it will send a HTTP GET method on http://&amp;lt;domain:port&amp;gt;/clientaccesspolicy.xml or http://&amp;lt;domain:port&amp;gt;/crossdomain.xml (in case clientaccesspolicy.xml wasn’t found). If you plan to self host your Web Service, you will agree that there is no possible way to host a physical Cross Domain policy file at the root of the Web Server.&lt;/P&gt;
&lt;P&gt;You must handle this request through your Service implementation. It usually matches the /clientaccesspolicy.xml or /crossdomain.xml URI pattern. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;WCF way (inspired from &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" target=_blank 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;Carlo’s blog&lt;/A&gt;)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Self-hosted Service&lt;/U&gt; &lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; Program&lt;/PRE&gt;&lt;PRE&gt;{&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; Main(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;[] args)&lt;/PRE&gt;&lt;PRE&gt;    {&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=rem&gt;// URI of the Service&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;        Uri uri = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Uri(&lt;SPAN class=str&gt;"http://localhost:8081/"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=rem&gt;// create a new WebServiceHost specifying the implementation of the Service&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=rem&gt;// and the specified uri to bind with&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;        WebServiceHost host = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; WebServiceHost(&lt;/PRE&gt;&lt;PRE class=alt&gt;                &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; REST_ItemsServiceLibrary.ItemsREST(),&lt;/PRE&gt;&lt;PRE&gt;                uri);&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=rem&gt;// add the Service Endpoint specifying the Service Interface&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;        host.AddServiceEndpoint(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(REST_ItemsServiceLibrary.IItemsREST),&lt;/PRE&gt;&lt;PRE&gt;                                &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; WebHttpBinding(), &lt;SPAN class=str&gt;""&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=rem&gt;// open the WebServiceHost&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;        host.Open();&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;        Console.WriteLine(&lt;SPAN class=str&gt;"Service hosted at {0}"&lt;/SPAN&gt;, uri.OriginalString);&lt;/PRE&gt;&lt;PRE class=alt&gt;        Console.ReadLine();&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=rem&gt;// close the WebServiceHost&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;        host.Close();&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;    }&lt;/PRE&gt;&lt;PRE class=alt&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;
&lt;U&gt;Handling cross-domain file requests&lt;/U&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As we said earlier, we have to manage the /clientaccesspolicy.xml, specify in the Service Interface that HTTP GET method on the URI /clientaccesspolicy.xml will be handled by GetSilverlightPolicy();&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;[OperationContract]&lt;/PRE&gt;&lt;PRE&gt;[WebGet(UriTemplate =&lt;SPAN class=str&gt;"/clientaccesspolicy.xml"&lt;/SPAN&gt;)]&lt;/PRE&gt;&lt;PRE class=alt&gt;Stream GetSilverlightPolicy();&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;
this also applies to /crossdomain.xml&lt;/P&gt;
&lt;P&gt;Finally, in your Service implementation, return a clientaccesspolicy.xml content:&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; Stream GetSilverlightPolicy()&lt;/PRE&gt;&lt;PRE&gt;{&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; result = &lt;SPAN class=str&gt;@"&amp;lt;?xml version="&lt;/SPAN&gt;&lt;SPAN class=str&gt;"1.0"&lt;/SPAN&gt;&lt;SPAN class=str&gt;" encoding="&lt;/SPAN&gt;&lt;SPAN class=str&gt;"utf-8"&lt;/SPAN&gt;&lt;SPAN class=str&gt;"?&amp;gt;&lt;/PRE&gt;&lt;PRE&gt;&amp;lt;access-policy&amp;gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;    &amp;lt;cross-domain-access&amp;gt;&lt;/PRE&gt;&lt;PRE&gt;        &amp;lt;policy&amp;gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;            &amp;lt;allow-from http-request-headers="&lt;/SPAN&gt;&lt;SPAN class=str&gt;"*"&lt;/SPAN&gt;&lt;SPAN class=str&gt;"&amp;gt;&lt;/PRE&gt;&lt;PRE&gt;                &amp;lt;domain uri="&lt;/SPAN&gt;&lt;SPAN class=str&gt;"*"&lt;/SPAN&gt;&lt;SPAN class=str&gt;"/&amp;gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;            &amp;lt;/allow-from&amp;gt;&lt;/PRE&gt;&lt;PRE&gt;            &amp;lt;grant-to&amp;gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;                &amp;lt;resource path="&lt;/SPAN&gt;&lt;SPAN class=str&gt;"/"&lt;/SPAN&gt;&lt;SPAN class=str&gt;" include-subpaths="&lt;/SPAN&gt;&lt;SPAN class=str&gt;"true"&lt;/SPAN&gt;&lt;SPAN class=str&gt;"/&amp;gt;&lt;/PRE&gt;&lt;PRE&gt;            &amp;lt;/grant-to&amp;gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;        &amp;lt;/policy&amp;gt;&lt;/PRE&gt;&lt;PRE&gt;    &amp;lt;/cross-domain-access&amp;gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;lt;/access-policy&amp;gt;"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; StringToStream(result);&lt;/PRE&gt;&lt;PRE class=alt&gt;}&lt;/PRE&gt;&lt;PRE&gt;Stream StringToStream(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; result)&lt;/PRE&gt;&lt;PRE class=alt&gt;{&lt;/PRE&gt;&lt;PRE&gt;    WebOperationContext.Current.OutgoingResponse.ContentType = &lt;SPAN class=str&gt;"application/xml"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; MemoryStream(Encoding.UTF8.GetBytes(result));&lt;/PRE&gt;&lt;PRE&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;&lt;STRONG&gt;Restlet way&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Self-hosted Service &lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; main(String[] args) {&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=kwrd&gt;try&lt;/SPAN&gt; {&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=rem&gt;// Create a new Component.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;        Component component = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Component();&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=rem&gt;// Add a new HTTP server listening on port 8182.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;        component.getServers().add(Protocol.HTTP, 8182);&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=rem&gt;// Attach the sample application.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;        component.getDefaultHost().attach(&lt;/PRE&gt;&lt;PRE&gt;                &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; FirstResourceApplication(component.getContext()));&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=rem&gt;// Start the component.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;        component.start();&lt;/PRE&gt;&lt;PRE&gt;        &lt;/PRE&gt;&lt;PRE class=alt&gt;    } &lt;SPAN class=kwrd&gt;catch&lt;/SPAN&gt; (Exception e) {&lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=rem&gt;// Something is wrong.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;        e.printStackTrace();&lt;/PRE&gt;&lt;PRE&gt;    }&lt;/PRE&gt;&lt;PRE class=alt&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;&lt;U&gt;Handling cross-domain file requests&lt;/U&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Following the same philosophy as the WCF way, we need to handle HTTP GET method on /clientaccesspolicy.xml file request :&lt;/P&gt;
&lt;P&gt;In the Application implementation you must bind the URI pattern with the Ressource that will handle it :&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/TipsCrossdomainpolicyfilesinselfhostedSe_CA95/image_2.png" mce_href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/TipsCrossdomainpolicyfilesinselfhostedSe_CA95/image_2.png"&gt;&lt;IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=247 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/TipsCrossdomainpolicyfilesinselfhostedSe_CA95/image_thumb.png" width=552 border=0 mce_src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/TipsCrossdomainpolicyfilesinselfhostedSe_CA95/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Finally, implement the ClientAccessPolicy class, specially the HTTP GET method within getRepresentation method :&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;package firstResource;&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=alt&gt;import java.io.IOException;&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=alt&gt;import org.restlet.Context;&lt;/PRE&gt;&lt;PRE&gt;import org.restlet.data.MediaType;&lt;/PRE&gt;&lt;PRE class=alt&gt;import org.restlet.data.Request;&lt;/PRE&gt;&lt;PRE&gt;import org.restlet.data.Response;&lt;/PRE&gt;&lt;PRE class=alt&gt;import org.restlet.resource.DomRepresentation;&lt;/PRE&gt;&lt;PRE&gt;import org.restlet.resource.Representation;&lt;/PRE&gt;&lt;PRE class=alt&gt;import org.restlet.resource.Resource;&lt;/PRE&gt;&lt;PRE&gt;import org.restlet.resource.Variant;&lt;/PRE&gt;&lt;PRE class=alt&gt;import org.w3c.dom.Document;&lt;/PRE&gt;&lt;PRE&gt;import org.w3c.dom.Element;&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; ClientAccessPolicy extends Resource{&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; ClientAccessPolicy(Context context, Request request,&lt;/PRE&gt;&lt;PRE class=alt&gt;            Response response) {&lt;/PRE&gt;&lt;PRE&gt;        super(context, request, response);&lt;/PRE&gt;&lt;PRE class=alt&gt;        getVariants().add(&lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Variant(MediaType.TEXT_XML));&lt;/PRE&gt;&lt;PRE&gt;    }&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;/PRE&gt;&lt;PRE&gt;    @Override&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; Representation getRepresentation(Variant variant){&lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (MediaType.TEXT_XML.equals(variant.getMediaType())) {&lt;/PRE&gt;&lt;PRE class=alt&gt;             &lt;SPAN class=kwrd&gt;try&lt;/SPAN&gt; {&lt;/PRE&gt;&lt;PRE&gt;                DomRepresentation representation = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; DomRepresentation(&lt;/PRE&gt;&lt;PRE class=alt&gt;                      MediaType.TEXT_XML);&lt;/PRE&gt;&lt;PRE&gt;                &lt;SPAN class=rem&gt;// Generate a DOM document representing the list of&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;                &lt;SPAN class=rem&gt;// items.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;                Document d = representation.getDocument();&lt;/PRE&gt;&lt;PRE class=alt&gt;                Element accesspolicy = d.createElement(&lt;SPAN class=str&gt;"access-policy"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE&gt;                d.appendChild(accesspolicy);&lt;/PRE&gt;&lt;PRE class=alt&gt;                &lt;/PRE&gt;&lt;PRE&gt;                Element crossdomainaccess = d.createElement(&lt;SPAN class=str&gt;"cross-domain-access"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE class=alt&gt;                accesspolicy.appendChild(crossdomainaccess);&lt;/PRE&gt;&lt;PRE&gt;                &lt;/PRE&gt;&lt;PRE class=alt&gt;                Element policy = d.createElement(&lt;SPAN class=str&gt;"policy"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE&gt;                crossdomainaccess.appendChild(policy);&lt;/PRE&gt;&lt;PRE class=alt&gt;                &lt;/PRE&gt;&lt;PRE&gt;                Element allowfrom = d.createElement(&lt;SPAN class=str&gt;"allow-from"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE class=alt&gt;                allowfrom.setAttribute(&lt;SPAN class=str&gt;"http-request-headers"&lt;/SPAN&gt;,&lt;SPAN class=str&gt;"*"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE&gt;                &lt;/PRE&gt;&lt;PRE class=alt&gt;                Element domain = d.createElement(&lt;SPAN class=str&gt;"domain"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE&gt;                domain.setAttribute(&lt;SPAN class=str&gt;"uri"&lt;/SPAN&gt;, &lt;SPAN class=str&gt;"*"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE class=alt&gt;                &lt;/PRE&gt;&lt;PRE&gt;                allowfrom.appendChild(domain);&lt;/PRE&gt;&lt;PRE class=alt&gt;                &lt;/PRE&gt;&lt;PRE&gt;                Element grantto = d.createElement(&lt;SPAN class=str&gt;"grant-to"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE class=alt&gt;                Element resource = d.createElement(&lt;SPAN class=str&gt;"resource"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE&gt;                resource.setAttribute(&lt;SPAN class=str&gt;"include-subpaths"&lt;/SPAN&gt;,&lt;SPAN class=str&gt;"true"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE class=alt&gt;                resource.setAttribute(&lt;SPAN class=str&gt;"path"&lt;/SPAN&gt;, &lt;SPAN class=str&gt;"/"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE&gt;                &lt;/PRE&gt;&lt;PRE class=alt&gt;                &lt;/PRE&gt;&lt;PRE&gt;                grantto.appendChild(resource);&lt;/PRE&gt;&lt;PRE class=alt&gt;                &lt;/PRE&gt;&lt;PRE&gt;                policy.appendChild(allowfrom);&lt;/PRE&gt;&lt;PRE class=alt&gt;                policy.appendChild(grantto);&lt;/PRE&gt;&lt;PRE&gt;                &lt;/PRE&gt;&lt;PRE class=alt&gt;                d.normalizeDocument();&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;                &lt;SPAN class=rem&gt;// Returns the XML representation of this document.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;                &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; representation;&lt;/PRE&gt;&lt;PRE&gt;             } &lt;SPAN class=kwrd&gt;catch&lt;/SPAN&gt; (IOException e) {&lt;/PRE&gt;&lt;PRE class=alt&gt;                e.printStackTrace();&lt;/PRE&gt;&lt;PRE&gt;             }&lt;/PRE&gt;&lt;PRE class=alt&gt;          }&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=alt&gt;          &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;    }&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;- &lt;A class="" href="http://www.linkedin.com/in/ronnykwon" target=_blank mce_href="http://www.linkedin.com/in/ronnykwon"&gt;Ronny Kwon&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8848024" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/Implementation/default.aspx">Implementation</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/D2D/default.aspx">D2D</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/Tip/default.aspx">Tip</category></item><item><title>How-To : Silverlight accessing Java REST services (Part 2 – No Cross Domain : Tomcat/Eclipse)</title><link>http://blogs.msdn.com/silverlight_plus_java/archive/2008/08/06/how_2D00_to-silverlight-accessing-java-rest-services-part-2-no-cross-domain-tomcat.aspx</link><pubDate>Wed, 06 Aug 2008 11:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8791751</guid><dc:creator>Steve SFARTZ</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/silverlight_plus_java/comments/8791751.aspx</comments><wfw:commentRss>http://blogs.msdn.com/silverlight_plus_java/commentrss.aspx?PostID=8791751</wfw:commentRss><description>&lt;P mce_keep="true"&gt;The &lt;A href="http://blogs.msdn.com/silverlight_plus_java/archive/tags/How-to/default.aspx"&gt;HowTo&lt;/A&gt; serie demoes Silverlight accessing Web Services in various configuration. In this post, we will demonstrate a REST service consumed by a Silverlight client application where the Site of Origin hosts the Web Services. This scenario is categorized as a &lt;A href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/28/scenario-d2d-developer-env.aspx" mce_href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/28/scenario-d2d-developer-env.aspx"&gt;&lt;STRONG&gt;D2D scenario&lt;/STRONG&gt;&lt;/A&gt;&lt;STRONG&gt; &lt;EM&gt;without&lt;/EM&gt; cross-domain policy&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;EM&gt;The XAP package, the REST service Eclipse project and the Silverlight Eclipse project are available as an attachment to this post.&lt;/EM&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Technical Environment&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;REST services are built with the Restlet framework and hosted in Tomcat &lt;/LI&gt;
&lt;LI&gt;The Silverlight application is also hosted in Tomcat&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_2.png" mce_href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_2.png"&gt;&lt;IMG title=image style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=308 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_thumb.png" width=411 border=0 mce_src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_thumb.png"&gt;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because the Site Of Origin and the Web Services reside in the same host, no Cross Domain policy is required.&lt;/P&gt;
&lt;P&gt;To successfully install the technical environment, please take the following step :&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Build the scenario detailled in &lt;A href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/29/silverlight-plus-xml-rest-style-in-cross-domain-access.aspx" mce_href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/29/silverlight-plus-xml-rest-style-in-cross-domain-access.aspx"&gt;HowTo : Silverlight accessing Java REST services (Part 1 - Cross Domain : IIS + Tomcat)&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;If you don’t feel like doing the previous step, the XAP package available as an attachment contains a Silverlight client which is configured to access a REST service at http://localhost:8080/Restlet-servletfirstResource/items.&lt;/P&gt;
&lt;P&gt;The REST service is also available as an attachment to this post allows to do a GET and POST method to get a list of items or to insert a new one.&lt;/P&gt;
&lt;P&gt;Download the attachment and unzip it. There are two needed parts : the Silverlight XAP package and the Restlet Eclipse project.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_4.png" mce_href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_4.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Host the REST service with Tomcat&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Import the Reslet-servletfirstResource project into your Eclipse workspace : &lt;/LI&gt;
&lt;UL&gt;
&lt;LI&gt;go to File –&amp;gt; Import &lt;BR&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_6.png"&gt;&lt;IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=243 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_thumb_2.png" width=146 border=0&gt;&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Then chose General—&amp;gt;Existing Projects into Workspace &lt;BR&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_10.png"&gt;&lt;IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=270 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_thumb_4.png" width=231 border=0&gt;&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Select the root directory, Browse to the Restlet-servletfirstResource folder, then click on Finish. The Restlet-servletfirstResource has now been imported into your workspace &lt;BR&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_14.png"&gt;&lt;IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=268 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_thumb_6.png" width=229 border=0&gt;&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;LI&gt;Run the project on Tomcat Server. check that &lt;A title=http://localhost:8080/Restlet-servletfirstResource/items href="http://localhost:8080/Restlet-servletfirstResource/items"&gt;http://localhost:8080/Restlet-servletfirstResource/items&lt;/A&gt; is accessible you should get the following result : &lt;BR&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_16.png"&gt;&lt;IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=196 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_thumb_7.png" width=240 border=0&gt;&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Host the Silverlight application in an Eclipse project running on Tomcat&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Create a new Dynamic Web Project&lt;/LI&gt;
&lt;UL&gt;
&lt;LI&gt;Press Ctrl+n to go to the New Wizard Project, under Web select Dynamic Web Project. &lt;BR&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_18.png"&gt;&lt;IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=239 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_thumb_8.png" width=240 border=0&gt;&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;Call it REST-SilverlightClient and ensure that the Target Runtime is set to Apache Tomcat 6.0 &lt;BR&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_20.png"&gt;&lt;IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=240 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_thumb_9.png" width=205 border=0&gt;&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;If Eclipse prompts you to switch to J2EE perspective, accept it.&lt;/LI&gt;&lt;/UL&gt;
&lt;LI&gt;In the REST-SilverlightClient project, create the WebContent\ClientBin folder and copy the XAP package into it.&lt;/LI&gt;
&lt;LI&gt;Now we need to host it through an Active X control :&lt;/LI&gt;
&lt;UL&gt;
&lt;LI&gt;Right click on WebContent folder and select New—&amp;gt;JSP, call it index&lt;/LI&gt;
&lt;LI&gt;Edit index.jsp, in the Head part put the following script that catches Silverlight Error.&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt; &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text/javascript"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;     &lt;SPAN class=kwrd&gt;function&lt;/SPAN&gt; onSilverlightError(sender, args) {&lt;/PRE&gt;&lt;PRE class=alt&gt;     &lt;/PRE&gt;&lt;PRE&gt;         &lt;SPAN class=kwrd&gt;var&lt;/SPAN&gt; appSource = &lt;SPAN class=str&gt;""&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE class=alt&gt;         &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (sender != &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt; &amp;amp;&amp;amp; sender != 0) {&lt;/PRE&gt;&lt;PRE&gt;             appSource = sender.getHost().Source;&lt;/PRE&gt;&lt;PRE class=alt&gt;         } &lt;/PRE&gt;&lt;PRE&gt;         &lt;SPAN class=kwrd&gt;var&lt;/SPAN&gt; errorType = args.ErrorType;&lt;/PRE&gt;&lt;PRE class=alt&gt;         &lt;SPAN class=kwrd&gt;var&lt;/SPAN&gt; iErrorCode = args.ErrorCode;&lt;/PRE&gt;&lt;PRE&gt;         &lt;/PRE&gt;&lt;PRE class=alt&gt;         &lt;SPAN class=kwrd&gt;var&lt;/SPAN&gt; errMsg = &lt;SPAN class=str&gt;"Unhandled Error in Silverlight 2 Application "&lt;/SPAN&gt; +  appSource + &lt;SPAN class=str&gt;"\n"&lt;/SPAN&gt; ;&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=alt&gt;         errMsg += &lt;SPAN class=str&gt;"Code: "&lt;/SPAN&gt;+ iErrorCode + &lt;SPAN class=str&gt;"    \n"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;         errMsg += &lt;SPAN class=str&gt;"Category: "&lt;/SPAN&gt; + errorType + &lt;SPAN class=str&gt;"       \n"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE class=alt&gt;         errMsg += &lt;SPAN class=str&gt;"Message: "&lt;/SPAN&gt; + args.ErrorMessage + &lt;SPAN class=str&gt;"     \n"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=alt&gt;         &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (errorType == &lt;SPAN class=str&gt;"ParserError"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;PRE&gt;         {&lt;/PRE&gt;&lt;PRE class=alt&gt;             errMsg += &lt;SPAN class=str&gt;"File: "&lt;/SPAN&gt; + args.xamlFile + &lt;SPAN class=str&gt;"     \n"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;             errMsg += &lt;SPAN class=str&gt;"Line: "&lt;/SPAN&gt; + args.lineNumber + &lt;SPAN class=str&gt;"     \n"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE class=alt&gt;             errMsg += &lt;SPAN class=str&gt;"Position: "&lt;/SPAN&gt; + args.charPosition + &lt;SPAN class=str&gt;"     \n"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;         }&lt;/PRE&gt;&lt;PRE class=alt&gt;         &lt;SPAN class=kwrd&gt;else&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (errorType == &lt;SPAN class=str&gt;"RuntimeError"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;PRE&gt;         {           &lt;/PRE&gt;&lt;PRE class=alt&gt;             &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (args.lineNumber != 0)&lt;/PRE&gt;&lt;PRE&gt;             {&lt;/PRE&gt;&lt;PRE class=alt&gt;                 errMsg += &lt;SPAN class=str&gt;"Line: "&lt;/SPAN&gt; + args.lineNumber + &lt;SPAN class=str&gt;"     \n"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;                 errMsg += &lt;SPAN class=str&gt;"Position: "&lt;/SPAN&gt; +  args.charPosition + &lt;SPAN class=str&gt;"     \n"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE class=alt&gt;             }&lt;/PRE&gt;&lt;PRE&gt;             errMsg += &lt;SPAN class=str&gt;"MethodName: "&lt;/SPAN&gt; + args.methodName + &lt;SPAN class=str&gt;"     \n"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE class=alt&gt;         }&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=alt&gt;         &lt;SPAN class=kwrd&gt;throw&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Error(errMsg);&lt;/PRE&gt;&lt;PRE&gt;     }&lt;/PRE&gt;&lt;PRE class=alt&gt; &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;script&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;UL&gt;
&lt;LI&gt;In the Body part, instantiate a Silverlight control by adding the following HTML code, ensure that the param named “source” has is value set to the XAP package URI relative to index.jsp Web Page:&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;
&lt;DIV class=csharpcode&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;div&lt;/SPAN&gt; &lt;SPAN class=attr&gt;id&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="silverlightControlHost"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;object&lt;/SPAN&gt; &lt;SPAN class=attr&gt;data&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="data:application/x-silverlight,"&lt;/SPAN&gt; &lt;/PRE&gt;&lt;PRE class=alt&gt;            &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="application/x-silverlight-2-b2"&lt;/SPAN&gt; &lt;/PRE&gt;&lt;PRE&gt;            &lt;SPAN class=attr&gt;width&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="100%"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;height&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="100%"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;param&lt;/SPAN&gt;     &lt;SPAN class=attr&gt;name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="source"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;value&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="ClientBin/REST-JavaServiceItem.xap"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;        &lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;param&lt;/SPAN&gt;     &lt;SPAN class=attr&gt;name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="onerror"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;value&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="onSilverlightError"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;param&lt;/SPAN&gt;     &lt;SPAN class=attr&gt;name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="background"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;value&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="white"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;a&lt;/SPAN&gt;     &lt;SPAN class=attr&gt;href&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://go.microsoft.com/fwlink/?LinkID=115261"&lt;/SPAN&gt; &lt;/PRE&gt;&lt;PRE class=alt&gt;            &lt;SPAN class=attr&gt;style&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="text-decoration: none;"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;               &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;img&lt;/SPAN&gt; &lt;SPAN class=attr&gt;src&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://go.microsoft.com/fwlink/?LinkId=108181"&lt;/SPAN&gt; &lt;/PRE&gt;&lt;PRE class=alt&gt;                 &lt;SPAN class=attr&gt;alt&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Get Microsoft Silverlight"&lt;/SPAN&gt; &lt;/PRE&gt;&lt;PRE&gt;                 &lt;SPAN class=attr&gt;style&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="border-style: none"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;a&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;object&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;iframe&lt;/SPAN&gt; &lt;SPAN class=attr&gt;style&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;='visibility:hidden;height:0;width:0;border:0px'&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;iframe&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;div&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;
&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;UL&gt;
&lt;LI&gt;Run the project on Tomcat Server and the Silverlight control will appear in the Eclipse Web Browser : &lt;BR&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_22.png"&gt;&lt;IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=216 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaRESTservice_F1AE/image_thumb_10.png" width=240 border=0&gt;&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;The great thing about that is that you will be able to test your REST Service and the Silverlight application without running multiple Development Environments.&lt;/P&gt;
&lt;P&gt;- &lt;A class="" href="http://www.linkedin.com/in/ronnykwon" target=_blank mce_href="http://www.linkedin.com/in/ronnykwon"&gt;Ronny Kwon&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8791751" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/silverlight_plus_java/attachment/8791751.ashx" length="145518" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/XML_2F00_REST/default.aspx">XML/REST</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/Implementation/default.aspx">Implementation</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/How-to/default.aspx">How-to</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/D2D/default.aspx">D2D</category></item><item><title>How-To : Silverlight accessing Java SOAP services (Part 1 – Cross Domain : IIS + Tomcat)</title><link>http://blogs.msdn.com/silverlight_plus_java/archive/2008/08/04/how-to-silverlight-accessing-java-soap-services-part-1-cross-domain-iis-tomcat.aspx</link><pubDate>Mon, 04 Aug 2008 18:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8831283</guid><dc:creator>Steve SFARTZ</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/silverlight_plus_java/comments/8831283.aspx</comments><wfw:commentRss>http://blogs.msdn.com/silverlight_plus_java/commentrss.aspx?PostID=8831283</wfw:commentRss><description>&lt;P mce_keep="true"&gt;The How-To series demo Silverlight accessing Web Services in various configuration. In this post, we will demonstrate a SOAP service consumed by a Silverlight client application. This scenario can be categorized as a &lt;A class="" href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/28/scenario-d2d-developer-env.aspx" mce_href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/28/scenario-d2d-developer-env.aspx"&gt;D2D scenario&lt;/A&gt; with a cross domain policy.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Both the Silverlight and SOAP service are available as an attachment to this post. Since Metro libraries are too large, you will need to copy all jar files from metro\lib\ folder into WebContent\WEB-INF\lib project folder. Steps are described below&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Technical environment&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;SOAP services are built with JAX-WS and JAX-B APIs and hosted in Tomcat. &lt;/LI&gt;
&lt;LI&gt;The Silverlight application is hosted under the Visual Studio embedded Web Server code name “Catalina” (which delivers a subset of the IIS capabilities)&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_25.png"&gt;&lt;IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=417 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb.png" width=524 border=0&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Requirement &lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;For this How-To, we use the &lt;A href="https://metro.dev.java.net/discover/" target=_blank mce_href="https://metro.dev.java.net/discover/"&gt;Metro framework&lt;/A&gt; which contains both &lt;A href="https://jax-ws.dev.java.net/" target=_blank mce_href="https://jax-ws.dev.java.net/"&gt;JAX-WS&lt;/A&gt; and &lt;A href="https://jaxb.dev.java.net/introduction.html" target=_blank mce_href="https://jaxb.dev.java.net/introduction.html"&gt;JAX-B&lt;/A&gt; APIs which will be used to develop SOAP Services in JAVA. &lt;/P&gt;
&lt;P&gt;&lt;U&gt;Configuring Tomcat&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Download the jar file from &lt;A title=https://metro.dev.java.net/1.2/ href="https://metro.dev.java.net/1.2/" target=_blank mce_href="https://metro.dev.java.net/1.2/"&gt;https://metro.dev.java.net/1.2/&lt;/A&gt; and launch it. A “metro” folder has been created at the jar location. metro\lib folder contains all the needed libraries for the Java SOAP service development and Tomcat configuration. Here is a good link that describes how to configure your Tomcat server &lt;A class="" href="http://blogs.sun.com/arungupta/entry/metro_on_tomcat_6_x" target=_blank mce_href="http://blogs.sun.com/arungupta/entry/metro_on_tomcat_6_x"&gt;http://blogs.sun.com/arungupta/entry/metro_on_tomcat_6_x&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Implementing the SOAP / RPC service&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;In Eclipse, create a new Dynamic Web Project called “&lt;STRONG&gt;&lt;EM&gt;SOAP-SumService&lt;/EM&gt;&lt;/STRONG&gt;” &lt;/LI&gt;
&lt;LI&gt;copy all jar files from metro\lib\ folder into WebContent\WEB-INF\lib project folder. &lt;/LI&gt;
&lt;LI&gt;Create a package called “service” and add a new Java class called “&lt;EM&gt;&lt;STRONG&gt;ServiceSumImpl&lt;/STRONG&gt;&lt;/EM&gt;” to this package. &lt;/LI&gt;
&lt;LI&gt;Add a xml file to WebContent\WEB-INF called “sun-jaxws.xml”.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Your project structure now looks like this :&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_6.png" mce_href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_6.png"&gt;&lt;IMG title=image style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=343 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_2.png" width=232 border=0 mce_src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_2.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;U&gt;Implementation of the Web Service endpoint&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;In ServiceSumImpl.java, import the following libraries :&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_8.png" mce_href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_8.png"&gt;&lt;IMG title=image style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=37 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_3.png" width=266 border=0 mce_src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_3.png"&gt;&lt;/A&gt; &lt;/DIV&gt;
&lt;P&gt;Declare the class as a Web Service endpoint with the following annotations, for more informations about annotations refer to this &lt;A class="" href="http://edocs.bea.com/wls/docs91/webserv/annotations.html#1042436" target=_blank mce_href="http://edocs.bea.com/wls/docs91/webserv/annotations.html#1042436"&gt;site&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_10.png" mce_href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_10.png"&gt;&lt;IMG title=image style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=128 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_4.png" width=423 border=0 mce_src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_4.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;The only method that our service exposes is getSum. It returns the sum of two integers. But we want this method to be known over the service as “SumTwoInt”. Within the annotations we can configure all these parameters. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_12.png" mce_href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_12.png"&gt;&lt;IMG title=image style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=108 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_5.png" width=393 border=0 mce_src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_5.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Now build the project to generate the bytecode as the WSGen tool need it.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;U&gt;Generation of the required artifacts for the Web Service deployment and invocation&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;For this step, Metro provides a generation tool called “wsgen”.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Open a Windows Command Prompt : Start-&amp;gt;Run and type “cmd” &lt;/LI&gt;
&lt;LI&gt;set a METRO as a path variable to metro\bin folder (in our case it is C:\metro\bin path)&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_14.png" mce_href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_14.png"&gt;&lt;IMG title=image style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=54 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_6.png" width=240 border=0 mce_src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_6.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Go to your build project folder (by default in Eclipse: &lt;EM&gt;ProjectName\build\classes&lt;/EM&gt;). In our example it is the &lt;EM&gt;SOAP-SumService\build\classes&lt;/EM&gt; folder &lt;BR&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_16.png" mce_href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_16.png"&gt;&lt;IMG title=image style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=18 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_7.png" width=555 border=0 mce_src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_7.png"&gt;&lt;/A&gt;&amp;nbsp; &lt;BR&gt;&lt;BR&gt;Type the following command line to generates the artifacts in the project “src” folder. &lt;BR&gt;&lt;BR&gt;&lt;EM&gt;%METRO%\wsgen –cp . service.ServiceSumImpl –s ../../src&lt;/EM&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Refresh the Project Explorer and observes that two java files have been generated&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_18.png" mce_href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_18.png"&gt;&lt;IMG title=image height=286 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_8.png" width=340 border=0 mce_src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_8.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;They represent the message that will be shared in the Web Service process&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Configuring the Web Service Deployment&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;To configure the deployment, we need to instantiate a Servlet that will handles JAX-WS Web Services requests.&lt;/P&gt;
&lt;P&gt;In web.xml, add a Servlet element. We use a pre-existing Web Service Servlet :&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;servlet&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;servlet-name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;jaxservlet&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;servlet-name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;servlet-class&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;        com.sun.xml.ws.transport.http.servlet.WSServlet&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;servlet-class&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;load-on-startup&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;1&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;load-on-startup&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;servlet&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;This servlet will handle every requests on /services/* URI, so let’s map to it with its name:&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;servlet-mapping&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;servlet-name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;jaxservlet&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;servlet-name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;url-pattern&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;/services/*&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;url-pattern&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;servlet-mapping&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;To provide the right context, we need a listener (which also already exists):&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;listener&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;listener-class&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;        com.sun.xml.ws.transport.http.servlet.WSServletContextListener&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;listener-class&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;listener&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;Finally, we need to expose the endpoint ServiceSumImpl within an URI, for example /services/sum. &lt;/P&gt;
&lt;P&gt;Edit the sun-jaxws.xml file and add the following elements :&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;&amp;lt;?&lt;/SPAN&gt;&lt;SPAN class=html&gt;xml&lt;/SPAN&gt; &lt;SPAN class=attr&gt;version&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="1.0"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;encoding&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="UTF-8"&lt;/SPAN&gt;?&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;endpoints&lt;/SPAN&gt; &lt;SPAN class=attr&gt;xmlns&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://java.sun.com/xml/ns/jax-ws/ri/runtime"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;version&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="2.0"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;endpoint&lt;/SPAN&gt; &lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=attr&gt;name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="sum"&lt;/SPAN&gt; &lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=attr&gt;implementation&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="service.ServiceSumImpl"&lt;/SPAN&gt; &lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=attr&gt;url-pattern&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="/services/sum"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;endpoints&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;UL&gt;
&lt;LI&gt;Save all files, then Run the project on the Tomcat Server &lt;BR&gt;Right click on the project node : Run As –&amp;gt; Run on Server&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;The service is now hosted on Tomcat at &lt;A title=http://localhost:8080/SOAP-SumService/services/sum?wsdl href="http://localhost:8080/SOAP-SumService/services/sum?wsdl" mce_href="http://localhost:8080/SOAP-SumService/services/sum?wsdl"&gt;http://localhost:8080/SOAP-SumService/services/sum?wsdl&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_22.png" mce_href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_22.png"&gt;&lt;IMG title=image style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=267 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_10.png" width=378 border=0 mce_src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_10.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Enabling Cross Domain Access&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since the SOAP service and the Silverlight application reside on different hosts, we need to overpass the &lt;A href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/31/Cross-Domain-_3A00_-Trouble-while-accessing-Web-Services.aspx" mce_href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/31/Cross-Domain-_3A00_-Trouble-while-accessing-Web-Services.aspx"&gt;Cross Domain Issue&lt;/A&gt;. Create at the root of the SOAP service host, a clientaccesspolicy.xml file with the following content :&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;&amp;lt;?&lt;/SPAN&gt;&lt;SPAN class=html&gt;xml&lt;/SPAN&gt; &lt;SPAN class=attr&gt;version&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="1.0"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;encoding&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="UTF-8"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;standalone&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="no"&lt;/SPAN&gt;?&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;access-policy&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;cross-domain-access&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;policy&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;            &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;allow-from&lt;/SPAN&gt; &lt;SPAN class=attr&gt;http-request-headers&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="*"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;                &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;domain&lt;/SPAN&gt; &lt;SPAN class=attr&gt;uri&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="*"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;            &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;allow-from&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;            &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;grant-to&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;                &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;resource&lt;/SPAN&gt; &lt;SPAN class=attr&gt;include-subpaths&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="true"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;path&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="/"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;            &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;grant-to&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;policy&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;cross-domain-access&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;access-policy&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Consuming a SOAP service with Silverlight&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Now that the Web Service is exposed, we are going to generate the client proxy to consume the Web Service with Silverlight.&lt;/P&gt;
&lt;P&gt;Open Visual Studio 2008 and create a new Silverlight Project called SOAP-Sum and paste the following XAML code in Page.xaml to obtain a simple interface that will manipulate the web service.&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;UserControl&lt;/SPAN&gt; &lt;SPAN class=attr&gt;x:Class&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="SOAP_Sum.Page"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=attr&gt;xmlns&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/SPAN&gt; &lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=attr&gt;xmlns:x&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/SPAN&gt; &lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=attr&gt;Width&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="400"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Height&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="300"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;Canvas&lt;/SPAN&gt; &lt;SPAN class=attr&gt;x:Name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="LayoutRoot"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Background&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="White"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;TextBox&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Text&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="0"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;x:Name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="_int1"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Width&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="50"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Height&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="20"&lt;/SPAN&gt; &lt;/PRE&gt;&lt;PRE class=alt&gt;                          &lt;SPAN class=attr&gt;Canvas&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;Top&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="10"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Canvas&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;Left&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="30"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;TextChanged&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="_TextChanged"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;TextBlock&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Canvas&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;Top&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="10"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Canvas&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;Left&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="95"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Text&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="+"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;TextBox&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Text&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="0"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;x:Name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="_int2"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Width&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="50"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Height&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="20"&lt;/SPAN&gt; &lt;/PRE&gt;&lt;PRE&gt;                          &lt;SPAN class=attr&gt;Canvas&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;Top&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="10"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Canvas&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;Left&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="120"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;TextChanged&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="_TextChanged"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;TextBlock&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Canvas&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;Top&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="10"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Canvas&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;Left&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="175"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Text&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="="&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;TextBlock&lt;/SPAN&gt; &lt;SPAN class=attr&gt;x:Name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="_result"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Canvas&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;Top&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="10"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Canvas&lt;/SPAN&gt;.&lt;SPAN class=attr&gt;Left&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="190"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Text&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;=""&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;Canvas&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;UserControl&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;UL&gt;
&lt;LI&gt;Add a Service Reference &lt;BR&gt;Right click on References then chose Add a Service Reference&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_24.png" mce_href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_24.png"&gt;&lt;IMG title=image style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=67 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_11.png" width=240 border=0 mce_src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_11.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;In Address field, type the Sum service address then click Go (it should be &lt;A title=http://localhost:8080/SOAP-SumService/services/sum?wsdl href="http://localhost:8080/SOAP-SumService/services/sum?wsdl" mce_href="http://localhost:8080/SOAP-SumService/services/sum?wsdl"&gt;http://localhost:8080/SOAP-SumService/services/sum?wsdl&lt;/A&gt;). &lt;BR&gt;&lt;BR&gt;We actually have the Sum service named ServiceSum and one operation exposed as SumTwoInt, this is exactly what we did parameter in “Implementation of the Web Service endpoint” (see above)&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_28.png" mce_href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_28.png"&gt;&lt;IMG title=image style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=200 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_13.png" width=240 border=0 mce_src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_13.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;In Namespace field, type ServiceSum : this is how the service will be accessible through the Silverlight project. Click OK. In the Solution Explorer you see the ServiceSum reference in Service References.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_32.png" mce_href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_32.png"&gt;&lt;IMG title=image style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=34 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_15.png" width=149 border=0 mce_src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/HowToSilverlightaccessingJavaSOAPservice_E0EA/image_thumb_15.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;U&gt;Implementation of the client proxy&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;In Page.xaml.cs, add an import to SOAP-Sum.ServiceSum reference library.&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   1:  &lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; SOAP_Sum.ServiceSum;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;Now we need to handle the TextChanged event in _TextChanged method :&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Instantiate a client proxy 
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;ServiceSumClient client = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; ServiceSumClient();&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;
&lt;/LI&gt;
&lt;LI&gt;Add an event handler corresponding to the operation we are going to use so we can get the result 
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;client.SumTwoIntCompleted += &lt;/PRE&gt;&lt;PRE&gt;   &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; EventHandler&amp;lt;SumTwoIntCompletedEventArgs&amp;gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;      (&lt;/PRE&gt;&lt;PRE&gt;         client_SumTwoIntCompleted&lt;/PRE&gt;&lt;PRE class=alt&gt;      );&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;
&lt;/LI&gt;
&lt;LI&gt;Use Async operation to send our two integers. &lt;BR&gt;Operations are made asynchronous so Silverlight UI won’t freeze 
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;client.SumTwoIntAsync(a,b);&lt;/PRE&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;The whole method looks like this :&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   1:  &lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; _TextChanged(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; sender, TextChangedEventArgs e)&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   2:  &lt;/SPAN&gt;{&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   3:  &lt;/SPAN&gt;    &lt;SPAN class=rem&gt;// check if fields contain some text&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   4:  &lt;/SPAN&gt;    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (_int1.Text == &lt;SPAN class=str&gt;""&lt;/SPAN&gt; || _int2.Text == &lt;SPAN class=str&gt;""&lt;/SPAN&gt;) &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   5:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   6:  &lt;/SPAN&gt;    &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; a = &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt;.Parse(_int1.Text);&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   7:  &lt;/SPAN&gt;    &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; b = &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt;.Parse(_int2.Text);&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   8:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   9:  &lt;/SPAN&gt;    &lt;SPAN class=rem&gt;// generate a client proxy to the Web Service&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  10:  &lt;/SPAN&gt;    ServiceSumClient client = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; ServiceSumClient();&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  11:  &lt;/SPAN&gt;    client.SumTwoIntCompleted += &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; EventHandler&amp;lt;SumTwoIntCompletedEventArgs&amp;gt;(client_SumTwoIntCompleted);&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  12:  &lt;/SPAN&gt;    client.SumTwoIntAsync(a,b);&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  13:  &lt;/SPAN&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;Then we can process the result in the event handler&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; client_SumTwoIntCompleted(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; sender, SumTwoIntCompletedEventArgs e)&lt;/PRE&gt;&lt;PRE&gt;{&lt;/PRE&gt;&lt;PRE class=alt&gt;    _result.Text = e.Result.ToString();&lt;/PRE&gt;&lt;PRE&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P mce_keep="true"&gt;Run the project and type some integers in the text boxes : Silverlight is consuming a JAX-WS SOAP service.&lt;/P&gt;
&lt;P&gt;- &lt;A class="" href="http://www.linkedin.com/in/ronnykwon" target=_blank mce_href="http://www.linkedin.com/in/ronnykwon"&gt;Ronny Kwon&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8831283" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/silverlight_plus_java/attachment/8831283.ashx" length="589450" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/SOAP_2F00_RPC/default.aspx">SOAP/RPC</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/Implementation/default.aspx">Implementation</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/How-to/default.aspx">How-to</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/Cross+Domain/default.aspx">Cross Domain</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/D2D/default.aspx">D2D</category></item><item><title>How-To : Silverlight accessing Java REST services (Part 1 - Cross Domain : IIS + Tomcat)</title><link>http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/30/How_2D00_To-_3A00_-Silverlight-accessing-Java-REST-services-_2800_Part-1-_2D00_-Cross-Domain-_3A00_-IIS-_2B00_-Tomcat_2900_.aspx</link><pubDate>Wed, 30 Jul 2008 15:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8789161</guid><dc:creator>Steve SFARTZ</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/silverlight_plus_java/comments/8789161.aspx</comments><wfw:commentRss>http://blogs.msdn.com/silverlight_plus_java/commentrss.aspx?PostID=8789161</wfw:commentRss><description>&lt;P mce_keep="true"&gt;The &lt;A class="" href="http://www.linkedin.com/in/ronnykwon" target=_blank mce_href="http://www.linkedin.com/in/ronnykwon"&gt;HowTo&lt;/A&gt; serie demoes Silverlight accessing Web Services in various configurations. In this post, we will demonstrate a REST service consumed by HTTP GET and POST requests issued from a Silverlight client application. This scenario can be categorized as a &lt;A href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/28/scenario-d2d-developer-env.aspx" mce_href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/28/scenario-d2d-developer-env.aspx"&gt;D2D scenario&lt;/A&gt; with a cross domain policy. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;EM&gt;The Silverlight example described below is available as an attachment to this post.&lt;/EM&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Technical environment&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;REST services are built with Restlet and hosted in Tomcat&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV mce_keep="true"&gt;The Silverlight application is hosted under the Visual Studio embedded Web Server code name "Catalina" (which delivers a subset of the IIS capabilities)&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/MixJavaand.NETEnvironment_DFA6/image_2.png"&gt;&lt;IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=387 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/MixJavaand.NETEnvironment_DFA6/image_thumb.png" width=505 border=0&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Because the Site of Origin and the Web Services reside in different hosts, a Cross Domain policy is required at the Services host’s root (/clientaccesspolicy.xml"&amp;gt;http://&amp;lt;serviceshostname:port&amp;gt;/clientaccesspolicy.xml)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Implementation of the REST service&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;To get an overview of the Restlet framework, complete the tutorials : &lt;A class="" href="http://www.restlet.org/documentation/1.0/firstSteps" target=_blank mce_href="http://www.restlet.org/documentation/1.0/firstSteps "&gt;First Steps&lt;/A&gt; and &lt;A class="" href="http://www.restlet.org/documentation/1.0/firstResource" target=_blank mce_href="http://www.restlet.org/documentation/1.0/firstResource"&gt;First Resource&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Service development with Restlet can be summarized as follow : &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The Application class is the entry point to the Restlet service. It&amp;nbsp; binds a URI to a specific Resource. &lt;/LI&gt;
&lt;LI&gt;The Resource class describes how the service behaves on a specific URI invokation. &lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;After completing the tutorials above, deploy the firstResource service as a &lt;A class="" href="http://www.restlet.org/documentation/1.0/firstSteps#part03" target=_blank mce_href="http://www.restlet.org/documentation/1.0/firstSteps#part03"&gt;Servlet hosted by Tomcat&lt;/A&gt;.&lt;/P&gt;
&lt;P mce_keep="true"&gt;Invoke the Restlet service with the URI &lt;A href="http://localhost:8080/Restlet-servletfirstResource/items"&gt;http://localhost:8080/Restlet-servletfirstResource/items&lt;/A&gt;. Assuming that Tomcat is running on port 8080 and that your Restlet project name is Restlet-servletfirstResource, you get the following response :&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;  &lt;FONT color=#000000&gt;&lt;SPAN class=kwrd&gt;&amp;lt;?&lt;/SPAN&gt;&lt;SPAN class=html&gt;xml&lt;/SPAN&gt; &lt;SPAN class=attr&gt;version&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="1.0"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;encoding&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="UTF-8"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;standalone&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="no"&lt;/SPAN&gt; ?&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt; &lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE&gt;  &lt;FONT color=#000000&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;items&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;     &lt;FONT color=#000000&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;item&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE&gt;        &lt;FONT color=#000000&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;item1&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt; &lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;FONT color=#000000&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;description&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;description of item1&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;description&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt; &lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE&gt;     &lt;FONT color=#000000&gt;&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;item&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;   &lt;FONT color=#000000&gt;&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;items&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Enabling Cross Domain Access&lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Since the REST service and the Silverlight application are hosted in different hosts, we need to overpass the &lt;A href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/31/Cross-Domain-_3A00_-Trouble-while-accessing-Web-Services.aspx" target=_blank&gt;Cross Domain Issue&lt;/A&gt;. Create at the root of the REST service host, a clientaccesspolicy.xml file with the following content :&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;&amp;lt;?&lt;/SPAN&gt;&lt;SPAN class=html&gt;xml&lt;/SPAN&gt; &lt;SPAN class=attr&gt;version&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="1.0"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;encoding&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="UTF-8"&lt;/SPAN&gt;?&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;access-policy&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;cross-domain-access&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;policy&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;            &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;allow-from&lt;/SPAN&gt; &lt;SPAN class=attr&gt;http-request-headers&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="*"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;                &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;domain&lt;/SPAN&gt; &lt;SPAN class=attr&gt;uri&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="*"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;            &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;allow-from&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;            &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;grant-to&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;                &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;resource&lt;/SPAN&gt; &lt;SPAN class=attr&gt;include-subpaths&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="true"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;path&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="/"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;            &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;grant-to&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;policy&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;cross-domain-access&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;access-policy&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Consuming a REST service with Silverlight (GET method)&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We chose the WebClient API to request the REST service, and LINQ to process the XML response. &lt;A class="" href="http://msdn.microsoft.com/en-us/library/cc188996(VS.95).aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/cc188996(VS.95).aspx"&gt;XmlReader&lt;/A&gt; is another parsing option, and &lt;A class="" href="http://www.linkedin.com/in/ronnykwon" target=_blank mce_href="http://www.linkedin.com/in/ronnykwon"&gt;Serialization&lt;/A&gt; (Xml or DataContract) is another one.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Invocation of the REST service&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;First of all, in your UserControl, declare a MyItem class that will map the XML response elements.&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   1:  &lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; MyItem&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   2:  &lt;/SPAN&gt;{&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   3:  &lt;/SPAN&gt;    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; myName { get; set; }&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   4:  &lt;/SPAN&gt;    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; myDescription { get; set; }&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   5:  &lt;/SPAN&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;DIV class=csharpcode&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   1:  &lt;/SPAN&gt;&lt;SPAN class=rem&gt;// List of Items&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   2:  &lt;/SPAN&gt;IEnumerable&amp;lt;MyItem&amp;gt; Items = &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;Now, let's send a HTTP GET method request to /items URI so we can retrieve every items&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   1:  &lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; getAction()&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   2:  &lt;/SPAN&gt;{&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   3:  &lt;/SPAN&gt;    WebClient webclient = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; WebClient();&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   4:  &lt;/SPAN&gt;    webclient.DownloadStringCompleted += &lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   5:  &lt;/SPAN&gt;      &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; DownloadStringCompletedEventHandler(client_DownloadStringCompleted);&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   6:  &lt;/SPAN&gt;    webclient.DownloadStringAsync(&lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Uri(&lt;SPAN class=str&gt;"http://localhost:8080/Restlet-servletfirstResource/items"&lt;/SPAN&gt;));&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   7:  &lt;/SPAN&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P mce_keep="true"&gt;&lt;U&gt;Processing the XML results&lt;/U&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Let’s process the results using LINQ support for XML :&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   1:  &lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; client_DownloadStringCompleted(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; sender, DownloadStringCompletedEventArgs e)&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   2:  &lt;/SPAN&gt;{&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   3:  &lt;/SPAN&gt;    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (e.Error == &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   4:  &lt;/SPAN&gt;    {&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   5:  &lt;/SPAN&gt;        XDocument xmlItems = XDocument.Parse(e.Result);&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   6:  &lt;/SPAN&gt;        &lt;SPAN class=rem&gt;// use LINQ to XML to parse the response&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   7:  &lt;/SPAN&gt;        Items = from child &lt;SPAN class=kwrd&gt;in&lt;/SPAN&gt; xmlItems.Element(&lt;SPAN class=str&gt;"items"&lt;/SPAN&gt;).Descendants().ToList()&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   8:  &lt;/SPAN&gt;                &lt;SPAN class=rem&gt;// restrict the selection to item children&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   9:  &lt;/SPAN&gt;                &lt;SPAN class=kwrd&gt;where&lt;/SPAN&gt; child.Name.LocalName==&lt;SPAN class=str&gt;"item"&lt;/SPAN&gt;    &lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  10:  &lt;/SPAN&gt;                select &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; MyItem&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  11:  &lt;/SPAN&gt;                    {&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  12:  &lt;/SPAN&gt;                        myName = (&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;)child.Element(&lt;SPAN class=str&gt;"name"&lt;/SPAN&gt;),&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  13:  &lt;/SPAN&gt;                        myDescription = (&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;) child.Element(&lt;SPAN class=str&gt;"description"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  14:  &lt;/SPAN&gt;                    };&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  15:  &lt;/SPAN&gt;    } &lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  16:  &lt;/SPAN&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;&lt;STRONG&gt;Sending Data to a REST service with Silverlight&amp;nbsp; (POST method)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Use the WebClient to send a HTTP POST request to the /items URI, by adding two parameters : name = "Foo"&amp;nbsp; and description = "Bar" :&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   1:  &lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; postWebClient()&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   2:  &lt;/SPAN&gt;{&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   3:  &lt;/SPAN&gt;    WebClient webclient = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; WebClient();&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   4:  &lt;/SPAN&gt;    webclient.UploadStringAsync(&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   7:  &lt;/SPAN&gt;      &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Uri(&lt;SPAN class=str&gt;"http://localhost:8080/Restlet-servletfirstResource/items"&lt;/SPAN&gt;),&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   8:  &lt;/SPAN&gt;      &lt;SPAN class=str&gt;"name=Foo&amp;amp;description=Bar"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   9:  &lt;/SPAN&gt;    );&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  10:  &lt;/SPAN&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Warning : Notice that if you try to hit the same URI several time with the HTTP GET method, the results do not get refreshed but remain the same. Further explanations about this &lt;/EM&gt;&lt;A class="" href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/30/Limitations-when-accessing-REST-services-from-Silverlight.aspx#CacheIssue" mce_href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/30/Limitations-when-accessing-REST-services-from-Silverlight.aspx#CacheIssue"&gt;&lt;EM&gt;caching issue&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt; are available here.&lt;/EM&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- &lt;A class="" href="http://www.linkedin.com/in/ronnykwon" target=_blank mce_href="http://www.linkedin.com/in/ronnykwon"&gt;Ronny Kwon&lt;/A&gt; &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8789161" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/silverlight_plus_java/attachment/8789161.ashx" length="822159" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/XML_2F00_REST/default.aspx">XML/REST</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/Implementation/default.aspx">Implementation</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/How-to/default.aspx">How-to</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/Cross+Domain/default.aspx">Cross Domain</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/D2D/default.aspx">D2D</category></item><item><title>D2D scenario : Developer Environment</title><link>http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/28/scenario-d2d-developer-env.aspx</link><pubDate>Mon, 28 Jul 2008 17:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8784339</guid><dc:creator>Steve SFARTZ</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/silverlight_plus_java/comments/8784339.aspx</comments><wfw:commentRss>http://blogs.msdn.com/silverlight_plus_java/commentrss.aspx?PostID=8784339</wfw:commentRss><description>&lt;p&gt;This scenario is typically used in development phase when &lt;strong&gt;you are building a Silverlight rich client that connects to new business Logic&lt;/strong&gt;. It is mandatory that the business logic is new to ensure you have enough control to enforce a configuration where the Site Of Origin and the Services Host reside on the same node. If you face a configuration where you need to interface with Business Logic exposed by existing Web Services from a distinct node or requiring protocol adaptation, turn to the B2E scenario.&lt;/p&gt;  &lt;p&gt;As listed in &lt;a id="bp___v___r___postlist___EntryItems_ctl02_PostTitle" href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/28/silverlight-scenarios-for-rich-internet-applications.aspx"&gt;&lt;font color="#176db5"&gt;Silverlight scenarios for Rich Internet Applications&lt;/font&gt;&lt;/a&gt;, the following constraints apply to the Developer Environment scenario :&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;No infrastructure security constraints since this is a dev/test env (No HTTPS, no DMZ) &lt;/li&gt;    &lt;li&gt;No protocol adaptation is necessary as we develop brand new services here (ie, messages format &amp;amp; exchange protocol correspond to the Silverlight client capabilities, they can be directly consumed) &lt;/li&gt;    &lt;li&gt;Authentication &amp;amp; authorization may need to be handled if required at production/deployment time : this point is covered in the B2E scenario. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;A cross domain security file is needed if the Site Of Origin does not host the Web Services&lt;/strong&gt;, as in interoperability scenarios where the Site of Origin and the Web Services rely on two different technologies.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/D2DScenarioDeveloperEnvironment_FA7C/image_2.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="191" alt="image" src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/D2DScenarioDeveloperEnvironment_FA7C/image_thumb.png" width="255" border="0" /&gt;&lt;/a&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;a href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/D2DScenarioDeveloperEnvironment_FA7C/image_6.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="194" alt="image" src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/D2DScenarioDeveloperEnvironment_FA7C/image_thumb_1.png" width="254" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/ScenarioD2DDeveloperEnv_E51C/image_2.png" mce_href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/ScenarioD2DDeveloperEnv_E51C/image_2.png"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;We plan to experiment the following configurations :&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;u&gt;SOAP/ RPC style (operation oriented)&lt;/u&gt;       &lt;ol&gt;       &lt;li&gt;Mixed configuration : IIS for Site of Origin + Tomcat and JAVA-WS for Web Services          &lt;ul&gt;           &lt;li&gt;with a cross-domain policy &lt;/li&gt;            &lt;li&gt;or by servicing Web services request from IIS through the &lt;a class="" href="http://tomcat.apache.org/connectors-doc/webserver_howto/iis.html" target="_blank" mce_href="http://tomcat.apache.org/connectors-doc/webserver_howto/iis.html"&gt;Tomcat connector for IIS&lt;/a&gt;&lt;/li&gt;         &lt;/ul&gt;       &lt;/li&gt;        &lt;li&gt;Full Java configuration : Tomcat for Site of Origin + JAVA-WS for Web Services &lt;/li&gt;        &lt;li&gt;Full Windows configuration : IIS for Site or Origin + WCF services (SOAP style) for Web Services          &lt;ul&gt;           &lt;li&gt;with a cross-domain policy &lt;/li&gt;            &lt;li&gt;or with the IIS built-in integration of WCF services through SVC resources&lt;/li&gt;         &lt;/ul&gt;       &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt;    &lt;li&gt;&lt;u&gt;XML/ REST style (resource oriented)&lt;/u&gt;       &lt;ol&gt;       &lt;li&gt;Mixed configuration : IIS for Site of Origin + Tomcat and the Restlet framework for Web Services          &lt;ul&gt;           &lt;li&gt;with a cross-domain policy &lt;/li&gt;            &lt;li&gt;or by servicing Web services request from IIS through the &lt;a class="" href="http://tomcat.apache.org/connectors-doc/webserver_howto/iis.html" target="_blank" mce_href="http://tomcat.apache.org/connectors-doc/webserver_howto/iis.html"&gt;Tomcat connector for IIS&lt;/a&gt;&lt;/li&gt;         &lt;/ul&gt;       &lt;/li&gt;        &lt;li&gt;Full Java configuration : Tomcat for Site of Origin + Restlet for Web Services &lt;/li&gt;        &lt;li&gt;Full Windows configuration : IIS for Site of Origin + WCF services (REST style) for Web Services&lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt; &lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8784339" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/XML_2F00_REST/default.aspx">XML/REST</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/SOAP_2F00_RPC/default.aspx">SOAP/RPC</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/Implementation/default.aspx">Implementation</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/D2D/default.aspx">D2D</category></item><item><title>Silverlight scenarios for Rich Internet Applications</title><link>http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/28/silverlight-scenarios-for-rich-internet-applications.aspx</link><pubDate>Mon, 28 Jul 2008 15:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8784089</guid><dc:creator>Steve SFARTZ</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/silverlight_plus_java/comments/8784089.aspx</comments><wfw:commentRss>http://blogs.msdn.com/silverlight_plus_java/commentrss.aspx?PostID=8784089</wfw:commentRss><description>&lt;P&gt;From the architecture described in the previous post &lt;A href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/28/a-cup-of-silverlight-a-drop-of-architecture.aspx" mce_href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/28/a-cup-of-silverlight-a-drop-of-architecture.aspx"&gt;a cup of Silverlight, a drop of Architecture&lt;/A&gt;, you may experience several technical requirements : &lt;/P&gt;
&lt;UL dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;LI&gt;&lt;STRONG&gt;Infrastructure Security&lt;/STRONG&gt; 
&lt;UL&gt;
&lt;LI&gt;DMZ (if the application is internet facing), &lt;/LI&gt;
&lt;LI&gt;Secured transport (HTTPS) if private communication has to be enforced (Mandatory in B2B and B2C environments)&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Application Security&lt;/STRONG&gt; 
&lt;UL&gt;
&lt;LI&gt;Authentication may be Form, Windows or Claim based depending on the consumer (employees, subcontractors, partners or customers) &lt;/LI&gt;
&lt;LI&gt;Authorization may be role based from various repositories (Active Directory, Claims, SQL Database)&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Application Topology&lt;/STRONG&gt; 
&lt;UL&gt;
&lt;LI&gt;The consumed Web Services are likely to be hosted on a distinct node in case of re-use or interop scenario. &lt;/LI&gt;
&lt;LI&gt;In new project development scenario, the Site of Origin may also host the Web Services.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Services Gateway and Protocols Adaptation&lt;/STRONG&gt; 
&lt;UL&gt;
&lt;LI&gt;The consumed Web Services may not be directly accessible due to security topology (ie, requires some kind of Gateway, Reverse Proxy) &lt;/LI&gt;
&lt;LI&gt;In case of Web Services re-use, they are likely to be exposed through protocols and/or formats incompatible with the Silverlight WCF client capabilities (ie, requires some kind of Mediation, Adaptation)&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;To comply with these Real World variants, we propose to categorize Silverlight Rich Client Applications into scenarios that you 'll may mix to conform to your requirements.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/SilverlightscenariosforRichInternetAppli_8D49/image_4.png"&gt;&lt;IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=465 alt=image src="http://blogs.msdn.com/blogfiles/silverlight_plus_java/WindowsLiveWriter/SilverlightscenariosforRichInternetAppli_8D49/image_thumb_1.png" width=572 border=0&gt;&lt;/A&gt; &lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;A class="" href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/28/scenario-d2d-developer-env.aspx" mce_href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/28/scenario-d2d-developer-env.aspx"&gt;&lt;STRONG&gt;D2D&lt;/STRONG&gt; (Developer To Developer) - Development Env&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;A class="" href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/31/b2e-scenario-intranet-environment.aspx" mce_href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/31/b2e-scenario-intranet-environment.aspx"&gt;&lt;STRONG&gt;B2E &lt;/STRONG&gt;(Business To Employee) - Silverlight App on an Intranet&lt;/A&gt;, eventually consuming pre-existing Web Services&lt;/P&gt;
&lt;P&gt;&lt;A class="" href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/31/b2b-scenario-partner-env.aspx" mce_href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/31/b2b-scenario-partner-env.aspx"&gt;&lt;STRONG&gt;B2B&lt;/STRONG&gt; (Business to Business) - Silverlight App delivered to partners&lt;/A&gt;, consuming pre-existing Web Services with federated security enforcement&lt;/P&gt;
&lt;P&gt;&lt;A class="" href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/31/b2b-scenario-partner-env.aspx" mce_href="http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/31/b2b-scenario-partner-env.aspx"&gt;&lt;STRONG&gt;B2C &lt;/STRONG&gt;(Business to Consumer) - Silverlight App delivered to customers&lt;/A&gt;, eventually consuming pre-existing Web Services with form based security enforcement &lt;/P&gt;
&lt;P&gt;In future posts, we discuss the architecture and an implementation sample with interoperability in mind.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8784089" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/XML_2F00_REST/default.aspx">XML/REST</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/SOAP_2F00_RPC/default.aspx">SOAP/RPC</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/Architecture/default.aspx">Architecture</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/D2D/default.aspx">D2D</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/B2B/default.aspx">B2B</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/B2E/default.aspx">B2E</category><category domain="http://blogs.msdn.com/silverlight_plus_java/archive/tags/B2C/default.aspx">B2C</category></item></channel></rss>