Tatham Oddie

Archive for June 2006

Show some love to Fuel Advance …

with one comment

… with our new t-shirts:

Written by Tatham Oddie

June 8, 2006 at 19:20

Posted in Uncategorized

Calling external web services in ASP.NET Atlas

with 7 comments

I just received this ASP.NET Atlas question via direct email, so thought I'd answer it publically:

I have a web project that has a AutoCompleteExtender textbox. Everything works fine if my .asmx file is in the same project.

<atlas:AutoCompleteExtender runat="server" ID="CustomerList">
<atlas:AutoCompleteProperties Enabled="true"
MinimumPrefixLength="1"
ServicePath="NorthwindService.asmx"
ServiceMethod="AutoCompleteCustomerList"
TargetControlID="customer"/>
</atlas:AutoCompleteExtender>

But as soon as I move the .asmx file to another project and add a web reference to the web project the WebMethod isn't being fired.

<atlas:AutoCompleteExtender runat="server" ID="CustomerList">
<atlas:AutoCompleteProperties Enabled="true"
MinimumPrefixLength="1"
ServicePath="http://server2/App/NorthwindService.asmx"
ServiceMethod="AutoCompleteCustomerList"
TargetControlID="customer"/>
</atlas:AutoCompleteExtender>

Same Host but Different Applications

If the web service you're attempting to hit is on the same host (eg http://localhost/App1/MyPage.aspx calling http://localhost/App2/MyService.asmx) then your issue most likely revolves around the proxy generation.

One of the magic building blocks behind service references in Atlas is the generation of JavaScript proxies for them. Create a new web service in your Atlas application (eg http://localhost/MyApp/MyService.asmx) then take a look at the proxy Atlas generates for it (http://localhost/MyApp/MyService.asmx/js). If you add this "/js" suffix to a web service URL in a non-Atlas application you'll just get an error. If you need to call a non-Atlas application like this, look at the instructions below for using bridges.

Different Hosts

If the web service you're attempting to hit is not on the same host (eg http://server1/MyPage.aspx calling http://server2/MyService.asmx) then your issue is the result of a security restriction:

Other than linking to external resource files (for example, image files, CSS files, script files, and so on), browser applications are restricted to accessing resources available on their home server. However, there is a great variety of Web services available on the Web, and the restriction to a home server limits what can be returned within the scope of a browser application.

To circumvent this restriction (in a secure way) you need to use an Atlas bridge, as documented here:

http://atlas.asp.net/docs/atlas/doc/bridge/default.aspx

technorati tags: ,

Written by Tatham Oddie

June 5, 2006 at 02:37

Posted in Uncategorized

Follow

Get every new post delivered to your Inbox.