发送wsse:Security到Asp.net中的SOAP Header吗?

时间:2019-07-06 11:04:04

标签: c# asp.net web-services soap

我需要使用具有WSSE证书安全性的Web服务。提供的WSDL中没有编写任何SoapHeader。但是,我需要将WSSE证书安全性作为SoapHeader传递给它。我运行SoapUI,它可以工作。但是,我需要将此添加到我的Asp.net应用程序中。我需要将以下请求转换为C#代码。

SoapUI中的原始请求如下所示。 (为此,我必须遵循此链接https://www.soapui.org/soapui-projects/ws-security.html。我在SOAPUI中得到响应)

POST https://url/ServiceName HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "ServiceName_ws_providers_ServiceInfo_Binder_Service"
Content-Length: 4844
Host: IP address:Port
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:rop.gov.om:amms">
   <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">
       <ds:Signature Id="SIG-C78B85E81AA0000000000000000000000" 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="soapenv urn" 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-C78B85E81AA9A00000000000000000000"><ds:Transforms>
       <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
       <ec:InclusiveNamespaces PrefixList="urn" 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>viN9XK/xKiEkDkWkWkwksksksil=</ds:DigestValue></ds:Reference></ds:SignedInfo>
       <ds:SignatureValue>H0l3fczlZ7pFxrfshLWQ4Pf3br/d6Enslkjfklasdlkasdlkfjaskdjflksadjflkjasdlkflkajsd
        n7hZYByqR31obCXTq2R+khsPsdkjflkjsadlfkjasdklfjakdsjflksajdflkjasdlfkjam73uij
        Y4SALSKDFJAKSDFasdlkjflksajdlfkjasdlfkjalksdjlfkjasldkfjaskdjflkaKXYOD1waOwa
        gMIojoZC1nw/1WYxpU5azhasdlfkjaksdjflksajdlfkjasdlfkjalksdjflksjadlfkjasO5zMO
        khv+DaGsCZF3rPdGxV4ra6fox4BQgQWjzlPGdA==</ds:SignatureValue><ds:KeyInfo Id="KI-C78B85E81000000000000000000000000"><wsse:SecurityTokenReference wsu:Id="STR-C78B85E81AA0000000000000000000000">
        <wsse:KeyIdentifier 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">{some encrypted values here}</wsse:KeyIdentifier>
        </wsse:SecurityTokenReference></ds:KeyInfo></ds:Signature><wsu:Timestamp wsu:Id="TS-C78B85E81AA0000000000000000000000"><wsu:Created>2019-07-06T09:38:28.657Z</wsu:Created><wsu:Expires>2019-07-06T09:38:38.657Z</wsu:Expires></wsu:Timestamp></wsse:Security>
    </soapenv:Header>
   <soapenv:Body wsu:Id="id-C78B85E81AA0000000000000000000000" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
      ....Body goes here .....
   </soapenv:Body>
</soapenv:Envelope>

我浏览了这里和外部的不同文章,但是在使用Web服务时找不到任何足以帮助通过WSSecurity证书的文章。

如果不使用普通的Web服务,没有人知道如何在C#中生成此代码。

注意:我想将其生成为HTML,但是签名总是在变化。

0 个答案:

没有答案