2

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...

1
  • why the ?wsdl on the URL? That's only to know what does what, the service is only http://www.webservicehost.co.uk/B2bservice.asmx
    – balexandre
    Oct 11, 2010 at 10:10

1 Answer 1

13

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

10
  • Thanks Balexandre, this gets me further. I now get an error saying: "soap:ClientServer did not recognize the value of HTTP Header SOAPAction: http:// www.webservicehost.co.uk/ B2bservice." (without spaces - I just added those to prevent this editor parsing the URL) I'm not sure what the method name is/should be?
    – Dan
    Oct 11, 2010 at 10:27
  • what is the correct service URL and call method? so I can give you a live example
    – balexandre
    Oct 11, 2010 at 10:30
  • you can see here stackoverflow.com/editing-help how to use the Edit Boxes, for your example, just wrap it with the backtick
    – balexandre
    Oct 11, 2010 at 10:31
  • I know the web service URL, but have no idea what the call method is. Is that something I'd need to contact the SOAP feed providers for? Sorry if this is a stupid question, this is just very new to me.
    – Dan
    Oct 11, 2010 at 10:59
  • the WDSL will tell you all about that, what methods exist and what do you need to pass to each other, if the webservice was made in .NET the .asmx page will have something like this: 27seconds.com/Holidays/US/Dates/USHolidayDates.asmx so you can click on every method and see what do you need to pass and what will you receive. That's what WDSL all about. To use a Web Service, you need to know the end point (URL) and the Method to use, if doing all by hand like you are doing, you also need to know what to send and what to expect from the server upon receive the answer.
    – balexandre
    Oct 11, 2010 at 11:15

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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

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