Question

I am attempting to wrap a newer .net ASMX webservice so that it can be used by an older classic asp application. To do this I found some code to send the soap requests. However in my testing it seems that none of my parameters are reaching the server.

The Server Test Code

   <WebMethod()> _
    Public Function Ping1(str As String)
        If str <> "" Then
            Return str
        Else
            Return "False"
        End If
    End Function

The xml being sent:

<?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>
    <Ping1 xmlns="http://tempuri.org">
      <str>asdf</str>
    </Ping1>
  </soap12:Body>
</soap12:Envelope>

The page keeps returning "False" but as far as I can tell, this should be the right format to send parameters. Any help would be appreciated.

Était-ce utile?

La solution

As demonstrated in this other question you should set proper headers when consuming the service:

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

Note that you can't use tempuri.org namespace, you have to also set your own namespace.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top