PHP7 SoapClient问题

4

我最近从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”标签。但是,一些函数仍然可以正常工作。还有其他人遇到过这个问题吗?

1个回答

2
有趣的是,我使用了wsdltophp.com并创建了一个WSDL类,一切都很顺利。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接