Calling webservices outside a domain with Javascript

The last few days i saw some threads about calling a webservice which is outside your domain with Javascript. Because of the restriction that is made for the path property of the servicereference <servicereference Path=”"> (same domain restrictions) it isn’t possible to make a reference to an webservice which is outside your domain. Well in MS Ajax Beta 2 version we could use bridge files to solve this problem. MS Ajax v1.0 doesn’t support bridge files anymore. So we must use another workaround.

The other workaround is using a second webservice (WebserviceA) which makes the call to the webservice (WebserviceB) outside your domain. This is very simple to build.

(WebserviceA)

WebserviceA should be configured in a way that it can accept calls from Javascript, take a look here to see how. This webservice must have a reference to WebserviceB which is outside your domain. You add a reference like we .NET developers are used to. (Add webreference)

(WebserviceB)

WebserviceB can be configured like a normal webservice and there you go!

Hope this helps you!

WebResource.axd and ScriptResource.axd size!

This night i saw 2 threads on the Ajax forum. The 2 threads were about the size of the Webresource.axd and the Scriptresource.axd, the developer said that these files were to big. While i was typing my answer for the developer, Kris van der Mast was already finshed with his answer. He said that the solution to this issue was setting <compilation debug=”false”>. My solution was setting <Scriptmanager Scriptmode=”Release”>. So i decided to check these 2 solutions. Well, i came to the conclusion that is makes no difference which solution you choose, they have the same effect.

When you set <compilation debug=”false”> and you don’t set the Scriptmode (which is “Auto” by defaut) the Scriptlibaries that will be send to the client while inherit the setting debug=false (so release=true). So the smaller scriptlibraries will be send to the client.

When you set <compilation debug=”true”> and the Scriptmode=”Release” then the compilation element will be overriden and the release scriptlibraries will also be send to the client.

My preference will go the latest option. Why? Well the first option has consequences for the whole application and the second option only on the page where you are working on. I hope you agree with me! 

Follow

Get every new post delivered to your Inbox.