tcrite
tcrite

Reputation: 553

Classic ASP Consuming WCF Service through SSL with UserName Authentication

Let me start by saying I have never had any exposure until now with Classic ASP. I created a WCF service using basicHttpBinding with UserName authentication. The client said that the code below worked when he was testing it on NeoLoad, but when he put it on the IIS server he started to get a 400 bad request error. I've looked around and have been fighting this for 2 days now and I can't find an answer to this problem. Any help would be greatly appreciated and thanks in advance.

<%
   Dim SOAPResponse, SOAPRequest, serviceUrl, strResult

serviceUrl = ""
Response.Write "Creating XML Object<br>" & vbCrLf
Dim oXmlHTTP : Set oXmlHTTP = CreateObject("MSXML2.ServerXMLHTTP")

   SOAPRequest = "<?xml version=""1.0"" encoding=""UTF-8""?>"
   SOAPRequest = SOAPRequest & "<s:Envelope xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:u=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"">"
    SOAPRequest = SOAPRequest & "<s:Header>"
        SOAPRequest = SOAPRequest & "<o:Security s:mustUnderstand=""1"" xmlns:o=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"">"
            SOAPRequest = SOAPRequest & "<u:Timestamp u:Id=""_0"">"
                SOAPRequest = SOAPRequest & "<u:Created>2014-12-04T20:13:37.744Z</u:Created>"
                SOAPRequest = SOAPRequest & "<u:Expires>2014-12-04T20:18:37.744Z</u:Expires>"
            SOAPRequest = SOAPRequest & "</u:Timestamp>"
            SOAPRequest = SOAPRequest & "<o:UsernameToken u:Id=""UsernameToken-5"">"
                SOAPRequest = SOAPRequest & "<o:Username>"
                    SOAPRequest = SOAPRequest & ""
                SOAPRequest = SOAPRequest & "</o:Username>"
                SOAPRequest = SOAPRequest & "<o:Password>"
                    SOAPRequest = SOAPRequest & ""
                SOAPRequest = SOAPRequest & "</o:Password>"
            SOAPRequest = SOAPRequest & "</o:UsernameToken>"
        SOAPRequest = SOAPRequest & "</o:Security>"
        SOAPRequest = SOAPRequest & "<To s:mustUnderstand=""1"" xmlns=""http://schemas.microsoft.com/ws/2005/05/addressing/none"">""""</To>"
        SOAPRequest = SOAPRequest & "<Action s:mustUnderstand=""1"" xmlns=""http://schemas.microsoft.com/ws/2005/05/addressing/none"">""http://tempuri.org/ISLAServiceSandbox/SaveEntry""</Action>"
    SOAPRequest = SOAPRequest & "</s:Header>"
    SOAPRequest = SOAPRequest & "<s:Body>"
        SOAPRequest = SOAPRequest & "<SaveEntry xmlns=""http://tempuri.org/"">"
            SOAPRequest = SOAPRequest & "<request xmlns:a=""http://schemas.datacontract.org/2004/07/IDOI.Ams.Taxes.Web.Domain"" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"">"

            SOAPRequest = SOAPRequest & "</request>"
        SOAPRequest = SOAPRequest & "</SaveEntry>"
        SOAPRequest = SOAPRequest & "</s:Body>"
    SOAPRequest = SOAPRequest & "/s:Envelope>"

oXmlHTTP.Open "POST", serviceUrl, False 

oXmlHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8" 
oXmlHTTP.setRequestHeader "Content-Length", Len(SOAPRequest)
oXmlHTTP.setRequestHeader "SOAPAction", "http://tempuri.org//SaveEntry" 

'send the request and capture the result
Call oXmlHTTP.send(SOAPRequest)
Response.Write "Status: " & oXmlHTTP.Status & " - " & oXmlHTTP.statusText & "<br>" &    vbCrLf
Response.Write strResult
%>

<%= strResult %>

Upvotes: 1

Views: 180

Answers (1)

tcrite
tcrite

Reputation: 553

Okay so the consultant writing this code got it figured out. Turns out it was just a bit of misplaced code. Instead of

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"

It should have been

<s:Envelope xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/"

Thanks to anybody that spent any time looking at this.

Upvotes: 1

Related Questions