我使用PHP的SoapClient连接到web服务(这是我无法控制的)。我收到的其中一个SoapFaults如下(为便于阅读而格式化):
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Infolog xmlns="Infolog" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<InfologMessage xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Dynamics.AX.Framework.Services">
<InfologMessageType>Error</InfologMessageType>
<Message>Customer 6729 not found.</Message>
</InfologMessage>
</Infolog>
</s:Header>
<s:Body>
<s:Fault>
<faultcode>s:Client</faultcode>
<faultstring xml:lang="en-US">Request Failed. See the Exception Log for details.</faultstring>
<detail xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<AifFault xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/Fault" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<CustomDetailXml i:nil="true" />
<FaultMessageListArray i:nil="true" />
<InfologMessageList xmlns:b="http://schemas.datacontract.org/2004/07/Microsoft.Dynamics.AX.Framework.Services" i:nil="true" />
<StackTrace i:nil="true" />
<XppExceptionType>3</XppExceptionType>
</AifFault>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
当PHP抛出SoapFault异常时,消息是预期的Request Failed. See the Exception Log for details.
。但我真正需要的是来自Infolog
的{{1}}条目。有没有办法检索Header参数,除了调用__getLastResponse()并自己解析整个XML,这看起来很笨重?
我愿意切换客户端库,如果可以的话 - 我到目前为止尝试使用本机PHP SoapClient和Zend \ Soap \ Client