natalina
Новичок
Здравствуйте! Проблема такая, вот мой скрипт soap-клиента
$url = "https://path_to.wsdl";
$user_id = '123456';
$func = 'TrCreate';
$firma = '654';
$xml = "<?xml version=\"1.0\" encoding=\"windows-1251\" ?><request></request>"; // TrCreate
$key = file_get_contents($user_id.".key");
$cert = file_get_contents($user_id.".crt");
$pkeyid = openssl_pkey_get_private($key);
//$pcertid = openssl_pkey_get_public($cert);
// compute signature
openssl_sign($xml, $signatureKey, $pkeyid);
// free the key from memory
openssl_free_key($pkeyid);
$reqbufb64 = base64_encode($signatureKey);
$signb64 = base64_encode($cert);
$client = new SoapClient($url, array(
"exceptions"=>0,"trace" => 1, "encoding" => "utf-8","cache_wsdl" => WSDL_CACHE_NONE));
$parm = array();
$parm[] = new SoapVar($user_id, XSD_STRING, null, null, 'USER-ID' );
$parm[] = new SoapVar($func, XSD_STRING, null, null, 'FUNC' );
$parm[] = new SoapVar($firma, XSD_STRING, null, null, 'FIRMA' );
$parm[] = new SoapVar($reqbufb64, XSD_STRING, null, null, 'REQBUFB64' );
$parm[] = new SoapVar($signb64, XSD_STRING, null, null, 'SIGNB64' );
$client->__soapCall('WSDLVEGA',
array(
new SoapParam($user_id, "a"),
new SoapParam($func, "b"),
new SoapParam($firma, "c"),
new SoapParam($reqbufb64, "d"),
new SoapParam($signb64, "e"),
),
array('soapaction' => 'WSDLVEGA'));
echo 'Запрос<br/>';
echo '<pre>'.htmlspecialchars($client->__getLastRequest()).'</pre><br/>';
echo 'Ответ<br/>';
echo htmlspecialchars($client->__getLastResponse()).'<br/>';
echo '<br/>';
запрос сейчас он формирует такой
<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:com-softwareag-entirex-rpc:CSS-BASE" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <ns1:WSDLVEGA> <USER-ID xsi:type="xsd:string">123456</USER-ID> <FUNC xsi:type="xsd:string">TrCreate</FUNC> <FIRMA xsi:type="xsd:string">654</FIRMA> <REQBUFB64 xsi:type="xsd:string">s4qMp7gFX/6QxNbStEK1mqzrYWgq+8ECUnCQVNU=</REQBUFB64> <SIGNB64 xsi:type="xsd:string">Q2VydGlmZDY6OmNmOjdkOUxUkxNk1ERVNnbm92R0lqZSsKZkdKSlhSdz0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo= </SIGNB64> <W3VALUE xsi:nil="true"/> </ns1:WSDLVEGA></SOAP-ENV:Body></SOAP-ENV:Envelope>
а мне нужна вот такая структура
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xmm="http://namespace.softwareag.com/entirex/xml/mapping"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:WSDLVEGA xmlns:m="urn:com-softwareag-entirex-rpc:CSS-BASE-WSDLVEGA">
<USER-ID>123456</USER-ID>
<FUNC>TrCreate</FUNC>
<FIRMA>654</FIRMA>
<REQBUFB64>6QxNbStEK1mqzrYWgq+8ECUnCQVNU=</REQBUFB64>
<SIGNB64>LS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=</</SIGNB64>
</m: WSDLVEGA>
</SOAP-ENV:Body></SOAP-ENV:Envelope>
Подскажите пожалуйста, как такое можно сделать или какая есть альтернатива?
$url = "https://path_to.wsdl";
$user_id = '123456';
$func = 'TrCreate';
$firma = '654';
$xml = "<?xml version=\"1.0\" encoding=\"windows-1251\" ?><request></request>"; // TrCreate
$key = file_get_contents($user_id.".key");
$cert = file_get_contents($user_id.".crt");
$pkeyid = openssl_pkey_get_private($key);
//$pcertid = openssl_pkey_get_public($cert);
// compute signature
openssl_sign($xml, $signatureKey, $pkeyid);
// free the key from memory
openssl_free_key($pkeyid);
$reqbufb64 = base64_encode($signatureKey);
$signb64 = base64_encode($cert);
$client = new SoapClient($url, array(
"exceptions"=>0,"trace" => 1, "encoding" => "utf-8","cache_wsdl" => WSDL_CACHE_NONE));
$parm = array();
$parm[] = new SoapVar($user_id, XSD_STRING, null, null, 'USER-ID' );
$parm[] = new SoapVar($func, XSD_STRING, null, null, 'FUNC' );
$parm[] = new SoapVar($firma, XSD_STRING, null, null, 'FIRMA' );
$parm[] = new SoapVar($reqbufb64, XSD_STRING, null, null, 'REQBUFB64' );
$parm[] = new SoapVar($signb64, XSD_STRING, null, null, 'SIGNB64' );
$client->__soapCall('WSDLVEGA',
array(
new SoapParam($user_id, "a"),
new SoapParam($func, "b"),
new SoapParam($firma, "c"),
new SoapParam($reqbufb64, "d"),
new SoapParam($signb64, "e"),
),
array('soapaction' => 'WSDLVEGA'));
echo 'Запрос<br/>';
echo '<pre>'.htmlspecialchars($client->__getLastRequest()).'</pre><br/>';
echo 'Ответ<br/>';
echo htmlspecialchars($client->__getLastResponse()).'<br/>';
echo '<br/>';
запрос сейчас он формирует такой
<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:com-softwareag-entirex-rpc:CSS-BASE" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <ns1:WSDLVEGA> <USER-ID xsi:type="xsd:string">123456</USER-ID> <FUNC xsi:type="xsd:string">TrCreate</FUNC> <FIRMA xsi:type="xsd:string">654</FIRMA> <REQBUFB64 xsi:type="xsd:string">s4qMp7gFX/6QxNbStEK1mqzrYWgq+8ECUnCQVNU=</REQBUFB64> <SIGNB64 xsi:type="xsd:string">Q2VydGlmZDY6OmNmOjdkOUxUkxNk1ERVNnbm92R0lqZSsKZkdKSlhSdz0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo= </SIGNB64> <W3VALUE xsi:nil="true"/> </ns1:WSDLVEGA></SOAP-ENV:Body></SOAP-ENV:Envelope>
а мне нужна вот такая структура
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xmm="http://namespace.softwareag.com/entirex/xml/mapping"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:WSDLVEGA xmlns:m="urn:com-softwareag-entirex-rpc:CSS-BASE-WSDLVEGA">
<USER-ID>123456</USER-ID>
<FUNC>TrCreate</FUNC>
<FIRMA>654</FIRMA>
<REQBUFB64>6QxNbStEK1mqzrYWgq+8ECUnCQVNU=</REQBUFB64>
<SIGNB64>LS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=</</SIGNB64>
</m: WSDLVEGA>
</SOAP-ENV:Body></SOAP-ENV:Envelope>
Подскажите пожалуйста, как такое можно сделать или какая есть альтернатива?