<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.alexthissen.nl/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>Alex Thissen Weblog Build 1.15.10.1971 : Web Services</title><link>http://www.alexthissen.nl/blogs/main/archive/tags/Web+Services/default.aspx</link><description>Tags: Web Services</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><item><title>Workaround for missing "Edit WCF Configuration" menu option in Visual Studio</title><link>http://www.alexthissen.nl/blogs/main/archive/2008/08/28/workaround-for-missing-quot-edit-wcf-configuration-quot-menu-option.aspx</link><pubDate>Thu, 28 Aug 2008 09:48:00 GMT</pubDate><guid isPermaLink="false">badf6229-ffeb-484a-8c5a-fc9c9987c8f2:2933</guid><dc:creator>Alex Thissen</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.alexthissen.nl/blogs/main/rsscomments.aspx?PostID=2933</wfw:commentRss><comments>http://www.alexthissen.nl/blogs/main/archive/2008/08/28/workaround-for-missing-quot-edit-wcf-configuration-quot-menu-option.aspx#comments</comments><description>&lt;p&gt;Sometimes when you have a clean install of Visual Studio 2005 or 2008 the context menu item &amp;quot;Edit WCF Configuration&amp;quot; for a app.config or web.config will not show.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.alexthissen.nl/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/main/EditWcfConfiguration_5F00_2.png"&gt;&lt;img border="0" width="264" src="http://www.alexthissen.nl/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/main/EditWcfConfiguration_5F00_thumb.png" alt="EditWcfConfiguration" height="300" style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The picture above &lt;span style="text-decoration:underline;"&gt;does&lt;/span&gt; show the menu item I&amp;#39;m talking about, but you may find that it is not there.&lt;/p&gt;
&lt;p&gt;Help is at hand: there is an easy workaround. Simply open up the Tools menu in Visual Studio and choose &amp;quot;Wcf Service Configuration Editor&amp;quot;. This will start the exact same tool, but doesn&amp;#39;t open your web/app.config. Close the tool straight away and right-click you config file. The &amp;quot;Edit WCF Configuration&amp;quot; context menu should be there now.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know exactly when the context menu goes missing, but I found that it occurs regularly for Virtual PC images. It might be totally unrelated to that though. The workaround works in all cases I encountered so far.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.alexthissen.nl/aggbug.aspx?PostID=2933" width="1" height="1"&gt;</description><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/Web+Services/default.aspx">Web Services</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/Visual+Studio+2005/default.aspx">Visual Studio 2005</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/.NET+FX+3.0/default.aspx">.NET FX 3.0</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/.NET+FX+3.5/default.aspx">.NET FX 3.5</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category></item><item><title>Combining AJAX and WCF 2.0</title><link>http://www.alexthissen.nl/blogs/main/archive/2008/03/22/combining-ajax-and-wcf-2-0.aspx</link><pubDate>Fri, 21 Mar 2008 20:36:47 GMT</pubDate><guid isPermaLink="false">badf6229-ffeb-484a-8c5a-fc9c9987c8f2:2881</guid><dc:creator>Alex Thissen</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.alexthissen.nl/blogs/main/rsscomments.aspx?PostID=2881</wfw:commentRss><comments>http://www.alexthissen.nl/blogs/main/archive/2008/03/22/combining-ajax-and-wcf-2-0.aspx#comments</comments><description>&lt;p&gt;The WCF &amp;quot;Orcas&amp;quot; release (the WCF from .NET Framework 3.5 aka WCF 2.0) makes it so much easier to use your WCF service in conjunction with ASP.NET AJAX (formerly known as 'Atlas'). &lt;/p&gt;  &lt;p&gt;Before Orcas you would build a AJAX enabled (web) service by adding the [ScriptService] attribute to the service class.&lt;/p&gt;  &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:10pt;background:#f5f5f5;padding-bottom:1pt;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:consolas;"&gt;   &lt;p style="margin:0px;"&gt;[&lt;span style="color:#2b91af;"&gt;WebService&lt;/span&gt;]&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;strong&gt;[&lt;span style="color:#2b91af;"&gt;ScriptService&lt;/span&gt;]&lt;/strong&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;MyService&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;{&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&amp;#160; &lt;span style="color:green;"&gt;// Implementation details&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;}&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;The ScriptServiceAttribute enables you to reference a JavaScript proxy from your client-side JS by including &lt;/p&gt;  &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:10pt;background:#f5f5f5;padding-bottom:1pt;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:consolas;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;script&lt;/span&gt; &lt;span style="color:red;"&gt;src&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;http://.../AlmostCoolestService.asmx/js&amp;quot;&lt;/span&gt; &lt;span style="color:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;Notice the /js that is appended at the end. That bit is the work of the ScriptService attribute. You do not have to add the script element manually, but get that automatically when you add a service reference to the ScriptManager control in your page.&lt;/p&gt;  &lt;p&gt;Before anything will work all .asmx requests in an AJAX-enabled website are redirected to a different handler:&lt;/p&gt;  &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:10pt;background:#f5f5f5;padding-bottom:1pt;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:consolas;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;system.web&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;httpHandlers&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;remove&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;verb&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;*&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;path&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;*.asmx&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;add&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;verb&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;*&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;path&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;*.asmx&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;validate&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;false&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;type&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;System.Web.Script.Services.ScriptHandlerFactory, ...&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;add&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;verb&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;*&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;path&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;*_AppService.axd&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;validate&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;false&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;type&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;...&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;add&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;verb&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;GET,HEAD&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;path&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;ScriptResource.axd&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;type&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;System.Web.Handlers.ScriptResourceHandler, ...&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;validate&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;false&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;httpHandlers&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;system.web&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;This replacement .asmx handler will return JSON data instead of the usual SOAP enveloppes, allowing for easy usage from the JavaScript code.&lt;/p&gt;  &lt;p&gt;&amp;lt;Side.note&amp;gt;&lt;/p&gt;  &lt;p&gt;Here is a bit of JSON (JavaScript Object Notation) data:&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:10pt;background:#f5f5f5;padding-bottom:1pt;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:consolas;"&gt;   &lt;p style="margin:0px;"&gt;{ &lt;span style="color:#a31515;"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt; : &lt;span style="color:#a31515;"&gt;&amp;quot;Alex&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;Age&amp;quot;&lt;/span&gt; : 35 }&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;Did you know that this is actually just a JavaScript fragment? Take a look at this:&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:10pt;background:#f5f5f5;padding-bottom:1pt;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:consolas;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;var&lt;/span&gt; person = { &lt;span style="color:#a31515;"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt; : &lt;span style="color:#a31515;"&gt;&amp;quot;Alex&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;Age&amp;quot;&lt;/span&gt; : 35 };&lt;/p&gt;    &lt;p style="margin:0px;"&gt;window.alert(person.Age);&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;So, when you send some JSON data over the wire, it is very easy to start working with that data.&lt;/p&gt;  &lt;p&gt;&amp;lt;/Side.note&amp;gt;&lt;/p&gt;  &lt;p&gt;This is quite a bit of work, right?&lt;/p&gt;  &lt;p&gt;In Orcas we get support for JSON, URL parameters and non-SOAP XML. It also has Atlas-specific conventions such as the JavaScript proxy.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Support for calling WCF service from the client stack&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Visual Studio 2008 has WCF AJAX support, meaning that the ScriptManager understands these types of services and new templates like the AJAX-enabled WCF service. The latter will automaticaly create the correct configuration and corresponding skeleton code.&lt;/p&gt;  &lt;p&gt;Enabling a WCF service for AJAX is a decision you can make at deployment time. So, you can call into any regular WCF service from AJAX without making any changes to your implementation. You do need to make some changes, which vary based on your hosting scenario. &lt;/p&gt;  &lt;p&gt;Let's assume you have an IIS hosted WCF service. You need to edit the ServiceHost directive in the .svc file and specify a different ServiceHostFactory implementation, like so:&lt;/p&gt;  &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:10pt;background:#f5f5f5;padding-bottom:1pt;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:consolas;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="background:#ffee62;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color:blue;"&gt;@&lt;/span&gt; &lt;span style="color:red;"&gt;ServiceHost&lt;/span&gt; &lt;span style="color:red;"&gt;Service&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;CoolestWCFService&amp;quot;&lt;/span&gt; &lt;span style="color:red;"&gt;Factory&lt;/span&gt;&lt;span style="color:blue;"&gt;=&amp;quot;WebScriptServiceHostFactory&amp;quot;&lt;/span&gt; &lt;span style="background:#ffee62;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;   &lt;p&gt;Here WebScript actually means AJAX-enabled.&lt;/p&gt;  &lt;p&gt;When you host the WCF service yourself, you should edit your configuration file to enable JSON support.&lt;/p&gt;  &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:10pt;background:#f5f5f5;padding-bottom:1pt;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:lucida console;"&gt;   &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;serviceHostingEnvironment&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;aspNetCompatibilityEnabled&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;true&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;services&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;service&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;AjaxService&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;endpoint&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;address&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;behaviorConfiguration&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;AjaxBehavior&lt;/span&gt;&amp;quot;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color:red;"&gt;binding&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;webHttpBinding&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;contract&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;IAjaxService&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;service&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;services&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;behaviors&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;endpointBehaviors&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;behavior&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;AjaxBehavior&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;enableWebScript&lt;/span&gt;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;behavior&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;endpointBehaviors&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;behaviors&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;Note how you only need to add an endpoint behavior for enabling WebScript. This makes WCF do the same thing as ASMX web services: it can generate a JavaScript proxy when you visit the URL &lt;a href="http://.../CoolestWCFService.svc/js"&gt;http://.../CoolestWCFService.svc/js&lt;/a&gt;. BTW, the WebScriptServiceHost automatically adds this behavior to any endpoint that has a WebMessageEncodingBindingElement in its Binding element list, but does not have the WebHttp behavior defined. If you are interested in a little more on hosting, check &lt;a href="http://www.alexthissen.nl/blogs/main/archive/2007/07/10/orcas-web-programming.aspx"&gt;here&lt;/a&gt; (a bit dated, but still pretty much ok).&lt;/p&gt;  &lt;p&gt;So, why would you switch to WCF services instead of ASMX services?&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;strong&gt;The separation of contract and binding&lt;/strong&gt;:       &lt;br /&gt;Because the service contract and the binding are separated it will line you up better for future versions of encoding or . You will only need to change the configuration file to hook up e.g. some JSON version 2 (which might become reality to fix the recent security vulnerabilities in JSON v1). Or, you can add an application layer to expose the same service simultaneously as an AJAX and a SOAP service. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;The cool features of WCF&lt;/strong&gt;:       &lt;br /&gt;How are you going to protect your ASMX service from Denial of Service (DoS) attacks? In WCF you can protect your service with quotas, throttles and timeouts. There are more manageability options, such as logging, tracing and a whole bunch of performance counters. Think about the extra hosting options (e.g. self-hosted) for WCF services.       &lt;br /&gt;Also, Workflow Services in .NET 3.5 allow you to put a workflow inside a service which is behind an AJAX-enabled page. Compared to ASMX you could get performance gains as much as 4 times for large messages (rough estimate and preliminary results). And you get to use the HTTP programming model, such as POX and returning binary data. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;The DataContract data model:        &lt;br /&gt;&lt;/strong&gt;Going forward from .NET 3.0 the DataContract way of serializing is the preferred way. In 3.5 you may have noticed that Linq to SQL and ADO.NET Entities have built-in support for DataContract as well. The generated types for both Linq to SQL and ADO.NET Entities are [DataContract] types. Also, Linq to XML will have its XNode and derived types serialize to strings, so there is no problem to send them over the wire and use these in JavaScript. Furthermore, the DataContract is an opt-in model, so your type never gets serialized by accident. This is especially important, since you are sending the information to the browser client. The future directions of &amp;quot;Orcas+1&amp;quot; also indicate neat stuff to happen with the workflow data model and transformations (see &lt;a href="http://www.alexthissen.nl/blogs/main/archive/2007/04/11/more-on-orcas-1-release.aspx" target="_blank"&gt;this entry&lt;/a&gt; for a little more detail). &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;The future&lt;/strong&gt;: There has been no investment in new features for ASMX since .NET 2.0 or in Orcas. Will there be for the future? &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Finally, here are some characteristics of the WCF AJAX architecture:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Operation names are in the URL. There are no SOAP actions. A special operation dispatcher makes this happen. &lt;/li&gt;    &lt;li&gt;Parameters in URLs, because no message body is available for GET requests. Again, a special formatter will take care of that. &lt;/li&gt;    &lt;li&gt;JSON parameters in URLs (Atlas-specific) allows for complex types to be passed from the client to the service. &lt;/li&gt; &lt;/ul&gt;&lt;img src="http://www.alexthissen.nl/aggbug.aspx?PostID=2881" width="1" height="1"&gt;</description><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/AJAX/default.aspx">AJAX</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/Web+Services/default.aspx">Web Services</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/ASP.NET+2.0/default.aspx">ASP.NET 2.0</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/.NET+FX+3.5/default.aspx">.NET FX 3.5</category></item><item><title>Are you my type?</title><link>http://www.alexthissen.nl/blogs/main/archive/2006/12/12/are-you-my-type.aspx</link><pubDate>Tue, 12 Dec 2006 06:01:00 GMT</pubDate><guid isPermaLink="false">badf6229-ffeb-484a-8c5a-fc9c9987c8f2:2665</guid><dc:creator>Alex Thissen</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.alexthissen.nl/blogs/main/rsscomments.aspx?PostID=2665</wfw:commentRss><comments>http://www.alexthissen.nl/blogs/main/archive/2006/12/12/are-you-my-type.aspx#comments</comments><description>&lt;P&gt;&lt;A href="http://athissen.killerblog.net/blogs/main/WindowsLiveWriter/Areyoumytype_BF7C/netmagazine%5B3%5D.jpg"&gt;&lt;IMG height=96 src="http://athissen.killerblog.net/blogs/main/WindowsLiveWriter/Areyoumytype_BF7C/netmagazine_thumb%5B1%5D.jpg" width=240 align=right&gt;&lt;/A&gt;The 15th episode of the &lt;A href="http://www.microsoft.com/netherlands/msdn/netmagazine/default.aspx" target=_blank&gt;Dutch .NET Magazine&lt;/A&gt; has dropped in the mailbox at &lt;A title=Class-A href="http://www.class-a.nl/" target=_blank&gt;Class-A&lt;/A&gt; just a moment ago. Inside are many great articles. There is also an article (I dare not say "one of them") written by Stefan Onderstal from &lt;A title=Qurius href="http://www.qurius.nl/" target=_blank&gt;Qurius&lt;/A&gt; and myself. &lt;/P&gt;
&lt;P&gt;The article focusses on the problem of the default use of the code generators for web service proxies in the .NET Framework and Visual Studio 2005. It discusses three options that we considered on a project for &lt;A title=KPN href="http://www.kpn.nl/" target=_blank&gt;KPN&lt;/A&gt;. These will generate data types for you, which is not always what you want or already have. The Schema Importer Extensions (I wrote about a fix for a generic implementation here) provide a way out in some of the cases.&lt;/P&gt;
&lt;P&gt;The article is in Dutch, but&amp;nbsp;if you got a hand on one of the magazines,&amp;nbsp;you're probably Dutch anyway. Have fun reading all articles.&amp;nbsp;If you aren't subscribed yet, do so right now: &lt;A class="" href="http://www.microsoft.com/netherlands/msdn/netmagazine/abonnementen.aspx"&gt;it's free&lt;/A&gt;. That should get the Dutch running. It might apply to Belgians as well.&lt;/P&gt;&lt;img src="http://www.alexthissen.nl/aggbug.aspx?PostID=2665" width="1" height="1"&gt;</description><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/Articles/default.aspx">Articles</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/Web+Services/default.aspx">Web Services</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/Visual+Studio+2005/default.aspx">Visual Studio 2005</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/Community/default.aspx">Community</category></item><item><title>Cheap skate way to do exception shielding in ASP.NET web services</title><link>http://www.alexthissen.nl/blogs/main/archive/2006/11/22/cheap-skate-way-to-do-exception-shielding-in-asp-net-web-services.aspx</link><pubDate>Wed, 22 Nov 2006 05:42:16 GMT</pubDate><guid isPermaLink="false">badf6229-ffeb-484a-8c5a-fc9c9987c8f2:2011</guid><dc:creator>Alex Thissen</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.alexthissen.nl/blogs/main/rsscomments.aspx?PostID=2011</wfw:commentRss><comments>http://www.alexthissen.nl/blogs/main/archive/2006/11/22/cheap-skate-way-to-do-exception-shielding-in-asp-net-web-services.aspx#comments</comments><description>&lt;p&gt;You read it right. There is a very cheap way to shield exception information from an ASP.NET web service. Mind you, this is available only from ASP.NET 2.0 (and upwards presumably).&lt;/p&gt; &lt;p&gt;So, what is exception shielding for web services? Preventing potentially valuable exception information from leaking to the calling client. It’s a good security practice to shield unhandled exceptions that occurred inside your web service from bubbling up to the ASP.NET HttpHandler for ASMX. Take this web service:&lt;/p&gt; &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:9pt;background:#f5f5f5;padding-bottom:1pt;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:lucida console;"&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; [&lt;span style="color:teal;"&gt;WebService&lt;/span&gt;(Namespace = &lt;span style="color:maroon;"&gt;"http://tempuri.org/"&lt;/span&gt;)]&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; [&lt;span style="color:teal;"&gt;WebServiceBinding&lt;/span&gt;(ConformsTo = &lt;span style="color:teal;"&gt;WsiProfiles&lt;/span&gt;.BasicProfile1_1)]&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; [&lt;span style="color:teal;"&gt;ToolboxItem&lt;/span&gt;(&lt;span style="color:blue;"&gt;false&lt;/span&gt;)]&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:teal;"&gt;FaultyTowers&lt;/span&gt; : System.Web.Services.&lt;span style="color:teal;"&gt;WebService&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; {&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &amp;nbsp; [&lt;span style="color:teal;"&gt;WebMethod&lt;/span&gt;]&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; HelloFawlty()&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color:blue;"&gt;throw&lt;/span&gt; &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:teal;"&gt;ArgumentException&lt;/span&gt;(&lt;span style="color:maroon;"&gt;"Stop right there, Basil!"&lt;/span&gt;);&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:maroon;"&gt;"No way, Manuel"&lt;/span&gt;;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;/div&gt; &lt;p&gt;The handler will take over and return a SOAP fault to the client. The &amp;lt;soap:Fault&amp;gt; element will contain (wrapped inside&amp;nbsp;a SoapException) the type and message of the exception that occurred, plus a stacktrace and references to the file location of the source file. It will look like this:&lt;/p&gt; &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:9pt;background:#f5f5f5;padding-bottom:1pt;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:lucida console;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:maroon;"&gt;xml&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;1.0&lt;/span&gt;"&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;encoding&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;utf-16&lt;/span&gt;"&lt;span style="color:blue;"&gt;?&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;soap:Envelope&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;xmlns:soap&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;http://schemas.xmlsoap.org/soap/envelope/&lt;/span&gt;"&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;xmlns:xsi&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/span&gt;"&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;xmlns:xsd&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;http://www.w3.org/2001/XMLSchema&lt;/span&gt;"&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;soap:Body&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;soap:Fault&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;faultcode&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;soap:Server&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:maroon;"&gt;faultcode&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;faultstring&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.Web.Services.Protocols.SoapException: Server was unable to process request. ---&lt;span style="color:red;"&gt;&amp;amp;gt;&lt;/span&gt; System.ArgumentException: Stop right there, Basil!&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; at WebApplication1.FaultyTowers.HelloFawlty() in C:\temp\WebApplication1\FaultyTowers.asmx.cs:line 23&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --- End of inner exception stack trace ---&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:maroon;"&gt;faultstring&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;detail&lt;/span&gt;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:maroon;"&gt;soap:Fault&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:maroon;"&gt;soap:Body&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:maroon;"&gt;soap:Envelope&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;p&gt;You could jump through hoops to catch all unhandled exceptions that occur inside of your methods and throw your own SoapExceptions (in which case the exception isn’t altered). There is some guidance right &lt;a href="http://msdn2.microsoft.com/en-us/library/aa480591.aspx" target="_blank"&gt;here&lt;/a&gt;&amp;nbsp;from the &lt;a href="http://msdn.microsoft.com/practices/" target="_blank"&gt;Patterns and Practices&lt;/a&gt; team.&lt;/p&gt; &lt;p&gt;Or you could set a new ASP.NET 2.0 diagnostics option in your web.config and let the ASP.NET runtime take care of not returning too much exception information.&lt;/p&gt; &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:9pt;background:#f5f5f5;padding-bottom:1pt;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:lucida console;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:maroon;"&gt;xml&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;1.0&lt;/span&gt;"&lt;span style="color:blue;"&gt;?&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;configuration&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;system.web&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;webServices&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;diagnostics&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;suppressReturningExceptions&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;true&lt;/span&gt;"&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:maroon;"&gt;webServices&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;p&gt;Setting the suppressReturningExceptions attribute to true (the default is false) will result in no information being included in the returned SoapException. The &amp;lt;soap:Fault&amp;gt; will now contain the following:&lt;/p&gt; &lt;div style="border-right:#cccccc 1pt solid;padding-right:1pt;border-top:#cccccc 1pt solid;padding-left:1pt;font-size:9pt;background:#f5f5f5;padding-bottom:1pt;border-left:#cccccc 1pt solid;width:100%;color:black;padding-top:1pt;border-bottom:#cccccc 1pt solid;font-family:lucida console;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;soap:Fault&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;faultcode&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;soap:Server&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:maroon;"&gt;faultcode&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;faultstring&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;System.Web.Services.Protocols.SoapException: An error occurred on the server.&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:maroon;"&gt;faultstring&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;detail&lt;/span&gt;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:maroon;"&gt;soap:Fault&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;p&gt;I say: recommended for production environments.&lt;/p&gt; &lt;p&gt;For a full-blown and more robust implementation, check the &lt;a href="http://practices.gotdotnet.com/svcfactory" target="_blank"&gt;Web Service Software Factory&lt;/a&gt; from P&amp;amp;P and read an intro by &lt;a href="http://blog.irm.se/blogs/eric/default.aspx" target="_blank"&gt;Eric&lt;/a&gt; &lt;a href="http://blog.irm.se/blogs/eric/archive/2006/09/14/Exception-Shielding.aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.alexthissen.nl/aggbug.aspx?PostID=2011" width="1" height="1"&gt;</description><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/Web+Services/default.aspx">Web Services</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/ASP.NET+2.0/default.aspx">ASP.NET 2.0</category></item><item><title>Calling webservices from client-side Atlas: part 2 of 2</title><link>http://www.alexthissen.nl/blogs/main/archive/2006/07/26/calling-webservices-from-client-side-atlas-part-2-of-2.aspx</link><pubDate>Wed, 26 Jul 2006 07:29:55 GMT</pubDate><guid isPermaLink="false">badf6229-ffeb-484a-8c5a-fc9c9987c8f2:2034</guid><dc:creator>Alex Thissen</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.alexthissen.nl/blogs/main/rsscomments.aspx?PostID=2034</wfw:commentRss><comments>http://www.alexthissen.nl/blogs/main/archive/2006/07/26/calling-webservices-from-client-side-atlas-part-2-of-2.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://www.alexthissen.nl/weblog/DetailsView.aspx?PostingID=271f6a16-8b81-47c2-b28c-2992e68b6735"&gt;Part 1&lt;/a&gt; left us able to call web services that are local. In part 2 we will take a look at web services that are remote to our own website that hosts the Atlas enabled page. Seems like a trivial thing to do. I mean, it&amp;rsquo;s &amp;ldquo;just&amp;rdquo; a soap call over HTTP, right? The challenge lies in the fact that the MSXML2.XmlHttp COM object is not allowed to make cross-domain HTTP requests. The solution is&amp;nbsp;to bridge your call through the local website. The hosting web server will make the call on your behalf to the remote web service. The mechanism that Atlas&amp;nbsp;brings is the .asbx bridge file. A bridge file defines what the remote web service looks like.&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;xml&lt;/span&gt;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;version&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;1.0&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;encoding&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;utf-8&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt; ?&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;bridge&lt;/span&gt;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;strong&gt;&lt;span style="COLOR:red;"&gt;namespace&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;KillerApps.Games.Atlas&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;className&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;GameServerStatus&lt;/SPAN&gt;"&lt;/strong&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;proxy&lt;/span&gt;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;type&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;KillerApps.Games.Atlas.GameQueryService, App_Code&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;serviceUrl&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&amp;rdquo;http://localhost:1256/WebSite/G&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;ameQueryService.asmx&amp;rdquo;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;method&lt;/span&gt;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;name&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;&lt;STRONG&gt;GetServerStatus&lt;/STRONG&gt;&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;input&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;parameter&lt;/span&gt;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;name&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;serverAddress&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;parameter&lt;/span&gt;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;name&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;queryPort&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;parameter&lt;/span&gt;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;name&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;engine&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;input&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;method&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;method&lt;/span&gt;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;name&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;&lt;STRONG&gt;GetPlayers&lt;/STRONG&gt;&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;input&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;parameter&lt;/span&gt;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;name&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;serverAddress&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;parameter&lt;/span&gt;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;name&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;queryPort&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;parameter&lt;/span&gt;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;name&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;engine&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;input&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;method&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;bridge&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;The XML fragment above defines a&amp;nbsp;proxy to the remote service located at the endpoint &lt;span style="COLOR:blue;"&gt;&lt;a href="http://localhost:8442/WebSite/GameQueryService.asmx"&gt;http://localhost:8442/WebSite/GameQueryService.asmx&lt;/a&gt;&lt;font color="#000000"&gt;.&amp;nbsp;Although the web service&amp;nbsp;might define more&amp;nbsp;operations two of those are mentioned and are callable by the proxy. The input and (optional) output parameters are listed as well. The proxy is a server-side class that you must provide. I used a wsdl.exe generated proxy class and included it in the App_Code folder of the Website that also hosts the .asbx file.:&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="COLOR:blue;"&gt;&lt;font face="Lucida Console"&gt;wsdl.exe /language:C# /out:GameQueryServiceProxy.cs /namespace:KillerApps.Games.Atlas &lt;/font&gt;&lt;a href="http://localhost:1256/Website/Gam"&gt;&lt;font face="Lucida Console"&gt;&lt;a href="http://localhost:1256/Website/GameQueryService.asmx"&gt;http://localhost:1256/Website/Gam&lt;/font&gt;&lt;/a&gt;&lt;font face="Lucida Console"&gt;eQueryService.asmx&lt;/a&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;In the first part you already saw how the ScriptHandlerFactory class handles all requests for .asmx (local web services) and .asbx (bridge files to remote web services). To be able to call a remote service, simply list the location of the .asbx file instead of local .asmx file you saw before.&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;atlas&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;:&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;ScriptManager&lt;/span&gt; &lt;span style="COLOR:red;"&gt;runat&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;="server"&lt;/span&gt; &lt;span style="COLOR:red;"&gt;ID&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;="scriptManager"&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;Services&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;atlas&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;:&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;ServiceReference&lt;/span&gt; &lt;span style="COLOR:red;"&gt;Path&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;="&lt;STRONG&gt;~/GameQueryService.asbx&lt;/STRONG&gt;"&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;Services&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;atlas&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;:&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;ScriptManager&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;Like before, the ScriptManager will emit JavaScript for the bridge containing an object that acts as a JavaScript proxy to the local server, which in turn bridges the call to the remote web service. The JavaScript is inserted by adding a include to the same location as the .asbx file, plus an extra /js, as in: &lt;a href="http://localhost/GameQueryService.asbx/js"&gt;http://localhost/GameQueryService.asbx/js&lt;/a&gt;. The resulting JavaScript for the bridge file above is:&lt;/p&gt;
&lt;p&gt;&lt;font face="Lucida Console"&gt;Type.registerNamespace('KillerApps.Games.Atlas'); KillerApps.Games.Atlas.GameServerStatus=new function() { this.appPath = "http://localhost:8442/WebSite/"; var cm=Sys.Net.ServiceMethod.createProxyMethod; cm(this,"GetServerStatus","args"); cm(this,"GetPlayers","args"); cm(this,"__invokeBridge","method","args"); }&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;You can call the web service through the JavaScript object that has a &amp;ldquo;namespace&amp;rdquo; and &amp;ldquo;className&amp;rdquo; as indicated in the bridge file. The method names correspond to the defined methods. The call to the service looks like this:&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;function&lt;/span&gt; OnLoad(sender, eventArgs)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;{&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; KillerApps.Games.Atlas.GameServerStatus.GetServerStatus&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ( &lt;strong&gt;{ &lt;span style="COLOR:maroon;"&gt;"serverAddress"&lt;/span&gt; : &lt;span style="COLOR:maroon;"&gt;"213.132.174.125"&lt;/span&gt;, &lt;/strong&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR:maroon;"&gt;"queryPort"&lt;/span&gt; : 27030, &lt;/strong&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:maroon;"&gt;"engine"&lt;/span&gt; : &lt;span style="COLOR:maroon;"&gt;"HalfLife"&lt;/span&gt; }&lt;/strong&gt;, &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OnStatusComplete);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;}&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;Notice that the bolded part is a different way to pass all parameters to the proxy. For proxies corresponding to local web services the arguments were &amp;ldquo;as always&amp;rdquo;. Now you need to define your arguments in a new Javascript dictionary. The syntax is { &amp;ldquo;parameterName1&amp;rdquo; : &amp;ldquo;argumentValue1&amp;rdquo;, &amp;ldquo;parameterName2&amp;rdquo; : &amp;ldquo;argumentValue2&amp;rdquo;, &amp;hellip; }. After the arguments you can still provide a callback methodname, plus one for timeouts and one for errors.&lt;/p&gt;
&lt;p&gt;You probably noticed that the service endpoint was a local address, that served as a remote web service for testing purposes. As soon as you want to access an actual remotely located web service, you will run into security problems. The bridge won&amp;rsquo;t let you call into cross-domain methods that are not marked safe. You do so by adding an extra attribute to each method that you consider safe (e.g. which transport non-confidential information, or the ones that cannot be misused)&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;font face="Lucida Console"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;method&lt;/span&gt;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;name&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;GetServerStatus&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;safeForCrossDomain&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;true&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;This should get your web method calls to work. There is some mention of marking your web method calls as a WebOperation, like so:&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;strong&gt;[&lt;span style="COLOR:teal;"&gt;WebOperation&lt;/span&gt;(&lt;span style="COLOR:blue;"&gt;true&lt;/span&gt;, &lt;span style="COLOR:teal;"&gt;ResponseFormatMode&lt;/span&gt;.Json, &lt;span style="COLOR:blue;"&gt;true&lt;/span&gt;)]&lt;/strong&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;[&lt;span style="COLOR:teal;"&gt;WebMethod&lt;/span&gt;]&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:teal;"&gt;ServerInfo&lt;/span&gt; GetServerStatus(&lt;span style="COLOR:blue;"&gt;string&lt;/span&gt; serverAddress, &lt;span style="COLOR:blue;"&gt;int&lt;/span&gt; queryPort, &lt;span style="COLOR:teal;"&gt;GameEngine&lt;/span&gt; engine)&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;but I haven&amp;rsquo;t found a situation yet where this is actually necessary to do.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.alexthissen.nl/aggbug.aspx?PostID=2034" width="1" height="1"&gt;</description><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/Gaming/default.aspx">Gaming</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/AJAX/default.aspx">AJAX</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/Web+Services/default.aspx">Web Services</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/ASP.NET+2.0/default.aspx">ASP.NET 2.0</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/Atlas/default.aspx">Atlas</category></item><item><title>Fixing the Shared Type Schema Importer Extension for nullable value types</title><link>http://www.alexthissen.nl/blogs/main/archive/2006/07/24/fixing-the-shared-type-schema-importer-extension-for-nullable-value-types.aspx</link><pubDate>Mon, 24 Jul 2006 20:11:44 GMT</pubDate><guid isPermaLink="false">badf6229-ffeb-484a-8c5a-fc9c9987c8f2:2035</guid><dc:creator>Alex Thissen</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.alexthissen.nl/blogs/main/rsscomments.aspx?PostID=2035</wfw:commentRss><comments>http://www.alexthissen.nl/blogs/main/archive/2006/07/24/fixing-the-shared-type-schema-importer-extension-for-nullable-value-types.aspx#comments</comments><description>&lt;p&gt;When you add a Web Reference to your project, Visual Studio will also import all schema types defined in the WSDL&amp;rsquo;s schema section. You can create a schema importer extension (SIE) to influence the way the XSD schema types are mapped to your CLR types. There is a &lt;a href="http://www.microsoft.com/belux/msdn/nl/community/columns/jdruyts/wsproxy.mspx" target="_blank"&gt;very nice article by Jelle Druyts&lt;/a&gt;&amp;nbsp;on a SIE that shows how you can create a extension that will map based on an XML configuration section in your devenv.exe.config file. Go read that one first, then read on.&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;xml&lt;/span&gt;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;version&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;1.0&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;encoding&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;utf-8&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt; ?&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;schemaImporterExtensions&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;sharedTypeMappings&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;mapping&lt;/span&gt;&lt;span style="COLOR:blue;"&gt; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;xmlNamespace&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;http://schemas.samplebusiness.net/SharedTypes&lt;/SPAN&gt;"&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;xmlTypeName&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;Customer&lt;/SPAN&gt;"&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;clrAssemblyPath&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;C:\Sample\SampleBusinessTypes.dll&lt;/SPAN&gt;"&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:red;"&gt;clrClassName&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;SampleBusinessTypes.Customer&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;sharedTypeMappings&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;schemaImporterExtensions&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;It a reasonably straightforward process of looking up the imported XML element name and namespace in the mapping elements and adding returning the mapped CLR class name instead of the 1&amp;ndash;1 mapping that would normally occur. We are using this schema importer extension on a project, but&amp;nbsp;project-colleague Frans Harinck&amp;nbsp;found that it did not map nullable enums correctly. So I ventured out to fix this. &lt;/p&gt;
&lt;p&gt;The problem is that nullable value types&amp;nbsp;on the web service will&amp;nbsp;now have a&amp;nbsp;xsd:nillable=&amp;rdquo;true&amp;rdquo;&amp;nbsp;attribute set in the WSDL schema. This was always true for reference types, which (of course) can have a null value. Value types couldn&amp;rsquo;t until .NET 2.0. The SIE from Jelle did not take this into account (although SIE was introduced in Visual Studio 2005). When you debug the SIE (side note: Set the build path directly into the folder C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies and attach the debugger to another VS2005 instance. In the attached instance Add or Update a Web Reference and your breakpoints should be hit), you will see how the name and namespace of your nullable value type pass by. These are mapped to your own CLR type, but not as nullable. You can determine whether your type is marked xsd:nillable=&amp;rdquo;true&amp;rdquo; by evaluating the XmlSchemaObject object supplied. This indicates that the corresponding schema element is nillable, and that it is a simpleType. The combination tells you the type is nullable. So instead of returning the mapped CLR name, it should return System.Nullable&amp;lt;&lt;em&gt;CLR name&lt;/em&gt;&amp;gt;.&lt;/p&gt;
&lt;p&gt;Below is the bolded change you need to make to the source code from the article, i.e. the SharedTypeSchemaImporterExtension.cs file to be exact.&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;override&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;string&lt;/span&gt; ImportSchemaType(&lt;span style="COLOR:blue;"&gt;string&lt;/span&gt; name, &lt;span style="COLOR:blue;"&gt;string&lt;/span&gt; ns, &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; XmlSchemaObject context, XmlSchemas schemas, &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; XmlSchemaImporter importer, CodeCompileUnit compileUnit, &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; CodeNamespace mainNamespace, CodeGenerationOptions options, &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; CodeDomProvider codeProvider)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;{&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;try&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="COLOR:blue;"&gt;foreach&lt;/span&gt; (SharedTypeMappingElement mapping &lt;span style="COLOR:blue;"&gt;in&lt;/span&gt; &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SchemaImporterExtensionsConfiguration.Instance.SharedTypeMappings)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="COLOR:green;"&gt;// Check if the namespace and type name match.&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="COLOR:blue;"&gt;if&lt;/span&gt; (mapping.Matches(ns, name))&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="COLOR:green;"&gt;// Add an assembly reference.&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="COLOR:blue;"&gt;if&lt;/span&gt; (!&lt;span style="COLOR:blue;"&gt;string&lt;/span&gt;.IsNullOrEmpty(mapping.ClrAssemblyPath))&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; compileUnit.ReferencedAssemblies.Add(mapping.ClrAssemblyPath);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="COLOR:green;"&gt;// Indicate that no XML schema type should be imported but that a&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="COLOR:green;"&gt;// well-known shared CLR type will be used.&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;// Valuetypes can be nullable in .NET 2.0&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XmlSchemaElement schemaElement = context &lt;span style="COLOR:blue;"&gt;as&lt;/span&gt; XmlSchemaElement;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;if&lt;/span&gt; (schemaElement != &lt;span style="COLOR:blue;"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; schemaElement.IsNillable &amp;amp;&amp;amp; &lt;/strong&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; schemaElement.ElementSchemaType &lt;span style="COLOR:blue;"&gt;is&lt;/span&gt; XmlSchemaSimpleType)&lt;/strong&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/strong&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;return&lt;/span&gt; &lt;span style="COLOR:teal;"&gt;String&lt;/span&gt;.Format(&lt;span style="COLOR:maroon;"&gt;"System.Nullable&amp;lt;{0}&amp;gt;"&lt;/span&gt;, mapping.ClrClassName);&lt;/strong&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/strong&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="COLOR:blue;"&gt;return&lt;/span&gt; mapping.ClrClassName;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;catch&lt;/span&gt; (&lt;span style="COLOR:teal;"&gt;Exception&lt;/span&gt; exc)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; System.Windows.Forms.MessageBox.Show(exc.Message + &lt;span style="COLOR:teal;"&gt;Environment&lt;/span&gt;.NewLine + &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exc.StackTrace, &lt;span style="COLOR:maroon;"&gt;"SharedTypeSchemaImporterExtension Exception"&lt;/span&gt;, &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Windows.Forms.MessageBoxButtons.OK, &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Windows.Forms.MessageBoxIcon.Error);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &lt;span style="COLOR:green;"&gt;// No match, delegate to the base class.&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;return&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;base&lt;/span&gt;.ImportSchemaType(name, ns, context, schemas, importer, &lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;compileUnit, mainNamespace, options, codeProvider);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.alexthissen.nl/aggbug.aspx?PostID=2035" width="1" height="1"&gt;</description><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/Web+Services/default.aspx">Web Services</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/Visual+Studio+2005/default.aspx">Visual Studio 2005</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/XML/default.aspx">XML</category></item><item><title>Calling webservices from client-side Atlas: part 1 of 2</title><link>http://www.alexthissen.nl/blogs/main/archive/2006/07/20/calling-webservices-from-client-side-atlas-part-1-of-2.aspx</link><pubDate>Thu, 20 Jul 2006 21:05:14 GMT</pubDate><guid isPermaLink="false">badf6229-ffeb-484a-8c5a-fc9c9987c8f2:2039</guid><dc:creator>Alex Thissen</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.alexthissen.nl/blogs/main/rsscomments.aspx?PostID=2039</wfw:commentRss><comments>http://www.alexthissen.nl/blogs/main/archive/2006/07/20/calling-webservices-from-client-side-atlas-part-1-of-2.aspx#comments</comments><description>&lt;p&gt;The March and May 2006 CTP&amp;rsquo;s of Atlas introduced two formal ways to call web services from a web browser. The difference is in the location of the web services.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Local web services&lt;/li&gt;&lt;li&gt;Remote or external web services&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Atlas makes it really easy to call web services when they are local, i.e. reside in the same website as your Atlas-enabled web pages. You can create any ordinary .asmx web service and it will be callable from client-side JavaScript. Sure, you need to do some extra things, but there are no requirements to your service. Let&amp;rsquo;s take a look at how this works. Full source code is included at the end.&lt;/p&gt;&lt;p&gt;Say we have a web service GameQueryService.asmx&amp;nbsp;whose class is defined like so:&lt;/p&gt;&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console;"&gt;&lt;p style="MARGIN:0px;"&gt;[&lt;span style="COLOR:teal;"&gt;WebService&lt;/span&gt;(Namespace = &lt;span style="COLOR:maroon;"&gt;"unr:www-killerapps-nl:services:games"&lt;/span&gt;)]&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;[&lt;span style="COLOR:teal;"&gt;WebServiceBinding&lt;/span&gt;(ConformsTo = &lt;span style="COLOR:teal;"&gt;WsiProfiles&lt;/span&gt;.BasicProfile1_1)]&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;public &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;class &lt;/span&gt;&lt;span style="COLOR:teal;"&gt;GameQueryService&lt;/span&gt; : System.Web.Services.&lt;span style="COLOR:teal;"&gt;WebService&lt;/span&gt;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;{&amp;nbsp;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; [&lt;span style="COLOR:teal;"&gt;WebMethod&lt;/span&gt;]&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; [&lt;span style="COLOR:teal;"&gt;XmlInclude&lt;/span&gt;(&lt;span style="COLOR:blue;"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR:teal;"&gt;HalfLifeServerInfo&lt;/span&gt;))]&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; [&lt;span style="COLOR:teal;"&gt;XmlInclude&lt;/span&gt;(&lt;span style="COLOR:blue;"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR:teal;"&gt;SourceServerInfo&lt;/span&gt;))]&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;public &lt;/span&gt;&lt;span style="COLOR:teal;"&gt;ServerInfo&lt;/span&gt; GetServerStatus(&lt;span style="COLOR:blue;"&gt;string&lt;/span&gt; serverAddress, &lt;span style="COLOR:blue;"&gt;int&lt;/span&gt; queryPort, &lt;span style="COLOR:teal;"&gt;GameEngine&lt;/span&gt; engine)&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Not relevant&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; }&amp;nbsp;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;p&gt;We want to be able to call this web service from JavaScript. In an Atlas enabled .aspx page there is always a atlas:ScriptManager control present. You need to reference the web service from there.&lt;/p&gt;&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console;"&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;atlas:ScriptManager &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&lt;/span&gt;&lt;span style="COLOR:red;"&gt;runat&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;server&lt;/SPAN&gt;" &lt;span style="COLOR:blue;"&gt;&lt;/span&gt;&lt;span style="COLOR:red;"&gt;ID&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;atlasScriptManager&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;Services&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;atlas:ServiceReference &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&lt;/span&gt;&lt;span style="COLOR:red;"&gt;Path&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;~/GameQueryService.asmx&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;Services&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;atlas:ScriptManager&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="COLOR:blue;"&gt;&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console;"&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;div &lt;/span&gt;&lt;span style="COLOR:red;"&gt;id&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;="serverNameLabel"&amp;gt;&lt;/span&gt;Loading server information...&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;div&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;Now, the scriptmanager will do loads of things for you. First of all, it will generate JavaScript code that represents a proxy to this very web service. It makes the service available through calls as simple as this:&lt;/p&gt;&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console;"&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:teal;"&gt;GameQueryService&lt;/span&gt;.GetServerStatus(&lt;span style="COLOR:maroon;"&gt;"213.132.174.125"&lt;/span&gt;, 27030, &lt;span style="COLOR:maroon;"&gt;"HalfLife"&lt;/span&gt;, OnStatusComplete);&lt;/p&gt;&lt;/div&gt;&lt;p&gt;That is almost exactly like a regular C# call to a proxy generated by wsdl.exe or Add Web Reference. The first three arguments are the ones from the WebMethod. The last one is the name of a callback JavaScript method that gets called when the call has completed.&lt;br /&gt;The magic behind the scenes is done by a different handler of .asmx requests. Web.config defines a new HttpHandler for .asmx and ties it to a ScriptHandlerFactory, allowing regular GET requests on the web service. GET requests are not supported by default in ASP.NET 2.0.&lt;/p&gt;&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;httpHandlers&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console;"&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;remove &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&lt;/span&gt;&lt;span style="COLOR:red;"&gt;verb&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;*&lt;/SPAN&gt;" &lt;span style="COLOR:blue;"&gt;&lt;/span&gt;&lt;span style="COLOR:red;"&gt;path&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;*.asmx&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;add &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&lt;/span&gt;&lt;span style="COLOR:red;"&gt;verb&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;*&lt;/SPAN&gt;" &lt;span style="COLOR:blue;"&gt;&lt;/span&gt;&lt;span style="COLOR:red;"&gt;path&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;*.asmx&lt;/SPAN&gt;" &lt;span style="COLOR:blue;"&gt;&lt;/span&gt;&lt;span style="COLOR:red;"&gt;type&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;Microsoft.Web.Services.ScriptHandlerFactory&lt;/SPAN&gt;" &lt;span style="COLOR:blue;"&gt;&lt;/span&gt;&lt;span style="COLOR:red;"&gt;validate&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;false&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;add &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&lt;/span&gt;&lt;span style="COLOR:red;"&gt;verb&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;*&lt;/SPAN&gt;" &lt;span style="COLOR:blue;"&gt;&lt;/span&gt;&lt;span style="COLOR:red;"&gt;path&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;*.asbx&lt;/SPAN&gt;" &lt;span style="COLOR:blue;"&gt;&lt;/span&gt;&lt;span style="COLOR:red;"&gt;type&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;Microsoft.Web.Services.ScriptHandlerFactory&lt;/SPAN&gt;" &lt;span style="COLOR:blue;"&gt;&lt;/span&gt;&lt;span style="COLOR:red;"&gt;validate&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;false&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;In part 2 we will get to the .asbx extension.&lt;br /&gt;You can switch off the ability to reach local web services from GET request, but this is enabled by default from the web.config&lt;/p&gt;&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console;"&gt;&lt;span style="COLOR:blue;"&gt;&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console;"&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;microsoft.web&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;webServices &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&lt;/span&gt;&lt;span style="COLOR:red;"&gt;enableBrowserAccess&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;true&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;Let&amp;rsquo;s say we want to call this web service when the page loads. You might be tempted to use the onLoad event of the BODY tag to wait for the page to finish loading. You should &lt;u&gt;not&lt;/u&gt; do this. There is a slight delay between the&amp;nbsp;loading of the&amp;nbsp;page and the generation of the JavaScript proxy. Instead you must trigger the call to the proxy via the Atlas application object:&lt;/p&gt;&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console;"&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;script &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&lt;/span&gt;&lt;span style="COLOR:red;"&gt;type&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;text/xml-script&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;page &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&lt;/span&gt;&lt;span style="COLOR:red;"&gt;xmlns:script&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;http://schemas.microsoft.com/xml-script/2005&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;components&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;application &lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&lt;/span&gt;&lt;span style="COLOR:red;"&gt;load&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;=&lt;/span&gt;"&lt;SPAN style="color:blue;"&gt;OnLoad&lt;/SPAN&gt;"&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;application&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;components&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;page&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;script&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;The&amp;nbsp;OnLoad method is called when the application&amp;nbsp;has finished loading.&lt;/p&gt;&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console;"&gt;&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console;"&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;script&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;function&lt;/span&gt; OnLoad(sender, eventArgs)&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; GameQueryService.GetServerStatus(&lt;span style="COLOR:maroon;"&gt;"213.132.174.125"&lt;/span&gt;, 27030, &lt;span style="COLOR:maroon;"&gt;"HalfLife"&lt;/span&gt;, OnStatusComplete);&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;function&lt;/span&gt; OnStatusComplete(result)&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="COLOR:blue;"&gt;if&lt;/span&gt; (result == &lt;span style="COLOR:blue;"&gt;null&lt;/span&gt;)&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; alert(&lt;span style="COLOR:maroon;"&gt;"No response received"&lt;/span&gt;);&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="COLOR:blue;"&gt;return&lt;/span&gt;;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &amp;nbsp; alert(result.ServerName);&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR:maroon;"&gt;script&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;The callback function expects a single parameter which is the result of the web service call, provided that no error or timeout has occured. In our case the result could be a null reference, so we need to test for that. But, if it is not, then you can access the result. We receive a ServerInfo (or one of its derived classes) object. The coolest thing is that you can access the&amp;nbsp;properties of the&amp;nbsp;result as if it were the actual C# object. That&amp;rsquo;s why you can access result.ServerName, because ServerName is one of the properties from the ServerInfo class.&lt;/p&gt;&lt;p&gt;You should also include a mechanism to catch timeouts and errors. For that, simply create a set of two JavaScript methods and pass the names of them as the last two arguments of the previous call to the proxy:&lt;/p&gt;&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Lucida Console;"&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&lt;font color="#000000"&gt;GameQueryService.GetServerStatus(&lt;/font&gt;&lt;span style="COLOR:maroon;"&gt;"213.132.174.125"&lt;/span&gt;&lt;font color="#000000"&gt;, 27030, &lt;/font&gt;&lt;span style="COLOR:maroon;"&gt;"HalfLife"&lt;/span&gt;&lt;font color="#000000"&gt;, OnStatusComplete, OnTimeout, OnError);&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;function&lt;/span&gt; OnError(result)&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;{&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; alert(&lt;span style="COLOR:maroon;"&gt;'An error has occured. Details are listed below:\n'&lt;/span&gt; + result);&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;}&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;function&lt;/span&gt; OnTimeout(result)&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;{&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;var&lt;/span&gt; serverNameLabel = &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; Sys.UI.Label($(&lt;span style="COLOR:maroon;"&gt;'serverNameLabel'&lt;/span&gt;));&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;&amp;nbsp; serverNameLabel.set_text(&lt;span style="COLOR:maroon;"&gt;'The gadget did not respond in time.'&lt;/span&gt;);&lt;/p&gt;&lt;p style="MARGIN:0px;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;p&gt;The OnTimeout method has another bit of client-side Atlas, manipulating the DIV with an ID of serverNameLabel through DHTML.&lt;/p&gt;&lt;p&gt;Calling your web service&amp;rsquo;s methods turns out to be not that complicated. Things change a little when you try to access a web service that is not in the same domain. We will cover bridging such calls in the next part.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.alexthissen.nl/weblog/blogs/athissen/LocalWebservicesAtlas.zip"&gt;File Attachment: LocalWebservicesAtlas.zip (425 KB)&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.alexthissen.nl/aggbug.aspx?PostID=2039" width="1" height="1"&gt;</description><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/Gaming/default.aspx">Gaming</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/AJAX/default.aspx">AJAX</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/Web+Services/default.aspx">Web Services</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/ASP.NET+2.0/default.aspx">ASP.NET 2.0</category><category domain="http://www.alexthissen.nl/blogs/main/archive/tags/Atlas/default.aspx">Atlas</category></item></channel></rss>