How to add urn to SoapClient in PHP?

I have this xml created by SoapUI from this wsdl :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:safetypay:mws:api:messages">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:CommunicationTestRequest>
         <urn:ApiKey>?</urn:ApiKey>
         <urn:RequestDateTime>?</urn:RequestDateTime>
         <urn:Signature>?</urn:Signature>
      </urn:CommunicationTestRequest>
   </soapenv:Body>
</soapenv:Envelope>

This works fine, but when I create it with a client for PHP, SoapClient, it fails ... I found that its error, because it is a little different, it only misses the ballot box (which I have no idea what it is). The Xml from SoapClient looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body>
        <CommunicationTestRequest>
            <RequestDateTime>2012-04-17T23:21:54</RequestDateTime>
            <ApiKey>XXXXX</ApiKey>
            <Signature>XXXXX</Signature>
        </CommunicationTestRequest>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Three main differences: 1) In the definition, the code generated by SoapClient is missing: XMLNS: urn = "urn: SAFETYPAY: MWS: api: messages" 2) In the xml generated by SoapUI, I have soapenv, and in that SoapClient is generated , this is SOAP-ENV 3) In SoapUI, I have an urn in front of every child, SoapClient is not.

( wsdl), ... .. - , ?

:

$std = new RequestDateTime();
$std->RequestDateTime = date ( 'Y-m-d\TH:i:s', time () );
$std->ApiKey = SafetyPaySoap::API_KEY_SAND;
$std->Signature = SafetyPaySoap::SIG_KEY_SAND;
$this->_wsdl->CommunicationTest($std);

SoapClient -

$config = array ();
$config ['exceptions'] = true;
$config ['trace'] = true;
$config ['cache_wsdl'] = WSDL_CACHE_NONE;
$config ['soap_version'] = SOAP_1_1;
parent::SoapClient ( $url . '?wsdl', $config );

Edit: . __doRequest. :

public function __doRequest($request, $location, $action, $version, $one_way = null) {
    $request = str_ireplace("<{$this->_method}Request>", "<{$this->_method}Request xmlns='urn:safetypay:mws:api:messages'>", $request);
    return parent::__doRequest ( $request, $location, $action, $version, $one_way );
}

, , , xml:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body>
        <CommunicationTestRequest xmlns='urn:safetypay:mws:api:messages'>
            <ApiKey>XXXX</ApiKey>
            <RequestDateTime>2012-04-18T20:22:51</RequestDateTime>
            <Signature>XXXXX</Signature>
        </CommunicationTestRequest>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
+3
1

: XML. SoapClient, , "uri" . , , .

$config = array();
$config['uri'] = "urn:safetypay:mws:api:messages";
// your other configurations
parent::SoapClient('https://mws2.safetypay.com/sandbox/express/ws/v.2.4/MerchantWS.asmx?wsdl', $config);
0

All Articles