Web service failing when installed in seperate project from the website
I am totally new to web services and cannot get mine to work.
My setup is on VS 2008 using IIS. I have one solution file with 3 projects in it: website, code, and services.
If I put my webservice into my website and call it locally then it will work 开发者_StackOverflowfine (it's just a hello world web service). I want to put the service into a different location for use from multiple sites.
I don't know what I'm doing wrong - i've read so much conflicting info regarding disco files, access files, silverlight, flash, java, etc.
I just looking for quick simple steps to create a web service that I can access from javascript and deploy to a seperate website. End goal is to have functionality in webservices so that website will call via JS and run much smoother in the loading time and async calls.
- Do I need to create a disco file?
- Do I need to configure security? -- I know this is prob best, i'm just looking to get it working at all.
- Do I need to allow cross browser access on IIS or on my hosted server?
- Are there any quick reference websites that you can recommend?
- Should I be using WCF as new technology? - I saw this on MSDN but seems to be more for windows apps then web apps.
I'm not getting any specific error codes. I have installed the firefox debugging tools (firebug) and I can see what the headers are but I don't know how to interpret them and there is no response being passed back.
Any help is appreciated!!!
When your JS calls your webservice, the two must be on the same hostname - this is a restriction of the same-origin policy of your browser.
For instance, if your webservice is at http://ws.domain.com/report.asmx
and your page is at http://domain.com/index.aspx
then a straight ajax call will not be allowed.
You can get around this in a few ways. One common method is called JSON-P, which involves returning the ws result as a js function and then calling the ws as a script.
http://en.wikipedia.org/wiki/JSON#JSONP
You can use right-click on the VS Project -> Publish to copy all relevant files in a folder. You have to create a Web Application in IIS and configure it for your WebService. If you don't get useful error messages, try to set
<configuration>
<system.web>
<customErrors mode="Off" />
</system.web>
</configuration>
I hope this helps, but your description of the error is a little vague...
精彩评论