0

I have a working ASP.Net test web service, but I keep getting 500 errors as:

"System.InvalidOperationException: Request format is invalid: text/xml.
   at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
   at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
"

when I call it with javascript.

It is a simple web service that takes a single parameter as a string and returns it to the client. Please help!

link to code here

2
  • 1
    Code? Hard to help if we don't know what you tried. Commented Nov 15, 2011 at 20:59
  • Try putting in the full path to the Web Service rather than relative, other than that make sure the JS is on the same server. Note the Same-origin policy en.wikipedia.org/wiki/Same_origin_policy that will limit your JS calling to only directories at the same level or above. Are you able to call directly in the browser? Commented Nov 15, 2011 at 21:04

2 Answers 2

1

For those of you who this might help, the issue was setting the SOAPAction in teh header correctly:

$.ajax({ type: "post", url: target, contentType: "text/xml", data: soapBody, dataType: "xml", processData: false, beforeSend: function( xhr ){ xhr.setRequestHeader( "SOAPAction", "http://blahblah.com/Services/MethodName" ); }, ....

Sign up to request clarification or add additional context in comments.

Comments

0

Make sure that your mess variable doesn't contain GET-style query string like '?a=1&b=2'. You need to send it in POST format, for example in JSON. Try to change contentType to contentType: "application/json; charset=utf-8"

$.ajax({
                url: service,
                type: "POST",
                dataType: "xml",
                data: '{key: value}',
                complete: endTest,
                error: processError,
                contentType: "application/json; charset=utf-8",
        });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.