简体   繁体   English

通过带有用户名身份验证的SSL的经典ASP消费WCF服务

[英]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. 首先,我要说的是到目前为止,我从未接触过Classic ASP。 I created a WCF service using basicHttpBinding with UserName authentication. 我使用basicHttpBinding和UserName身份验证创建了WCF服务。 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. 客户端说,下面的代码在他在NeoLoad上测试时起作用,但是当他将它放在IIS服务器上时,他开始遇到400错误的请求错误。 I've looked around and have been fighting this for 2 days now and I can't find an answer to this problem. 我环顾四周,现在已经战斗了2天,但找不到这个问题的答案。 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 %>

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. 感谢任何花时间研究此问题的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM