Hola
Bien, vamos avanzando...
He conseguido añadir una cabecera a la petición, y gracias al evento BeforeExecute, puedo ver que efectivamente ahora el XML sí tiene sección cabecera:
Código:
<SOAP-ENV:Header SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:NS1="urn:Soap.InvokeRegistry">
<NS1:TSOAPHeader xsi:type="NS1:TSOAPHeader"/>
Casi lloro.
Bien. Yo lo he hecho de otra forma, no sé si ves algún problema:
Código Delphi
[-]
procedure TForm1.Button2Click(Sender: TObject);
var facturasspp : SSPPFactura;
fichero_fac : SSPPFicheroFactura;
answ : SSPPResultadoEnviarFactura;
PO:SSPPWebServiceProxyPort;
htpr: THTTPRIO;
sphdr: TSOAPHEADER;
ws: SSPPWebServiceProxyPort;
begin
if opendialog1.Execute then
begin
sphdr := TSOAPHEADER.create;
PO := GetSSPPWebServiceProxyPort(FALSE, '', nil);
facturasspp := ssppfactura.Create;
facturasspp.correo := 'prueba@miemail.com';
fichero_fac := ssppficherofactura.Create;
fichero_fac.nombre := extractfilename(opendialog1.FileName);
fichero_fac.factura := '72345';
fichero_fac.mime := 'application/xml';
facturasspp.fichero_factura := fichero_fac;
HTTPRIO1.SOAPHeaders.Send(sphdr);
try
answ := (HTTPRIO1 as SSPPWebServiceProxyPort).enviarFactura(facturasspp);
except
on e:exception do showmessage(e.Message);
end;
end;
end;
Tu código es diferente, creo que utilizas un XMLDocument que contendría las cabeceras ya rellenadas?
Ahora lo complicado es
cómo meter el mensaje FIRMADO en la cabecera... ¿A mano?
Por ejemplo, en la petición SOAP que uso para pruebas, el body es este:
Código:
<SOAP-ENV:Body xmlns:NS2="https://webservice.face.gob.es" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<NS2:enviarFactura>
<facturaWS href="#2"/>
</NS2:enviarFactura>
<NS2:SSPPFactura id="2" xsi:type="NS2:SSPPFactura">
<correo xsi:type="xsd:string">prueba@miemail.com</correo>
<fichero_factura href="#3"/>
<ficheros_anexos xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="NS2:SSPPFicheroAnexo[0]"/>
</NS2:SSPPFactura>
<NS2:fichero_factura id="3" xsi:type="NS2:SSPPFicheroFactura">
<factura xsi:type="xsd:string">72345</factura>
<nombre xsi:type="xsd:string">Factura 177.xml</nombre>
<mime xsi:type="xsd:string">application/xml</mime>
</NS2:fichero_factura>
Cómo se "firma" ese trozo de texto?
Aquí tengo una muestra de petición "REAL" sacada de la documentación, que debería servirnos como ejemplo, aunque a estas alturas ya dudo de lo que puede servir y lo que no.
Le he quitado la parte de los ficheros anexos (por ahora) para simplificarlo un poco.
Código:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="https://webservice.face.gob.es">
<soapenv:Header>
<!-- // Security Content -->
</soapenv:Header>
<soapenv:Body>
<web:enviarFactura soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<facturaWS xsi:type="sspp:SSPPFactura">
<!--You may enter the following 3 items in any order-->
<correo xsi:type="xsd:string">XXXX correo electronicoXXXX</correo>
<fichero_factura xsi:type="sspp:SSPPFicheroFactura">
<!--You may enter the following 3 items in any order-->
<factura xsi:type="xsd:string"> _contenido enbase_64 del fichero factura_ </factura>
<nombre xsi:type="xsd:string"> _nombre del ficherofactura_ </nombre>
<mime xsi:type="xsd:string"> _mimeType del ficherofactura_ </mime>
</fichero_factura>
</facturaWS>
</web:enviarFactura>
</soapenv:Body>
</soapenv:Envelope>
Y el ejemplo de Security-Content que pone en la documentación es este (lo que va dentro del header):
Código:
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-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="CertId-5A5C126069B253F2B0135998798458616" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
MIIEpDCCBA2gAwIBAgIEPLPTKTANBgkqhkiG9w0BAQUFADA2MQswCQYDVQQGEwJFUzENMAsGA1UEChMERk5NVDEYMBYGA1UECxMPRk5NVCBDbGFzZSAyIENBMB4XDTALS6PmAJWFoOUT3Xvp8UxYptb9/YK93ykPj5NYLcsXeh8L9SRWbFSnozoiATZoECDnrcMd054DdPrNVYLTZNhZ9Y2U9JqJpnIWR+a64Mo3iiMk/KBkI2jo3QIuaCjvPK+k6LQCwTIaRvnHGRxwIDAQABo4IB1DCCAdAwgdgGA1UdEQSB0DCBzaSByjCBxzEYMBYGCSsGAQQBrGYBDxMJUzI4MjYwMTVGMUMwQQYJKwYBBAGsZgEOEzRJTlRFUlZFVc9fS1I6qgUkmwCZKHiwgJ4tS1Mv3gKMZ+8ulc8JErYo661ql3GVmLsfdH5g3eWyC5rBEcCjkHSKO0qDhzg==
</wsse:BinarySecurityToken>
<ds:Signature Id="Signature-11" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethodAlgorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#id-12">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethodAlgorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>vfoQe7yobzrB5LzQZ/HD4B2F1BY=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>
HOZFzxAsMAH8BDbuXOHekl+yyLXfodmPka5727t3LDFSkbxICkL92wy6dSbWyU07zK/dhfLl2a4c
33FcvOxAtYAEvQVRLcQM3VU9+L2SX9NReQaGTPPmtBb8UAWeH5m56nM9uxT7yIwfO424+lNEYEeo
1pYC+0DBI6WcN4LRgV4=
</ds:SignatureValue>
<ds:KeyInfo Id="KeyId-5A5C126069B253F2B0135998798458717">
<wsse:SecurityTokenReference wsu:Id="STRId-5A5C126069B253F2B0135998798458718"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:ReferenceURI="#CertId-5A5C126069B253F2B0135998798458616"
ValueType="http://docs.oasis-open.org/wss/2004/01/
oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature>
<wsu:Timestamp wsu:Id="Timestamp-10" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsu:Created>2013-02-04T14:26:24.586Z</wsu:Created>
<wsu:Expires>2013-02-04T14:31:24.586Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
Los componentes de SecureBlackBox permiten firmar peticiones SOAP usando certificados de diferentes tipos, y añaden la sección security al header, PERO no de la misma forma que en este ejemplo. Además, estaría bien saber si es posible hacerlo sin dichos componentes, ya que hay muchos usuarios que no los utilizan.