我正在尝试处理来自First Data全球网关的SOAP响应。我以前使用过SoapClient,但是没有wsdl文件 - 公司表示他们不提供。我尝试了各种其他方法,例如基于此处和PHP手册中找到的示例的SimpleXMLElement,但我无法使任何内容正常工作。我怀疑命名空间是我的问题之一。是否有人可以建议一种方法或将我指向类似的示例 - 我的Google搜索至今无果。使用PHP 5。部分SOAP响应(去除所有HTML头信息)如下:
我需要确定是否有SOAP故障发生。相应的XML如下所示:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<fdggwsapi:FDGGWSApiOrderResponse xmlns:fdggwsapi="http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi">
<fdggwsapi:CommercialServiceProvider/>
<fdggwsapi:TransactionTime>Thu Nov 29 17:03:18 2012</fdggwsapi:TransactionTime>
<fdggwsapi:TransactionID/>
<fdggwsapi:ProcessorReferenceNumber/>
<fdggwsapi:ProcessorResponseMessage/>
<fdggwsapi:ErrorMessage>SGS-005005: Duplicate transaction.</fdggwsapi:ErrorMessage>
<fdggwsapi:OrderId>A-e833606a-5197-45d6-b990-81e52df41274</fdggwsapi:OrderId>
...
<snip>
我需要确定是否有SOAP故障发生。相应的XML如下所示:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<SOAP-ENV:FaultX>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring xml:lang="en">MerchantException</faultstring>
<detail>
cvc-pattern-valid: Value '9999185.00' is not facet-valid with respect to pattern '([1-9]([0-9]{0,3}))?[0-9](\.[0-9]{1,2})?' for type '#AnonType_ChargeTotalAmount'.
cvc-type.3.1.3: The value '9999185.00' of element 'v1:ChargeTotal' is not valid.
</detail>
</SOAP-ENV:FaultX>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
使用Mr. Code的答案,我已经能够从非错误响应中检索数据。但是我需要确定我正在处理的数据包类型,并从两种类型中提取数据。如果他们提供了wsdl,那将会更容易!