Hm.. Now I hosted my web services for my Silverlight application and everything working fine there in Client server. Meanwhile I just tried to connect the hosted webservice from my development environment(From visual studio project). Nothing unusual, cool.. it throws the error once again to test my patience. It goes like... " This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place "
This time workaround is not in the code its there in the Web service hosted server. In order to enable cross domain policy you have to add a "crossdomain.xml" file in the root of the application host. That is, either in your "wwwroot" or the folder where the root URL points (like if your application hosted in "http://myapplications.com/Webservice1", the cross domain policy xml file you have to locate is "http://myapplications.com/crossdomain.xml". Not inside of any the sub application folders ). Here is the plain simple crossdomain.xml content.
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="SOAPAction,Content-Type"/>
</cross-domain-policy>
This MSDN reference makes it authenticated :)
Thats it!. Simple cool. So enjoy coding :)
Monday, August 30, 2010
Web service project host on remote server
I was moving my project codes to the Remote host server. Actually It's a Silverlight Project and thank god we have Web service support in Silverlight to manage Database stuffs. So I did it well and my client really impressed with my work (Thanks to the magic done by the Silverlight. I really love Silverlight now :) ) So I decided to host it to server from my development environment.
Definitely I've to make sure that my Web service project is working perfectly, because everything depends on that. I hosted it and pulled the URL from my browser. It was nice to see that the web page lists all the WebMethods written to support my application. I clicked one of them to test from there itself that it is pulling data properly and outputs the exact XML. Page moved to the specific function test page to invoke and test the function(Thanks to .Net that we have very nice UI to test the Web service functions.)
But suddenly it shocked me that my "Invoke" button is missing instead it shows "The test form is only available for requests from the local machine". For a moment it made me mad because I've committed the entire application to the client before evening.
But nothing to worry I suppose, as usual google brought the quickest solution. It's just a matter of adding a protocol section in the web.config file. So see bellow it goes like this.
<configuration>
<system.web>
<webservices>
<protocols>
<add name="HttpGet">
<add name="HttpPost">
</add>
</add>
</protocols>
</webservices>
</system.web>
</configuration>
Thats it! now everything fine. Thanks for a cool week start :)
Definitely I've to make sure that my Web service project is working perfectly, because everything depends on that. I hosted it and pulled the URL from my browser. It was nice to see that the web page lists all the WebMethods written to support my application. I clicked one of them to test from there itself that it is pulling data properly and outputs the exact XML. Page moved to the specific function test page to invoke and test the function(Thanks to .Net that we have very nice UI to test the Web service functions.)
But suddenly it shocked me that my "Invoke" button is missing instead it shows "The test form is only available for requests from the local machine". For a moment it made me mad because I've committed the entire application to the client before evening.
But nothing to worry I suppose, as usual google brought the quickest solution. It's just a matter of adding a protocol section in the web.config file. So see bellow it goes like this.
<configuration>
<system.web>
<webservices>
<protocols>
<add name="HttpGet">
<add name="HttpPost">
</add>
</add>
</protocols>
</webservices>
</system.web>
</configuration>
Thats it! now everything fine. Thanks for a cool week start :)
Subscribe to:
Posts (Atom)
