Discussion:
digital signature and SOAP
(too old to reply)
shawrie
2010-03-17 19:24:04 UTC
Permalink
hello
i have to write an application that sends requests using soap/xml to a
web service. The company that hosts the web service requires to be
digtally signed. They have sent me the example file
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<wsse:Security
xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext">
<wsse:BinarySecurityToken valueType="wsse:X509v3"
encodingType="wsse:Base64Binary" id="X509Token">
MIIEZzCcA9cgwaABQfd86afd2g...
</wsse:BinarySecurityToken>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod>
Algorithm="http://www.w3.org/2001/10/xml-enc-c14n#"/>
</ds:CanonicalizationMethod>
<ds:SignatureMethod Algorithm="
http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#MsgBody">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xmlexc-
c14n#"/>
</ds:Transforms>
<ds:DigestMethod
Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>DJbchm5gk...</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>LyLsF0pi4wPu...</ds:SignatureValue>
<ds:KeyInfo>
<wsse:SecurityTokenReference>
<wsse:Reference URI="#X509Token"/>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature>
</wsse:Security>
</soap:Header>
<soap:Body id="MsgBody">
<mcr:MailboxCollectRequest
xmlns:mcr="http://www.ros.ie/schemas/customs/collectrequest/v1"/>
</soap:Body>
</soap:Envelope

can someone tell me how i am supposed to digtally sign it and what the
BinarySecurityToken is and worked out??

thanks
Peter
2010-04-02 19:52:01 UTC
Permalink
I can't directly answer your question, but here's an app in .vbs ( VBScript )
that works for my use. sensitive info replaced by ellipses.

Dim sURL, sCookie, oHttp, strRequest
strRequest = ""
strRequest = "<?xml version='1.0' encoding='UTF-8'?>"
strRequest = strRequest & "<SOAP-ENV:Envelope "
strRequest = strRequest &
"xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' "
strRequest = strRequest &
"xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' "
strRequest = strRequest &
"xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"
strRequest = strRequest & "<SOAP-ENV:Body><ns1:...Info
xmlns:ns1='http://tempu...your...WebServiceAction'>"
strRequest = strRequest & "<xmlRequest
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:type='xsd:string'>"
strRequest = strRequest & "<...ServicesRequest marketid='1'
language='ENG' country='USA'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:noNamespaceSchemaLocation='...Services.xsd'>"
strRequest = strRequest & "<...fields...> "
strRequest = strRequest & "<...field... id='214585'/>"
strRequest = strRequest & "<...field... id='B56530'/>"
strRequest = strRequest & "</...fields...>"
strRequest = strRequest & "<ServiceRequests>"
strRequest = strRequest & "<...Service>"
strRequest = strRequest & "<Attribute typeid='14'
type='...attr1...'/>"
strRequest = strRequest & "<Attribute typeid='1' type='...attr2...'/>"
strRequest = strRequest & "<Attribute typeid='2' type='...attr3...'/>"
strRequest = strRequest & "</...Service> "
strRequest = strRequest & "</ServiceRequests> "
strRequest = strRequest & "</...ServicesRequest> "
strRequest = strRequest & "</xmlRequest>"
strRequest = strRequest & "</ns1:...Info>"
strRequest = strRequest & "</SOAP-ENV:Body>"
strRequest = strRequest & "</SOAP-ENV:Envelope>"

sURL = "https://web...address...serviceservlet"
sCookie = "WSLX-credential=Sjo2...ZI0Q"

Set oHttp = CreateObject("WinHttp.WinHttpRequest.5.1")

Call oHttp.open("POST", sURL, false)
oHTTP.setRequestHeader "Cookie", sCookie
oHTTP.setRequestHeader "Content-type", "text/xml"
Call oHttp.send (strRequest)
oHTTP.WaitForResponse(5)

msgbox oHTTP.GetAllResponseHeaders()
msgbox "Status: " & oHttp.Status
msgbox "StatusText: " & oHttp.StatusText
msgbox oHttp.ResponseText

Loading...