0

早上好,

我正在设置 PHP 应用程序以与 SOAP Web 服务进行通信,但遇到了问题。在服务上调用“GetIntradaySnapshotForCommodity”函数时,PHP 返回 NULL。但是,当我检查“__getLastResponse()”内容时,会返回一个有效的 XML 响应。

以下是我的 SOAP 交互代码。

$client = new SoapClient('liffecommoditiesservice.wsdl', array('trace' => TRUE));

$result = $client->GetIntradaySnapshotForCommodity(array(
    'securityToken' => 'XXX',
    'commoditiySymbol' => 'XT'
));

var_dump($result); //This returns NULL

var_dump($client->__getLastRequest()); //This response is included below
var_dump($client->__getLastResponse()); //This response is included below

$client->__getLastRequest()

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://liffecommoditieswebservice.if5.com/"><SOAP-ENV:Body><ns1:GetIntradaySnapshotForCommodity><ns1:securityToken>XXX</ns1:securityToken><ns1:commoditiySymbol>XT</ns1:commoditiySymbol></ns1:GetIntradaySnapshotForCommodity></SOAP-ENV:Body></SOAP-ENV:Envelope>

$client->__getLastResponse()

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ArrayOfIntradaySnapshot xmlns="http://liffecommoditieswebservice.if5.com/"><IntradaySnapshot><CommoditySymbol>XT</CommoditySymbol><DeliveryMonth>Jan-13</DeliveryMonth><TimeStamp>01-Aug-2012 10:48:01</TimeStamp><LastTradePrice>-</LastTradePrice><LastTradeVolume>-</LastTradeVolume><LastTradeTime>-</LastTradeTime><Bid>191 </Bid><Ask>-</Ask><High>-</High><Low>-</Low> <SettlementPrice>192.95 </SettlementPrice><OpenInterest>-</OpenInterest><CurrentCumulativeVolume>-</CurrentCumulativeVolume><PriceChange>0</PriceChange> <PercentagePriceChange>0%</PercentagePriceChange></IntradaySnapshot><IntradaySnapshot><CommoditySymbol>XT</CommoditySymbol><DeliveryMonth>Jan-14</DeliveryMonth><TimeStamp>01-Aug-2012 10:48:01</TimeStamp><LastTradePrice>-</LastTradePrice><LastTradeVolume>-</LastTradeVolume><LastTradeTime>-</LastTradeTime><Bid>161.5 </Bid><Ask>-</Ask><High>-</High><Low>-</Low> <SettlementPrice>165.75 </SettlementPrice><OpenInterest>-</OpenInterest><CurrentCumulativeVolume>-</CurrentCumulativeVolume><PriceChange>0</PriceChange> <PercentagePriceChange>0%</PercentagePriceChange></IntradaySnapshot><IntradaySnapshot><CommoditySymbol>XT</CommoditySymbol><DeliveryMonth>Jul-13</DeliveryMonth><TimeStamp>01-Aug-2012 10:48:01</TimeStamp><LastTradePrice>-</LastTradePrice><LastTradeVolume>-</LastTradeVolume><LastTradeTime>-</LastTradeTime><Bid>-</Bid><Ask>-</Ask><High>-</High><Low>-</Low> <SettlementPrice>201.3 </SettlementPrice><OpenInterest>-</OpenInterest><CurrentCumulativeVolume>-</CurrentCumulativeVolume><PriceChange>0</PriceChange> <PercentagePriceChange>0%</PercentagePriceChange></IntradaySnapshot><IntradaySnapshot><CommoditySymbol>XT</CommoditySymbol><DeliveryMonth>Mar-13</DeliveryMonth><TimeStamp>01-Aug-2012 10:48:01</TimeStamp><LastTradePrice>-</LastTradePrice><LastTradeVolume>-</LastTradeVolume><LastTradeTime>-</LastTradeTime><Bid>-</Bid><Ask>-</Ask><High>-</High><Low>-</Low> <SettlementPrice>195.2 </SettlementPrice><OpenInterest>-</OpenInterest><CurrentCumulativeVolume>-</CurrentCumulativeVolume><PriceChange>0</PriceChange> <PercentagePriceChange>0%</PercentagePriceChange></IntradaySnapshot><IntradaySnapshot><CommoditySymbol>XT</CommoditySymbol><DeliveryMonth>Mar-14</DeliveryMonth><TimeStamp>01-Aug-2012 10:48:01</TimeStamp><LastTradePrice>-</LastTradePrice><LastTradeVolume>-</LastTradeVolume><LastTradeTime>-</LastTradeTime><Bid>-</Bid><Ask>-</Ask><High>-</High><Low>-</Low> <SettlementPrice>168.1 </SettlementPrice><OpenInterest>-</OpenInterest><CurrentCumulativeVolume>-</CurrentCumulativeVolume><PriceChange>0</PriceChange> <PercentagePriceChange>0%</PercentagePriceChange></IntradaySnapshot><IntradaySnapshot><CommoditySymbol>XT</CommoditySymbol><DeliveryMonth>May-13</DeliveryMonth><TimeStamp>01-Aug-2012 10:48:01</TimeStamp><LastTradePrice>195 </LastTradePrice><LastTradeVolume>30 </LastTradeVolume><LastTradeTime>08:57:17 </LastTradeTime><Bid>194.25 </Bid><Ask>199 </Ask><High>195 </High><Low>195 </Low> <SettlementPrice>198 </SettlementPrice><OpenInterest>-</OpenInterest><CurrentCumulativeVolume>30 </CurrentCumulativeVolume><PriceChange>-3</PriceChange> <PercentagePriceChange>-1.52%</PercentagePriceChange></IntradaySnapshot><IntradaySnapshot><CommoditySymbol>XT</CommoditySymbol><DeliveryMonth>May-14</DeliveryMonth><TimeStamp>01-Aug-2012 10:48:01</TimeStamp><LastTradePrice>-</LastTradePrice><LastTradeVolume>-</LastTradeVolume><LastTradeTime>-</LastTradeTime><Bid>-</Bid><Ask>-</Ask><High>-</High><Low>-</Low> <SettlementPrice>172.25 </SettlementPrice><OpenInterest>-</OpenInterest><CurrentCumulativeVolume>-</CurrentCumulativeVolume><PriceChange>0</PriceChange> <PercentagePriceChange>0%</PercentagePriceChange></IntradaySnapshot><IntradaySnapshot><CommoditySymbol>XT</CommoditySymbol><DeliveryMonth>Nov-12</DeliveryMonth><TimeStamp>01-Aug-2012 10:48:01</TimeStamp><LastTradePrice>190 </LastTradePrice><LastTradeVolume>20 </LastTradeVolume><LastTradeTime>09:20:13 </LastTradeTime><Bid>190 </Bid><Ask>190.5 </Ask><High>191 </High><Low>189 </Low> <SettlementPrice>191.95 </SettlementPrice><OpenInterest>-</OpenInterest><CurrentCumulativeVolume>129 </CurrentCumulativeVolume><PriceChange>-1.94999999999999</PriceChange> <PercentagePriceChange>-1.02%</PercentagePriceChange></IntradaySnapshot><IntradaySnapshot><CommoditySymbol>XT</CommoditySymbol><DeliveryMonth>Nov-13</DeliveryMonth><TimeStamp>01-Aug-2012 10:48:01</TimeStamp><LastTradePrice>-</LastTradePrice><LastTradeVolume>-</LastTradeVolume><LastTradeTime>-</LastTradeTime><Bid>161 </Bid><Ask>167 </Ask><High>-</High><Low>-</Low> <SettlementPrice>165.25 </SettlementPrice><OpenInterest>-</OpenInterest><CurrentCumulativeVolume>0 </CurrentCumulativeVolume><PriceChange>0</PriceChange> <PercentagePriceChange>0%</PercentagePriceChange></IntradaySnapshot><IntradaySnapshot><CommoditySymbol>XT</CommoditySymbol><DeliveryMonth>Nov-14</DeliveryMonth><TimeStamp>01-Aug-2012 10:48:01</TimeStamp><LastTradePrice>-</LastTradePrice><LastTradeVolume>-</LastTradeVolume><LastTradeTime>-</LastTradeTime><Bid>-</Bid><Ask>164 </Ask><High>-</High><Low>-</Low> <SettlementPrice>164 </SettlementPrice><OpenInterest>-</OpenInterest><CurrentCumulativeVolume>0 </CurrentCumulativeVolume><PriceChange>0</PriceChange> <PercentagePriceChange>0%</PercentagePriceChange></IntradaySnapshot></ArrayOfIntradaySnapshot></soap:Body></soap:Envelope>

$client->__getFunctions()

array(4) {
    [0]=>
        string(101) "GetEODSnapshotForCommodityResponse GetEODSnapshotForCommodity(GetEODSnapshotForCommodity $parameters)"
    [1]=>
        string(116) "GetIntradaySnapshotForCommodityResponse GetIntradaySnapshotForCommodity(GetIntradaySnapshotForCommodity $parameters)"
    [2]=>
        string(101) "GetEODSnapshotForCommodityResponse GetEODSnapshotForCommodity(GetEODSnapshotForCommodity $parameters)"
    [3]=>
        string(116) "GetIntradaySnapshotForCommodityResponse GetIntradaySnapshotForCommodity(GetIntradaySnapshotForCommodity $parameters)"
}
4

1 回答 1

0

对于任何感兴趣的人来说,这个问题似乎是由 PHP PEAR 库中的一个错误引起的,即一个完全有效的 SOAP 响应没有被正确地转换为一个对象。

我最终改用了 SOAP PEAR 库,它的工作就像做梦一样。

于 2012-08-11T06:15:07.393 回答