Usuario
Problemas al Firmar mensaje soap

Pregunta
-
Buenas, estoy tratando consumir un servicio implementado en java que usa WS-Security con certificados, el ciente que lo estamos desarrollando con C#, el mensaje soap que estamos generando es el siguiente :
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <s:Header> <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <u:Timestamp u:Id="uuid-70fa956a-79e6-40ad-9dae-b1f36af54aeb-1"> <u:Created xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2016-05-17T14:54:20.388Z</u:Created> <u:Expires xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2016-05-17T14:59:20.388Z</u:Expires> </u:Timestamp> <o: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" u:Id="uuid-c37649a8-4c4e-4bf2-bb6c-16db3d4df1be-3">MIIDAzCCAeugAwIBAgIIbCNhR7KQ96QwDQYJKoZIhvcNAQEFBQAwNzERMA8GA1UEAwwIQWRtaW5DQTExFTATBgNVBAoMDEVKQkNBIFNhbXBsZTELMAkGA1UEBhMCU0UwHhcNMTUxMjE2MTYwMDQ3WhcNMTgxMjIwMTQzNzEzWjBPMRIwEAYDVQQDDAk4MDA2Nzg3MTAxCzAJBgNVBAsMAlRJMR8wHQYDVQQKDBZTb2x1Y2lvbiBMb2dpc3RpY2EgUy5BMQswCQYDVQQGEwJQWTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAvuNaeRcGNKrh/935lyideBxTQw4mmA0SpNtblbutwzs0BxxlOl3kIrHYUVt5OgCgpuVDkxg0nI4WzMOrgCa+hcaiJftuR+Y4eyu0oKZBmNxaLgux7thtlK29iGrLu7wTATvkpCneaVlqiudicBeFu5RRVA8sdUfbZlPWxYxZM4ECAwEAAaN/MH0wHQYDVR0OBBYEFAKAO02QJ5XdebL4yxkJ3Nc6rb7NMAwGA1UdEwEB/wQCMAAwHwYDVR0jBBgwFoAUMX7WE5J2CDYMU5Sh+edd3H1PGN4wDgYDVR0PAQH/BAQDAgTwMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjANBgkqhkiG9w0BAQUFAAOCAQEACsnUf6I0sdkYaMgT8SO1TGn/mxdhrf40tzfmuT0Ur8UHfpKD/WMHzxIkR7Xr9zilj2f/PMVb1vFDLjLAD4PBGFv37khWRP+t+27iRoixtSSlo54pMKKA/UFeOTu5oPYimDIMNy/JKG6+XIZafNR5ql8hZbfZ2V0EgiMcRZdytzdyy8SKJhiYeFqDtG/xd0Kd6bg14X+R1fWbAbzf9RepBepnM0aTS/0DvB0GBR/WWci+2oCNbfc0BcZvTY+of9l4kk6shn2k9rB1Yj+uR7XopCvDBRQVYqkhUUnMqFAA1d+LuoLnHE9kwVMTXV5b/oSsvOQNI9doATzWqXyh3Ld6qA==</o:BinarySecurityToken> <Signature xmlns="http://www.w3.org/2000/09/xmldsig#"> <SignedInfo> <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></CanonicalizationMethod> <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></SignatureMethod> <Reference URI="#uuid-70fa956a-79e6-40ad-9dae-b1f36af54aeb-1"> <Transforms> <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></Transform> </Transforms> <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod> <DigestValue>2b2dWswyJROqtzIV3gQO6jt5rQc=</DigestValue> </Reference> </SignedInfo> <SignatureValue>dB2xCxwiu2nvZgLT6S8lnhCNuN6whSpkpxB1l+exUPVnir1+ra4VI6XB/uceSE6s6wKAM7TlrS+zT5+ALQcSbW3QiV6lTtCU3Cf5x0tHIMzCVyGWMZBIHdARw1CIBpuZdYpTfYuklICoKw0G7J8dYZtOEdNXH/jGbZvZmHz/QV4=</SignatureValue> <KeyInfo> <o:SecurityTokenReference xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <o:Reference URI="#uuid-c37649a8-4c4e-4bf2-bb6c-16db3d4df1be-3" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"></o:Reference> </o:SecurityTokenReference> </KeyInfo> </Signature> </o:Security> </s:Header> <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <consultarManifiesto xmlns="http://aduana.gov.py/webservices"> <idManifiesto xmlns=""> <fechaIngreso>20160517105419</fechaIngreso> <manifiesto>16704MANI000462A</manifiesto> <nroExpActa></nroExpActa> <prefijo>030</prefijo> <titulo>704-147852</titulo> </idManifiesto> <autenticacion xmlns=""> <codAduana>030</codAduana> <firma>LblLx13u680NCsQkTOXkC2iBU90gNuo/yh588U5zkwg5ZpNJ5a53ZLwCPI8bXh4sTQi7S9iwpynPPgWZqxgV4u3zM4VZHYonjRHo+Dma/TP/45a7OEGQdR56RMC45acMeElwtYxvdldzic1ldafZ1VwyLgxB+GxbWz7Lhtj9WNw=</firma> <token>CjxhdXRoPgoJPGlkIHVuaXF1ZV9pZD0iOTA3MDY5NjQ5IiBzcmM9IkM9cHksIE89ZG5hLCBPVT1zb2ZpYSwgQ049d3NhYXRlc3QiIGdlbl90aW1lPSIyMDE2LTA1LTE3VDEwOjU0OjE4LjE4OS0wNDowMCIgZXhwX3RpbWU9IjIwMTYtMDUtMTdUMTA6NTQ6MTguMTg5LTA0OjAwIi8+Cgk8b3BlcmF0aW9uIHZhbHVlPSJncmFudGVkIiB0eXBlPSJsb2dpbiI+CgkJPGxvZ2luIHVpZD0iQz1QWSwgTz1Tb2x1Y2lvbiBMb2dpc3RpY2EgUy5BLCBPVT1USSwgQ049ODAwNjc4NzEwIiBzZXJ2aWNlPSJzZXJ2aWNpb3B1ZXJ0byIgYXV0aG1ldGhvZD0iY21zIj4KCQk8L2xvZ2luPgoJPC9vcGVyYXRpb24+CjwvYXV0aD4K</token> <usuario>slogistica</usuario> </autenticacion> </consultarManifiesto> </s:Body> </s:Envelope>
Y la respuesta que recibimos es del servicio es :
System.ServiceModel.FaultException: org.jboss.ws.core.CommonSOAPFaultException: Required element did not contain a wsu:id.
Consultando con los responsables nos dice que el formato correcto del mensaje SOAP debería ser el siguiente:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Header> <wsse:Security env:mustUnderstand="1" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" 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="timestamp"> <wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2016-05-17T20:22:07.240Z</wsu:Created> </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#X509v3" wsu:Id="token-5783-1463516527601-8788113">MIIC6jCCAdKgAwIBAgIIBOg5f3kzz4wwDQYJKoZIhvcNAQEFBQAwLzESMBAGA1UEAwwJRE5BUm9v dENBMQwwCgYDVQQKDANETkExCzAJBgNVBAYTAlBZMB4XDTE0MDUwNTIwNDI1MVoXDTE4MTEwODEy </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-exc-c14n#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"></ds:CanonicalizationMethod> <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"></ds:SignatureMethod> <ds:Reference URI="#element-5782-1463516527243-26451062" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <ds:Transforms xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"></ds:Transform> </ds:Transforms> <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"></ds:DigestMethod> <ds:DigestValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#">oZrRPtPGHZtSPjZGUTMCVrC7L08=</ds:DigestValue> </ds:Reference> <ds:Reference URI="#timestamp" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <ds:Transforms xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"></ds:Transform> </ds:Transforms> <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"></ds:DigestMethod> <ds:DigestValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#">gzQOs2IOAmfthX9PKCunzCgI7+0=</ds:DigestValue> </ds:Reference> </ds:SignedInfo> <ds:SignatureValue> rFgSSYdLGLEYF8UqH9K3ijO3vhkNC0uLWE02V0x99a/qAzUkeXK/XTqiN9A4dov9JdNZg1fBw+N/ P8UZzpGkuGP/VSgwDOKCF55ENAxJzwWbSWh78oCOjX2G1i07QGRtx2wqbccGa8ScLB1C9hqc0ONy 2ATwBz2gIVjY7eUr2PI= </ds:SignatureValue> <ds:KeyInfo> <wsse:SecurityTokenReference wsu:Id="reference-5784-1463516527601-28775784" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:Reference URI="#token-5783-1463516527601-8788113" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"></wsse:Reference> </wsse:SecurityTokenReference> </ds:KeyInfo> </ds:Signature> </wsse:Security> </env:Header> <env:Body wsu:Id="element-5782-1463516527243-26451062" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <ns1:consultarManifiesto xmlns:ns1="http://aduana.gov.py/webservices"> <idManifiesto> <manifiesto>16002MANI006850V</manifiesto> <prefijo>COU</prefijo> <titulo>6432877651</titulo> </idManifiesto> <autenticacion> <codAduana>002</codAduana> <firma>j3zbKkUaGbyaVNeDoKEU5ruMCS3DeWRdC+M/nU+noyQ3/bQ7FqSW4hbmPDTFnY8egyCJfleMIawUTr7Ti2kOcdR40dYwpXB804Arbfi+GwkR4ra2tWcte0rhMyU+OMLw3sR511dFOTHZNi+St1LlkxHoXweaZwi/avKOnwOy5GU=</firma> <token>CjxhdXRoPgoJPGlkIHVuaXF1ZV9pZD0iMTQ2MzUxNjUyNyIgc3JjPSJDPXB5LCBPPWFkdWFuYSwgT1U9c29maWEsIENOPXdzYWEiIGdlbl90aW1lPSIyMDE2LTA1LTE3VDE2OjIyOjA3LjA4NC0wNDowMCIgZXhwX3RpbWU9IjIwMTYtMDUtMTdUMTc6MjI6MDcuMDg0LTA0OjAwIi8+Cgk8b3BlcmF0aW9uIHZhbHVlPSJncmFudGVkIiB0eXBlPSJsb2dpbiI+CgkJPGxvZ2luIHVpZD0iQz1QWSwgTz1BRFVBTkEsIE9VPVNPRklBLCBDTj1kaW5hYyIgc2VydmljZT0ic2VydmljaW9wdWVydG8iIGF1dGhtZXRob2Q9ImNtcyI+CgkJPC9sb2dpbj4KCTwvb3BlcmF0aW9uPgo8L2F1dGg+Cg==</token> <usuario>dinac</usuario> </autenticacion> </ns1:consultarManifiesto> </env:Body> </env:Envelope>
Alguna idea de que se deberia hacer para lograr el formato correcto del mensaje SOAP?
la configuracion del web.config
es la sigueinte:
<endpoint name="serviciodepositoSoap" address="https://secure.aduana.gov.py/test/sgd/serviciodeposito" binding="customBinding" bindingConfiguration="serviciodepositoSoapBinding" contract="ServicioDeposito.serviciodepositoSoap" behaviorConfiguration="endpointCredentialsBehaviors" > <identity> <dns value="800678710"/> </identity> </endpoint> <customBinding> <binding name="serviciodepositoSoapBinding"> <textMessageEncoding messageVersion="Soap11"/> <security authenticationMode="MutualCertificate" allowSerializedSigningTokenOnReply="true" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" includeTimestamp="true"> </security> <httpsTransport/> </binding> </customBinding> <webServices> <soapExtensionTypes> <add type="Microsoft.Web.Services3.WebServicesClientProtocol, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" priority="1" group="High"/> </soapExtensionTypes> </webServices>
- Editado Martin Rivas miércoles, 7 de diciembre de 2016 19:03