PHP7 SoapClient Issues



我最近从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中,它正在包装并添加额外的"项目"标签。然而,有些功能仍然可以正常工作。有其他人碰到过这个吗?

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

相关内容

  • 没有找到相关文章

最新更新