Dan
Dan

Reputation: 5986

Get simple response from SOAP service with classic asp

I have been tasked with obtaining a response from a SOAP request, using classic asp. The request is about as basic as it gets - I just need to fire off 3 parameters to a web service URL and write out the response (which is in simple plain text format). I've checked the service using a couple of SOAP testing utilities and it outputs the response fine.

I've also read about 10 different tutorials on consuming SOAP feeds in classic ASP, but none of them seem to work at all.

The latest one I'm trying has given me the following code:

<%
Set oXmlHTTP = CreateObject("Microsoft.XMLHTTP")
oXmlHTTP.Open "POST", "http://www.webservicehost.co.uk/B2bservice.asmx?wsdl", False 

oXmlHTTP.setRequestHeader "Content-Type", "application/soap+xml; charset=utf-8" 
oXmlHTTP.setRequestHeader "SOAPAction", "http://ourNameSpace/ourFunction"

SOAPRequest = _
  "<?xml version=""1.0"" encoding=""utf-8""?>" &_
  "<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">" &_
    "<soap12:Body>" &_
      "<ourFunction xmlns=""http://ourNameSpace/"">" &_
        "<Ccode>OurCode</Ccode>" &_
        "<Pword>1d2s45a</Pword>" &_
        "<OrderNo>9876</OrderNo>" &_
      "</ourFunction>" &_
    "</soap12:Body>" &_
  "</soap12:Envelope>"
oXmlHTTP.send SOAPRequest

response.write oXmlHTTP.responseText
%>

I have all the correct values for the POST URL, the Ccode, Pword and OrderNo variables, but have no idea what to use for the "SoapAction" or values. As a result, when I run the page I just get an error:

soap:SenderUnable to handle request without a valid action parameter. Please supply a valid soap action.

Can anyone suggest what to use for the SoapAction and ourFunction xmlns values?

Many thanks for any pointers...

Upvotes: 2

Views: 29313

Answers (1)

balexandre
balexandre

Reputation: 75093

your code should work ok with a few changes

<%
    Response.Write "<br>START<hr>"

    Set oXmlHTTP = CreateObject("Microsoft.XMLHTTP")
    oXmlHTTP.Open "POST", "http://www.crusaderb2b.co.uk/b2bservice.asmx", False 

    oXmlHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8" 
    oXmlHTTP.setRequestHeader "SOAPAction", "http://crusaderb2b.co.uk/TrackingId"

    SOAPRequest = _
      "<?xml version=""1.0"" encoding=""utf-8""?>" &_
      "<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">" &_
        "<soap12:Body>" &_
          "<ourFunction xmlns=""http://ourNameSpace/"">" &_
            "<Ccode>OurCode</Ccode>" &_
            "<Pword>1d2s45a</Pword>" &_
            "<OrderNo>9876</OrderNo>" &_
          "</ourFunction>" &_
        "</soap12:Body>" &_
      "</soap12:Envelope>"

    oXmlHTTP.send SOAPRequest    
    Response.Write oXmlHTTP.responseText

    Response.Write "<br>END<hr>"
%>

changes are

  • remove ?wdsl
  • change content type
  • method call needs to be the same server of the webservice as it's the method name

added

I changed the code as you provided the Web Service. All you need you have in the service page as:

alt text

original image here

answer with the code above:

alt text

Upvotes: 13

Related Questions