views:

2796

answers:

4
A: 

You might be missing the SOAPAction header. Here's a working example:

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class GreetingService : WebService
{
    [WebMethod]
    public string Greet(string name)
    {
        return string.Format("Hello {0}", name);
    }
}

And the calling VBS script:

Dim SoapRequest
Set SoapRequest = CreateObject("MSXML2.XMLHTTP")

Dim myXML 
Set myXML = CreateObject("MSXML.DOMDocument")


myXML.Async=False
SoapRequest.Open "POST", "http://localhost:4625/GreetingService.asmx", False
SoapRequest.setRequestHeader "Content-Type","text/xml;charset=utf-8"
SoapRequest.setRequestHeader "SOAPAction", """http://tempuri.org/Greet"""

Dim DataToSend
DataToSend= _
    "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:tem=""http://tempuri.org/""&gt;" & _
        "<soapenv:Header/>" & _
        "<soapenv:Body>" & _
            "<tem:Greet>" & _
                "<tem:name>John</tem:name>" & _
            "</tem:Greet>" & _
        "</soapenv:Body>" & _
    "</soapenv:Envelope>"

SoapRequest.Send DataToSend

If myXML.load(SoapRequest.responseXML) Then
    Dim Node
    Set Node = myXML.documentElement.selectSingleNode("//GreetResult")
    msgbox Node.Text

    Set Node = Nothing
End If

Set SoapRequest = Nothing
Set myXML = Nothing
Darin Dimitrov
+1  A: 

You might consider writing a bit of .NET wrapper code to consume the web service. Then expose the .NET code as a COM object that the ASP can call directly. As you've seen, there is no tooling to help you in classic ASP, so consider using as much .NET as possible, for the tooling. Then, use COM to interoperate between the two.

John Saunders
A: 

Might want to double-check the version of the MSXML components. Are you using Windows Authentication? I've noticed some odd XML parsing problems with IIS 7, Classic ASP, and MSXML.

It would also help to get a useful error. Check the ** myXML.parseError.errorCode** and if its not 0 write out the error.

Reference Code:

If (myXML.parseError.errorCode <> 0) then
    Response.Write "XML error: " & myXML.parseError.reason
Else
    'no error, do whatever here
End If
'You get the idea...
AnonJr
A: 
Zan