【问题标题】:Consuming SOAP Web Service with BinarySecurityToken using WCF, VB.NET and VS2015使用 WCF、VB.NET 和 VS2015 使用带有 BinarySecurityToken 的 SOAP Web 服务
【发布时间】:2015-12-22 19:59:00
【问题描述】:
祝你好运
我正在尝试使用 VB.NET 和 Framework 4.5 访问接收签名 XML 作为参数的 Web 服务方法。碰巧 Web 服务使用带有 BinarySecurityToken 模式的 WS-Authentication,我设法从 SOAP UI 生成了一个请求,它工作得很好,这是请求的 XML:
base64binary-Token
base64binary-DigestValue
base64 二进制签名值
这里是 CDATA 标记之间的 XML 数据
我已经做了很多研究,发现这可以使用 WCF“轻松”完成,但我可以完全找到这个 WCF 绑定是如何工作的,以及我必须如何传递我的 XML 数据以便可以将其包装到带有适当安全元素的 SOAP 信封主体。
我检查过的代码对我来说看起来非常复杂,因为只是使用基类,我可以弄清楚它的来源。我想生成代码以在不添加引用的情况下使用 WS,而是像这个人在这里所做的那样使用 http 请求:
http://www2.sys-con.com/ITSG/virtualcd/WebServices/archives/0208/thota/index.html
感谢您的帮助,并提前感谢您的帮助!
【问题讨论】:
标签:
vb.net
web-services
wcf
soap
【解决方案1】:
我没有意识到 XML 代码,所以,这里是 SOAP 消息 XML 代码
<soapenv:Envelope xmlns:dgi="http://dgi.gub.uy" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="X509-B1784C762113654DB514508130204461">base64binary-Token</wsse:BinarySecurityToken>
<ds:Signature Id="SIG-B1784C762113654DB514508130206685" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<ec:InclusiveNamespaces PrefixList="dgi soapenv" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:CanonicalizationMethod>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#id-B1784C762113654DB514508130206654">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<ec:InclusiveNamespaces PrefixList="dgi" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transform>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>base64binary-DigestValue</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>base64Binary-SignatureValue</ds:SignatureValue>
<ds:KeyInfo Id="KI-B1784C762113654DB514508130206312">
<wsse:SecurityTokenReference wsu:Id="STR-B1784C762113654DB514508130206463">
<wsse:Reference URI="#X509-B1784C762113654DB514508130204461" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature>
</wsse:Security>
</soapenv:Header>
<soapenv:Body wsu:Id="id-B1784C762113654DB514508130206654" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<dgi:WS_eFactura.EFACRECEPCIONSOBRE>
<dgi:Datain>
<dgi:xmlData>HERE GOES XML DATA BETWEEN CDATA TAGS</dgi:xmlData>
</dgi:Datain>
</dgi:WS_eFactura.EFACRECEPCIONSOBRE>
</soapenv:Body>
</soapenv:Envelope>