Reputation: 21
So I've read the other parsing questions and answers out there on Parsing SOAP responses with Coldfusion. However, in this case, there response is a little different in format and when I try to parse it using xmlSearch, I get an empty Array as a result.
Here is the soap response I need to parse:
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<AuthorizeAndCaptureResponse xmlns="http://3DSI.org/WebServices/CreditCardTransaction">
<AuthorizeAndCaptureResult xmlns:a="http://schemas.datacontract.org/2004/07/ThreeDelta.Web.Services.ECLinx.Definitions.CreditCardTransactionDefinitions" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Succeeded xmlns="http://schemas.datacontract.org/2004/07/ThreeDelta.Web.Services.ECLinx.Definitions">false</Succeeded>
<ValidationFailures xmlns="http://schemas.datacontract.org/2004/07/ThreeDelta.Web.Services.ECLinx.Definitions" xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays" i:nil="true" />
<a:FailureReason>PermissionDenied</a:FailureReason>
<a:ProcessorResponse i:nil="true" />
<a:RuleInfringements xmlns:b="http://schemas.datacontract.org/2004/07/ThreeDelta.Web.Services.ECLinx.Definitions" i:nil="true" />
<a:ThirdPartyResponse i:nil="true" />
<a:Token i:nil="true" />
<a:TotalAmount>0</a:TotalAmount>
<a:TransactionKey i:nil="true" />
<a:TransactionWarning xmlns:b="http://schemas.datacontract.org/2004/07/ThreeDelta.Common.Enums" i:nil="true" />
<a:AddressAvsResponse>None</a:AddressAvsResponse>
<a:CardSecurityCodeResponse>None</a:CardSecurityCodeResponse>
<a:PostalCodeAvsResponse>None</a:PostalCodeAvsResponse>
<a:ProcessorAvsResponse i:nil="true" />
<a:ProcessorCardSecurityCodeResponse i:nil="true" />
<a:AuthCode i:nil="true" />
<a:CreditCardResponseStatus>None</a:CreditCardResponseStatus>
</AuthorizeAndCaptureResult>
</AuthorizeAndCaptureResponse>
</s:Body>
</s:Envelope>
I need the a:AuthCode
value as well from the array. I've already tried the following but with no luck. It returns an empty array.
<cfset results = xmlSearch(soapResponse,"//*[local-name()='s:Envelope']") />
<cfdump var="#results#" />
Any help would be greatly appreciated.
Upvotes: 2
Views: 179
Reputation: 850
Are you parsing the SOAP string before doing your xmlSearch?
<cfset soapFile = XmlParse(SOAP-RESPONSE)>
<cfset authCode = xmlSearch(soapFile, 'AuthCode') />
This worked for me.
Upvotes: 1