当我调用soap api 时,我得到这个响应
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wss="http://www.adonix.com/WSS"><soapenv:Body><wss:saveResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><saveReturn
xsi:type="wss:CAdxResultXml"><messages xsi:type="soapenc:Array"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" soapenc:arrayType="wss:CAdxMessage[0]"></messages><resultXml xsi:type="xsd:string"><!
[CDATA[{"PAY0_1":{"NUM":"WSBAC2310-
00033","PAYAPPFLG":"2","PAYAPPFLG_LBL":"Oui"},"PAY1_1":
{"FCY":"101","BPR":"TRAVELT","BPAINV":"1"},"PAY1_2":
{"ACCDAT":"20231007","REF":"04070436","BAN":"BNP01","AMTCUR":"362.00","CHQNUM":"82cfaaac0
7","ZPAYREF":"82cfaaac07"},"PAY1_5":{"FROCURRAT":"1 E","CURCURRAT":"EUR"},"PAY1_6":
{"SOLDE":"652934.87"},"PAY1_4":
[{"DENCOD":"OPE","VCRNUM":"","FCYLIN":"101","CURLIN":"EUR","AMTLIN":"362.00","DISDAT":nul
l}],"PAY4_3":{"NBRPAY":"0"},"PAY4_1":[],"VTL_2":[],"ADXTEC":
{"WW_MODSTAMP":"20231007193505","WW_MODUSER":"WSVPG"}}]]></resultXml><status
xsi:type="xsd:int">1</status><technicalInfos xsi:type="wss:CAdxTechnicalInfos"><busy
xsi:type="xsd:boolean">false</busy><changeLanguage
xsi:type="xsd:boolean">false</changeLanguage><changeUserId
xsi:type="xsd:boolean">false</changeUserId><flushAdx
xsi:type="xsd:boolean">false</flushAdx><loadWebsDuration
xsi:type="xsd:double">2</loadWebsDuration><nbDistributionCycle
xsi:type="xsd:int">-1</nbDistributionCycle><poolDistribDuration
xsi:type="xsd:double">1</poolDistribDuration><poolEntryIdx
xsi:type="xsd:int">10100</poolEntryIdx><poolExecDuration
xsi:type="xsd:double">441</poolExecDuration><poolRequestDuration
xsi:type="xsd:double">-1</poolRequestDuration><poolWaitDuration
xsi:type="xsd:double">0</poolWaitDuration><processReport xsi:type="xsd:string"
xsi:nil="true"/><processReportSize xsi:type="xsd:int">-1</processReportSize><reloadWebs
xsi:type="xsd:boolean">false</reloadWebs><resumitAfterDBOpen
xsi:type="xsd:boolean">false</resumitAfterDBOpen><rowInDistribStack xsi:type="xsd:int"
xsi:nil="true"/><totalDuration xsi:type="xsd:double">450</totalDuration><traceRequest
xsi:type="xsd:string"/><traceRequestSize xsi:type="xsd:int">0</traceRequestSize>
</technicalInfos></saveReturn></wss:saveResponse></soapenv:Body></soapenv:Envelope>
我想从这个文档获取状态属性, 我用这个代码
$xmlDomElement = new SimpleXMLElement(parent::__getLastResponse());
$xmlDomElement->registerXPathNamespace("wss", "http://www.adonix.com/WSS");
/** @var SimpleXMLElement $status */
$status = $xmlDomElement->xpath("//multiRef[1]//status/text()");
if ((int) $status[0]->__toString() == 0)
{
// my code
}
但我收到错误
Undefined index: 0
回复有效吗?在这种情况下我怎样才能获得状态属性,它是 1
尝试:
$xmlDomElement = new SimpleXMLElement(parent::__getLastResponse());
$xmlDomElement->registerXPathNamespace("wss", "http://www.adonix.com/WSS");
$status = $xmlDomElement->xpath("//wss:saveResponse//saveReturn//status/text()");
if (isset($status[0]) && (int) $status[0]->__toString() == 0) {
// my code
}