views:

42

answers:

2

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 fine (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!!!

A: 

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...

Hinek
Thanks! Sorry for the vague error message - I don't get one to pass on to you.With this being the issue - would I still be able to browse to the service? I'm not getting errors when I go to http://website/service.asmx but I just get the bad response when I try to call it with JS.And, I know this is most likely a real dumb question - how can i create a *application* in IIS 5? This is on my local xp machine but all i've found online is to do with IIS 6/7. Do you know of any good online resources?
Adam
Hi, the website/service.asmx "working" doesn't mean, the webservice is working. Only if you can test your methods via the website/service.asmx page you can be sure (or build a quick windows app, that uses the webservice). But you're right, it sounds very much like the problem is between the JS and the service. Sorry, can't help you with IIS 5 ... good luck anyway
Hinek
+1  A: 

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

adam
I'll look into this - thanks! I found some info online about cross access policy files (for silverlight and flash mostly). Do you know if this would be able to be used? I tried to use them a little but don't know if I'm doing it wrong or they just aren't made for this.
Adam