tags:

views:

109

answers:

4

driving me nutso....

I have a .Net 2.0 webservice that takes a string and returns XML. I have an HTML page that uses jQuery a simple $.post command to call the service and process the return. The service is up on the remote site, I can access it via URL and I can test it successfully using SOAP_UI no problem.

On my machine everything works great but on the remote server, the jQuery call fails.

jQuery code is:

$.post("/sample.asmx/sampleFunction", { StringParam: paramValue },
    function(data) {
        //stuff
    },
"xml");

any thoughts?

A: 

Have you tried entering the full url in the $.post method?

I found this based on your firebug error (Request format is unrecognized for URL unexpectedly ending in):

You may get this error while calling your web service. In my case it was running perfectly under IIS7 and when deployed on IIS6 it started giving this error. After searching a while I found that I have to enable GET and POST protocols in web.config file.

r-dub
I have. I've tried every permutation of the URL I could think of... full, without leading backslash, localhost...
pkstephens
Can I give two checks? This is the solution.
pkstephens
No, I'd award mimetnet though, I think checking firebug is always the right answer, anyone can google :P
r-dub
+1  A: 

How does it fail?

Did you try using $.ajax and registring the error callback?

jitter
I recommend this method as well.
Elzo Valugi
has the same results, and you can trap the error. Also check if you have valid XML as a result. If the XML is not valid with post it will silently fail.
Elzo Valugi
+3  A: 
  • What does FireBug report between the production and local?
    • Are the request headers the same?
    • What is the result between the two?
  • Does [server]/sample.asmx hit the correct service in the production environment?
mimetnet
With firebug I get: Request format is unrecognized for URL unexpectedly ending in '/sampleFunction' ...
pkstephens
googled the error from firebug, found solution: adding protocol section to webConfig file on remote machine. Didn't know about firebug so you get the check! Thanks to everyone for such amazingly quick responses!!
pkstephens
+1  A: 

you have the same virtual directory on your PC and the remote server?

Because you're using "/" and would indicate you're using from the root of the site.

andres descalzo