SOAPAction Woes

R

RisingFish

Hello Everyone,

I've set up a Webservice, and am trying to use XmlHttpRequest to hit
the service. I keep getting an error stating that I need to specifiy a
SOAPAction, but I am not using a SOAP Message for the initial request.
The XmlHttpRequest object is working fine and I'm using the following
headers:

var url = "http://webserver.company.com/path/service.asmx/method1
var params = "Var1=" + Var1 + "&Var2=" + Var2 + "&Var3=" + Var3;
httpreq.open("POST", url, true);
httpreq.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded")
httpreq.setRequestHeader("Content-Length", params.length)
httpreq.onreadystatechange = handleHttpResponse;
httpreq.send(params);

I know that my company is using SOAP 1.1 and .Net 1.1 on the web
servers. I've set the Web Service up on my local box, and I can
sucessfully call the Web Service using XmlHttpRequest, but my box is
running .Net 2.0 on IIS.

Thanks!
 
R

RisingFish

Thanks Gaurav,

That's what's confusing me, I'm not using SOAP to submit so why is it
asking for a SOAPAction in the header? I can set the exact same code
above up to work, with no changes made, on my Personal web server, and
it works fine.
 
Z

Zdenek Drlik

RisingFish napsal(a):
Hello Everyone,

I've set up a Webservice, and am trying to use XmlHttpRequest to hit
the service. I keep getting an error stating that I need to specifiy a
SOAPAction, but I am not using a SOAP Message for the initial request.
The XmlHttpRequest object is working fine and I'm using the following
headers:

var url = "http://webserver.company.com/path/service.asmx/method1
var params = "Var1=" + Var1 + "&Var2=" + Var2 + "&Var3=" + Var3;
httpreq.open("POST", url, true);
httpreq.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded")
httpreq.setRequestHeader("Content-Length", params.length)
httpreq.onreadystatechange = handleHttpResponse;
httpreq.send(params);

I know that my company is using SOAP 1.1 and .Net 1.1 on the web
servers. I've set the Web Service up on my local box, and I can
sucessfully call the Web Service using XmlHttpRequest, but my box is
running .Net 2.0 on IIS.

Thanks!
Hello,
try setting RoutingStyle to SoapServiceRoutingStyle.RequestElement on
your web service (in SoapDocumentServiceAttribute - see
http://msdn2.microsoft.com/en-US/li...s.protocols.soapdocumentserviceattribute.aspx).

After applying this attribute WS should not require SOAPAction HTTP
header in your request.

Zdenek Drlik, MCAD
 
Z

Zdenek Drlik

Gaurav Vaish (EduJini.IN) napsal(a):
It still will.
What WS-R says is that there should be an 'Action' element in Header part in
Message.

And the value of this Action element must be same as that of SOAPAction
provided in HTTP-Headers.
By the
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwebsrv/html/howwebmeth.asp

("If you'd rather not rely on the SOAPAction header for method
dispatching, you can instruct the .asmx handler to use the request
element's name by annotating the class with the [SoapDocumentService]
attribute's RoutingStyle property. If you do this, you should probably
also indicate that the WebMethods don't require a SOAPAction value by
setting their values to the empty string.")

should be possible to set .NET web service to not require SOAPAction.
It works fine for me, so what do you mean by "it still will"?

Zdenek Drlik, MCAD
 
Z

Zdenek Drlik

Gaurav Vaish (EduJini.IN) napsal(a):
Surprisingly... because the documentation reads that "SOAPAction must be set
to empty string" implies that a header:
SOAPAction: ""

must be sent. The same is provided in the sample as well.
If it does not expect SOAPAction header (HTTP Header), it is acting against
the specifications.
IIRC, not provided SOAPAction in custom requests has always generated an
error for me..

.. and hence my statement "It still will" -- meaning that ASMX requires a
SOAPAction HTTP header. The value may be empty... that's a different story.
But the header must still be present in the request.

I hope I am clear this time :)
Yes, you are clear, but I think that you are not true... :)
Document which link I posted yesterday
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwebsrv/html/howwebmeth.asp)
contains this text:

If you'd rather not rely on the SOAPAction header for method
dispatching, you can instruct the .asmx handler to use the request
element's name by annotating the class with the [SoapDocumentService]
attribute's RoutingStyle property. If you do this, you should probably
also indicate that the WebMethods don't require a SOAPAction value by
setting their values to the empty string.
....
In this case, the handler doesn't even look at the SOAPAction value---it
uses the name of the request element instead.

So how could be SOAPAction required when the handler doesn't even look
for it for method dispatching?

Zdenek Drlik, MCAD
 
A

Aditya

Hi RisingFish,

See first of all SoapAction can be used to specify the method name in the
webservice. I think the url you have written should be like following

var url = "http://webserver.company.com/path/service.asmx

And supposing you want to call the method Method1 it should be done as follows
The below code is done in javascript. But u can get the idea.
var aObjHeaders = new Array();
aObjHeaders["SOAPAction"] = "http://tempuri.org/Method1";
aObjHeaders["Content-Type"] = "text/xml";
and send it along with ur request object
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,281
Latest member
Pedroaciny

Latest Threads

Top