需要帮助 - 使用.NET中的WS-Security Oasis进行Soap服务

时间:2016-08-02 12:18:19

标签: .net web-services soap ws-security oasis

我正在尝试创建要从客户端使用的服务。 它必须符合WS-Security Oasis标准,响应必须如下:

<soapenv:Envelope xmlns:ns="http://inti.notariado.org/XML" 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">
                    <wsu:Timestamp wsu:Id="TS-3E29AD5728CD9B921B14555351279296">
                        <wsu:Created>2016-02-15T11:18:47.928Z</wsu:Created>
                        <wsu:Expires>2016-02-15T11:23:47.928Z</wsu:Expires>
                    </wsu:Timestamp>
                    <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#X509PKIPathv1" 
                                              wsu:Id="X509-3E29AD5728CD9B921B14555351276791">MIIH6zCCB+cw...OMMITED...2lpK
                    </wsse:BinarySecurityToken>
                    <ds:Signature Id="SIG-3E29AD5728CD9B921B14555351277955" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                        <ds:SignedInfo>
                            <ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
                            <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
                            <ds:Reference URI="#id-3E29AD5728CD9B921B14555351277904">
                                <ds:Transforms>
                                    <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                        <InclusiveNamespaces PrefixList="ns" xmlns="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>jBhSy8vJGQtkVx9ok+aiLklTMaU=</ds:DigestValue>
                            </ds:Reference>
                        </ds:SignedInfo>
                        <ds:SignatureValue>ui...OMMITED...eLzGcWA==
                        </ds:SignatureValue>
                        <ds:KeyInfo Id="KI-3E29AD5728CD9B921B14555351277502">
                            <wsse:SecurityTokenReference wsse11:TokenType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509PKIPathv1" 
                                                         wsu:Id="STR-3E29AD5728CD9B921B14555351277533" 
                                                         xmlns:wsse11="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd">
                                                         <wsse:Reference URI="#X509-3E29AD5728CD9B921B14555351276791" 
                                                         ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509PKIPathv1"/>
                            </wsse:SecurityTokenReference>
                        </ds:KeyInfo>
                    </ds:Signature>
    </wsse:Security>
    <ns:SERVICE_DISPATCHER>
        <ns:TIMESTAMP>2008-09-29T03:49:45</ns:TIMESTAMP>
        <ns:TIPO_MSJ>1</ns:TIPO_MSJ>
        <ns:EMISOR>TEST</ns:EMISOR>
        <ns:RECEP>CGN</ns:RECEP>
        <!--Optional:-->
        <ns:SERVICIO>CTREEF</ns:SERVICIO>
        </ns:SERVICE_DISPATCHER>
</soapenv:Header>
<soapenv:Body wsu:Id="id-3E29AD5728CD9B921B14555351277904" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <ns:SERVICE_DISPATCHER_REQUEST>
        <con:ConsultaTitularidadRealRequest xmlns:con="http://ancert.notariado.org/XML/ConsultaTitularidadReal/Terceros">
            <con:TipoConsulta>EMPRESAS_ACTUAL</con:TipoConsulta>
            <con:TipoResultado>XML_PDF</con:TipoResultado>
            <con:DatosConsulta>
                <con:Identificacion>
                    <con:TipoDocumento>1</con:TipoDocumento>
                    <con:NumeroDocumento>N4361258I</con:NumeroDocumento>
                </con:Identificacion>
            </con:DatosConsulta>            
        </con:ConsultaTitularidadRealRequest>
    </ns:SERVICE_DISPATCHER_REQUEST>
</soapenv:Body>

我尝试使用WSE 3.0和WCF,但我总是陷入困境,无法找到有关如何保护服务的好教程。

所以问题是......什么是开发它的最佳方式?任何可以帮助我的好教程?我应该通过代码还是通过web.config来配置安全性?

提前致谢。

0 个答案:

没有答案