Progresos:
Con este código:
Código PHP:
require('soap-wsse.php');
define('CERT_FILE', './certificado.cer');
class mySoap extends SoapClient
{
function __doRequest($request, $location, $saction, $version)
{
$doc = new DOMDocument('1.0');
$doc->loadXML($request);
$objWSSE = new WSSESoap($doc);
/* Crear el objeto de seguridad, establece y carga la clave */
$objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array ('type'=>'public'));
$objKey->loadKey(CERT_FILE, TRUE, TRUE);
/* Firmamos el mensaje */
$objWSSE->signSoapDoc($objKey);
$token = $objWSSE->addBinaryToken($cert, $isPEMFormat=TRUE, $isDSig=TRUE);
$objWSSE->attachTokentoSig($token);
return parent::__doRequest($objWSSE->saveXML(), $location, $saction, $version);
}
}
$wsdl = 'DomOrder.wsdl';
// opciones de conexion
$options = array(
'location'=>'https://www.dominio.com/anacreon/servlet/APIv3',
'trace' => true,
);
$sClient = new mySoap($wsdl, $options);
$wrapper= new SoapVar("9300002", XSD_STRING);
try {
$result = $sClient->getDetailsByDomain(new SoapParam("username", "userName"),
new SoapParam("password", "password"),
new SoapParam("reseller", "role"),
new SoapParam("es", "langpref"),
new SoapParam("999999998","parentid"),
new SoapParam("directo.com", "domainName"),
new SoapParam(array("All"),"option"));
} catch (SoapFault $fault) {
echo '<pre>';
print_r($fault);
echo '</pre>';
}
Consigo generar este XML:
Código XML:
Ver original<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="com.logicboxes.foundation.sfnb.order.DomOrder" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" SOAP-ENV:mustUnderstand="1">
<wsse:BinarySecurityToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" wsu:Id="pfxf1a07b50-4deb-f107-2911-e09bd531634e" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3">
</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#"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#pfxf381aa98-ef47-f225-0d05-29da0a5d1060">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>2jmj7l5rSw0yVb/vlWAYkK/YBwk=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue></ds:SignatureValue>
<ds:KeyInfo>
<wsse:SecurityTokenReference>
<wsse:Reference URI="#pfxf1a07b50-4deb-f107-2911-e09bd531634e"/>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="pfxf381aa98-ef47-f225-0d05-29da0a5d1060">
.................
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Se supone que está todo correcto menos "<ds:SignatureValue></ds:SignatureValue>" que no consigo llenarlo porque me salen los Warnings:
Warning: openssl_sign() [function.openssl-sign]: supplied key param is a public key in /web/WSF/xmlseclibs2010.php on line 452
Warning: openssl_sign() [function.openssl-sign]: supplied key param cannot be coerced into a private key in /web/WSF/xmlseclibs2010.php on line 452
Poniendo que se trata de un certificado y su clave es pública consigo generar el XML pero sin "<ds:SignatureValue></ds:SignatureValue>".
Ya te digo que no puedo probarlo contra el WS, pero no tiene mala pinta.
Sigo trabajando....
Saludos