PHP7 SoapClient问题

我最近从
PHP5.4升级到
PHP7.男孩是一个改变,但这是不重要的.

自升级以来,我遇到了SoapService的问题.

这是我的SoapRequest在PHP5.4上的样子:

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="urn:usaepay" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://www.w3.org/2003/05/soap-encoding">
<env:Body>
    <ns1:searchTransactions env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
    <Token xsi:type="ns1:ueSecurityToken">
        <ClientIP xsi:type="xsd:string">*redacted*</ClientIP>
        <PinHash xsi:type="ns1:ueHash">
            <HashValue xsi:type="xsd:string">*redacted*</HashValue>
            <Seed xsi:type="xsd:string">*redacted*</Seed>
            <Type xsi:type="xsd:string">sha1</Type>
        </PinHash>
        <SourceKey xsi:type="xsd:string">*redacted*</SourceKey>
    </Token>
    <Search enc:itemType="ns1:SearchParam" enc:arraySize="3" xsi:type="ns1:SearchParamArray">
        <item xsi:type="ns1:SearchParam">
            <Field xsi:type="xsd:string">created</Field>
            <Type xsi:type="xsd:string">gt</Type>
            <Value xsi:type="xsd:string">2016-07-26</Value>
        </item>
        <item xsi:type="ns1:SearchParam">
            <Field xsi:type="xsd:string">created</Field>
            <Type xsi:type="xsd:string">lt</Type>
            <Value xsi:type="xsd:string">2016-07-27</Value>
        </item>
        <item xsi:type="ns1:SearchParam">
            <Field xsi:type="xsd:string">response</Field>
            <Type xsi:type="xsd:string">eq</Type>
            <Value xsi:type="xsd:string">A</Value>
        </item>
    </Search>
    <MatchAll xsi:type="xsd:boolean">true</MatchAll>
    <Start xsi:type="xsd:integer">0</Start>
    <Limit xsi:type="xsd:integer">9999</Limit>
    <Sort xsi:type="xsd:string">TransID</Sort>
</ns1:searchTransactions>
</env:Body>
</env:Envelope>

以下是在PHP7上运行完全相同的代码的请求:

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="urn:usaepay" 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:enc="http://www.w3.org/2003/05/soap-encoding">
<env:Body>
    <ns1:searchTransactions env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
    <Token xsi:type="ns1:ueSecurityToken">
        <ClientIP xsi:type="xsd:string">*redacted*</ClientIP>
        <PinHash xsi:type="ns1:ueHash">
            <HashValue xsi:type="xsd:string">*redacted*</HashValue>
            <Seed xsi:type="xsd:string">*redacted*</Seed>
            <Type xsi:type="xsd:string">sha1</Type>
        </PinHash>
        <SourceKey xsi:type="xsd:string">*redacted*</SourceKey>
    </Token>
    <Search enc:itemType="ns2:Map" enc:arraySize="3" xsi:type="ns1:SearchParamArray">
        <item xsi:type="ns2:Map">
            <item>
                <key xsi:type="xsd:string">Field</key>
                <value xsi:type="xsd:string">created</value>
            </item>
            <item>
                <key xsi:type="xsd:string">Type</key>
                <value xsi:type="xsd:string">gt</value>
            </item>
            <item>
                <key xsi:type="xsd:string">Value</key>
                <value xsi:type="xsd:string">2016-07-26</value>
            </item>
        </item>
        <item xsi:type="ns2:Map">
            <item>
                <key xsi:type="xsd:string">Field</key>
                <value xsi:type="xsd:string">created</value>
            </item>
            <item>
                <key xsi:type="xsd:string">Type</key>
                <value xsi:type="xsd:string">lt</value>
            </item>
            <item>
                <key xsi:type="xsd:string">Value</key>
                <value xsi:type="xsd:string">2016-07-26</value>
            </item>
        </item>
        <item xsi:type="ns2:Map">
            <item>
                <key xsi:type="xsd:string">Field</key>
                <value xsi:type="xsd:string">response</value>
            </item>
            <item>
                <key xsi:type="xsd:string">Type</key>
                <value xsi:type="xsd:string">eq</value>
            </item>
            <item>
                <key xsi:type="xsd:string">Value</key>
                <value xsi:type="xsd:string">A</value>
            </item>
        </item>
    </Search>
    <MatchAll xsi:type="xsd:boolean">true</MatchAll>
    <Start xsi:type="xsd:integer">0</Start>
    <Limit xsi:type="xsd:integer">9999</Limit>
    <Sort xsi:type="xsd:string">created</Sort>
</ns1:searchTransactions>
</env:Body>
</env:Envelope>

以下是相关的PHP代码:(注$sec)是已编辑的安全信息.

$param = array(
            array('Field' => 'created', 'Type' => 'gt', 'Value' => date('Y-m-d', strtotime('2016-07-26'))), 
            array('Field' => 'created', 'Type' => 'lt', 'Value' => date('Y-m-d', strtotime('2016-07-26'))),
            array('Field' => 'response', 'Type' => 'eq', 'Value' => 'A')
            );

$matchAll = true;
$start = 0;
$limit = 9999;
$sort = 'TransID';

$this->advClient = new SoapClient($this->adv_wsdl, array('trace' => 1, 'exceptions' => 1, 'cache_wsdl' => WSDL_CACHE_BOTH, 'soap_version' => SOAP_1_2));
$result = $this->advClient->searchTransactions($sec, $searchParam, $matchAll, $start, $limit, $sort);

我最终得到的是一个错误.我认为问题是在PHP7中它包装并添加额外的“item”标签.但是有些功能仍然没有问题.还有其他人遇到过这个吗?

最佳答案 有趣的是,我使用了wsdltophp.com并为WSDL创建了一个类,一切正常.

点赞