Search This Blog

Thursday, March 10, 2016

How to call WCF service from classic ASP

DIM xmlhttp, response, objRequest, txtRequest, test
DIM url : url = "http://www.example.com/Services/Service1.svc"



txtRequest = "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:tem=""http://tempuri.org/"">" & _
        "<soapenv:Header/>" & _
        "<soapenv:Body>" & _
          "<tem:GetVehicleStatus>" & _
            "<tem:OrgId>111</tem:OrgId>" & _
            "<tem:VehicleId>555</tem:VehicleId>" & _
          "</tem:GetVehicleStatus>" & _
        "</soapenv:Body>" & _
      "</soapenv:Envelope>"

set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")

'xmlhttp.setOption 2, 13056 'ignore certificate errors for development machines
xmlhttp.open "POST", url, false
xmlhttp.setRequestHeader "Content-Type", "text/xml;charset=UTF-8"
xmlhttp.setRequestHeader "SOAPAction", "http://tempuri.org/Services/GetVehicleStatus"
xmlhttp.send txtRequest
response = xmlhttp.responseText
Response.Write (xmlhttp.status& ":::"& xmlhttp.statusText) & "response:::"& response