两个soap请求之间的差异


Difference between two soap requests

我的SOAP请求

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://ws.dgpys.deloitte.com" xmlns:ns2="ws.apache.org/namespaces/axis2">
    <env:Header>
        <ns2:ServiceGroupId>
            <BOGUS>urn:uuid:7C2F61BDE7CB9D9C6D1424938568724</BOGUS>
        </ns2:ServiceGroupId>
    </env:Header>
    <env:Body>
        <ns1:getGunlukParametreRapor>
            <date>2015-02-22T00:00Z</date>
        </ns1:getGunlukParametreRapor>
    </env:Body>
</env:Envelope>

预期的SOAP请求

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ws="http://ws.dgpys.deloitte.com">
   <soap:Header>
       <axis2:ServiceGroupId xmlns:axis2="http://ws.apache.org/namespaces/axis2">urn:uuid:479731898147E116AD1424691518968</axis2:ServiceGroupId>
   </soap:Header>
   <soap:Body>
      <ws:getGunlukParametreRapor>
         <date>2015-02-22T00:00Z</date>
      </ws:getGunlukParametreRapor>
   </soap:Body>
</soap:Envelope>

尝试使用以下代码:

$options = array(
        'trace'       => 1,
        'exceptions'  => 1,
        'soap_version' => SOAP_1_2
    );
$client = new SoapClient("http://dgpysws.pmum.gov.tr/dgpys/services/EVDServis.wsdl", $options);
$p1 = new stdCLass();
$p1->loginMessage = new stdCLass();
$p1->loginMessage->UserName = new stdCLass();
$p1->loginMessage->UserName->v = "Username";
$p1->loginMessage->Password = new stdCLass();
$p1->loginMessage->Password->v = "Passwor";
$client->login($p1);
$headers[] = new SoapHeader('http//ws.apache.org/namespaces/axis2', 'ServiceGroupId', "UNIQUEID", false);
$client->__setSoapHeaders($headers);    
$result = $client->getGunlukParametreRapor(array('date' => '2015-02-22T00:00Z'));

问题是:

  1. 这些SOAP请求是相同的吗

我使用的是SOAP_1_2,它应该像Expected SOAP Request,但我的请求看起来不像预期的格式。哪里不见了?

  1. 我如何才能获得预期的输出

注意:dgpysws.pum.gov.tr wsdl地址是私人区域

它们不一样。要摆脱BOGUS节点,您需要使用以下内容:

$strHeaderComponent_Session = "<SessionHeader><ServiceGroupId>$theVarWithTheIDGoesHere</ServiceGroupId></SessionHeader>";
$objVar_Session_Inside = new SoapVar($strHeaderComponent_Session, XSD_ANYXML,
                                     null, null, null);
$objHeader_Session_Outside = new SoapHeader('http//ws.apache.org/namespaces/axis2', 
                                           'SessionHeader', $objVar_Session_Inside);
// More than one header can be provided in this array.
$client->__setSoapHeaders(array($objHeader_Session_Outside));

尝试以下

$ns = 'http//ws.apache.org/namespaces/axis2'; //Namespace of the WS.
//Body of the Soap Header.
$headerbody = array('ServiceGroupId' => $UNIQUEID_Token);
//Create Soap Header.       
$header = new SOAPHeader($ns, 'axis2', $headerbody);             
//set the Headers of Soap Client.
$soap_client->__setSoapHeaders($header); 
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://ws.dgpys.deloitte.com" xmlns:ns2="ws.apache.org/namespaces/axis2">
    <env:Header>
        <ns2:ServiceGroupId>
            urn:uuid:7C2F61BDE7CB9D9C6D1424938568724
        </ns2:ServiceGroupId>
    </env:Header>
    <env:Body>
        <ns1:getGunlukParametreRapor>
            <date>2015-02-22T00:00Z</date>
        </ns1:getGunlukParametreRapor>
    </env:Body>
</env:Envelope>

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ws="http://ws.dgpys.deloitte.com">
   <soap:Header>
       <axis2:ServiceGroupId xmlns:axis2="http://ws.apache.org/namespaces/axis2">urn:uuid:479731898147E116AD1424691518968</axis2:ServiceGroupId>
   </soap:Header>
   <soap:Body>
      <ws:getGunlukParametreRapor>
         <date>2015-02-22T00:00Z</date>
      </ws:getGunlukParametreRapor>
   </soap:Body>
</soap:Envelope>

都是一样的。env=soap,ns2=ws,ns2=axis2。您可以根据需要使用任何前缀来引用这些名称空间。一旦你指定了前缀,你就可以在其他地方使用它来指代它。唯一不同的是伪造的标签锡第一次请求。把它取下来。