6

I need to consume web services on this .NET site:

https://www.iyardiasp.com/8223third_17/webservices/ItfResidentData.asmx

For preliminary consumption I use either Fiddler or curl. Both give the same error:

<faultstring>Unable to handle request without a valid action parameter. Please supply a valid soap action.</faultstring> 

My curl command:

curl -d @GetVersionNumber.xml https://www.iyardiasp.com/8223third_17/webservices/ItfResidentData.asmx

Please see file GetVersionNumber.xml below:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
    <GetVersionNumber xmlns="http://tempuri.org/YSI.Interfaces.WebServices/ItfResidentData" />
</soap:Body>
</soap:Envelope>

Adding SOAP-ENV:Header as element in soap:Envelope does not help

<SOAP-ENV:Header Content-Type="text/xml" Host="www.iyardiasp.com" SOAPAction="http://tempuri.org/YSI.Interfaces.WebServices/ItfResidentData/GetVersionNumber"/>

Adding the Soap Action as a header does not help.

In this case the curl command is:

curl -H "SOAPAction: http://tempuri.org/YSI.Interfaces.WebServices/ItfResidentData/GetVersionNumber" -d @GetVersionNumber.xml "https://www.iyardiasp.com/8223third_17/webservices/itfapplicantscreening.asmx"

And the response is:

<faultstring>Server did not recognize the value of HTTP Header SOAPAction: http://tempuri.org/YSI.Interfaces.WebServices/ItfResidentData/GetVersionNumber.</faultstring>

2 Answers 2

14

You need to supply the SOAPAction as a HTTP header, not a SOAP header. Here is how a complete request might look like when performed with SoapUI (notice the forth row):

POST /8223third_17/webservices/ItfResidentData.asmx HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "http://tempuri.org/YSI.Interfaces.WebServices/ItfResidentData/GetVersionNumber"
User-Agent: Jakarta Commons-HttpClient/3.1
Host: www.iyardiasp.com
Content-Length: 260

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:itf="http://tempuri.org/YSI.Interfaces.WebServices/ItfResidentData">
   <soapenv:Body>
      <itf:GetVersionNumber/>
   </soapenv:Body>
</soapenv:Envelope>

For curl you might use the -H parameter to send the SOAPAction header but I suggest you use SoapUI for your preliminary consumption (it includes the SOAPAction header by default and beats the console any day).

If you do need to use curl, try something like this (all must be on one line; separated for readability):

curl -H "Content-Type: text/xml;charset=UTF-8" 
     -H "SOAPAction: \"http://tempuri.org/YSI.Interfaces.WebServices/ItfResidentData/GetVersionNumber\"" 
     -d @GetVersionNumber.xml 
     https://www.iyardiasp.com/8223third_17/webservices/ItfResidentData.asmx

with this in the GetVersionNumber.xml file:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:itf="http://tempuri.org/YSI.Interfaces.WebServices/ItfResidentData">
   <soapenv:Body>
      <itf:GetVersionNumber/>
   </soapenv:Body>
</soapenv:Envelope>
3
  • Bogdan, please see my addition to the request, thanks
    – Alex
    Commented Oct 7, 2013 at 21:07
  • Bogdan I checked from Fiddler with your headers - works fine, thanks. From curl it is not working yet
    – Alex
    Commented Oct 7, 2013 at 21:32
  • Bogdan, I tried several variants: for example:curl -H "Content-Type: application/soap+xml;SOAPAction: "tempuri.org/YSI.Interfaces.WebServices/ItfResidentData/…"; Host: www.iyardiasp.com" -d @GetVersionNumber.xml "iyardiasp.com/8223third_17/webservices/…". It is the same result
    – Alex
    Commented Oct 8, 2013 at 16:26
1

Probably noone is using asmx files anymore - but I am :), and just came across the issue. The general problem is that .net has no indication that this is a WebMethod that handles, among other things, soap requests.

The other answers may be valid in their own way, but for the super simple case, making sure your method is decorated with the [WebMethod] attribute solved my problem.

[WebMethod]
public string test() { return "Hello World"];

The attribute is probably also responsible for wrapping your response in a soap wrapper.

Ahh, Microsoft. So much automatic, but even more learning curve.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.