| |
geja_myzone3
Posts: 1
Score: 0
Joined: 6/30/2008
Status: offline
|
Im a beginner in vbscript programming. Im writing client code using vbscript to consume a secured webservice with signature and certificate authentication. I have given the sample code below which I tried. and Im getting "there is no webservice matching the incoming request" as soap fault. Can anyone help me to reslove this issue and let me know how well the vbscript supports webservice security. Dim crypt,certStore,success,cert set crypt = CreateObject("Chilkat.Crypt2") success = crypt.UnlockComponent("30-day trial") If (success <> 1) Then MsgBox "Crypt component unlock failed" WScript.Quit End If set certStore = CreateObject("Chilkat.CertStore") success = certStore.LoadPfxFile("TESTCERT.pfx","pass1") If (success <> 1) Then MsgBox certStore.LastErrorText WScript.Quit End If Set cert = certStore.FindCertBySubjectCN("CLIENTCERT") If (cert Is Nothing ) Then MsgBox certStore.LastErrorText WScript.Quit End If crypt.SetSigningCert cert hashValue = crypt.HashStringENC("true") signValue = crypt.SignStringENC("true") Dim soapStr Set xDoc = CreateObject("MSXML2.DOMDocument") soapStr = "<soapenv:Envelope " soapStr = soapStr & "xmlns:SOAP-SEC=""http://schemas.xmlsoap.org/ws/2002/07/utility"" " soapStr = soapStr & "xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" " soapStr = soapStr & "xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" " soapStr = soapStr & "xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" " soapStr = soapStr & "<soapenv:Header>" soapStr = soapStr & "<wsse:Security soapenv:actor=""http://schemas.xmlsoap.org/soap/actor/next"" " soapStr = soapStr & "soapenv:mustUnderstand=""0"" " soapStr = soapStr & "xmlns:wsse=""http://schemas.xmlsoap.org/ws/2002/07/secext"">" soapStr = soapStr & "<wsse:UsernameToken><wsse:Username>TEST1</wsse:Username>" soapStr = soapStr & "<wsse:Password>pass1</wsse:Password></wsse:UsernameToken>" soapStr = soapStr & "<ds:Signature xmlns:ds=""http://www.w3.org/2000/09/xmldsig#"">" soapStr = soapStr & "<ds:SignedInfo>" soapStr = soapStr & "<ds:CanonicalizationMethod Algorithm=""http://www.w3.org/TR/2001/REC-xml-c14n-20010315""/>" soapStr = soapStr & "<ds:SignatureMethod Algorithm=""http://www.w3.org/2000/09/xmldsig#rsa-sha1""/>" soapStr = soapStr & "<ds:Reference URI=""#Body"">" soapStr = soapStr & "<ds:DigestMethod Algorithm=""http://www.w3.org/2000/09/xmldsig#sha1""/>" soapStr = soapStr & "<ds:DigestValue> & hashValue & </ds:DigestValue>" soapStr = soapStr & "</ds:Reference>" soapStr = soapStr & "</ds:SignedInfo>" soapStr = soapStr & "<ds:SignatureValue> & signValue & </ds:SignatureValue>" soapStr = soapStr & "</ds:Signature></wsse:Security></soapenv:Header>" soapStr = soapStr & "<soapenv:Body soapenv:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"" Id=""Body"">" soapStr = soapStr & "<tns:test>" soapStr = soapStr & "<string>Testing</string>" soapStr = soapStr & "</tns:test>" soapStr = soapStr & "</soapenv:Body></soapenv:Envelope>" xDoc.loadXML(soapStr) MsgBox xDoc.xml Set xmlhttp = CreateObject("WinHttp.WinHttpRequest.5.1") Set xmlDoc = CreateObject("MSXML2.DOMDocument") xmlhttp.Open "POST", "https://server1/example/service", False xmlhttp.SetClientCertificate "LOCAL_MACHINE\My\CLIENTCERT" xmlhttp.SetCredentials "TEST1","pass",0 xmlhttp.Option(4) = 256 + 512 + 4096 + 8192 xmlhttp.SetRequestHeader "content-Type", "text/xml" xmlhttp.Send soapStr xmlDoc.loadXML (xmlhttp.ResponseText) MsgBox xmlhttp.StatusText & ": " & xmlhttp.Status MsgBox(xmlDoc.xml) xmlDoc.save("test.xml") Thanks geja
|
|