I'm having issues with a SOAP call, and I believe it is related to a namespace. I'm getting incorrect responses back from the server I'm sending to, and it appears to be thanks to an incorrect SOAP Envelope and namespace.
152 protected function callWithSOAP($xml) {
153
154 try {
155 $soapClient = new SoapClient($this->mercuryWSDL, array('trace'=>1));
156 } catch (Exception $e) {
157 throw new Exception($e->getMessage());
158 }
159
160 $message = array(
161 'tran'=> $xml,
162 'pw'=> $this->mercuryPassword
163 );
164
165 // Make SOAP Call
166 try {
167 $request = $soapClient->CreditTransaction($message);
168 } catch (Exception $e) {
169 throw new Exception($e->getMessage());
170 }
171
172 $res = $soapClient->__getLastRequest();
173 return $res;
174
175 return $request;
176 }
The XML I'm feeding into it in the method signature is fine, I have confirmed that is the same as the server is expecting, its specifically the soap request that is having the problem.
Here is the SOAP request I'm sending with SoapClient:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.mercurypay.com">
<SOAP-ENV:Body>
<ns1:CreditTransaction>
<ns1:tran>
<?xml version="1.0"?>
<TStream>
<Transaction>
<MerchantID>******</MerchantID>
<TranType>Credit</TranType>
<TranCode>FSASale</TranCode>
<InvoiceNo>12</InvoiceNo>
<RefNo>12</RefNo>
<Account>
<AcctNo>*******</AcctNo>
<ExpDate>****</ExpDate>
</Account>
<Amount>
<Purchase>25</Purchase>
<FSAPrescription>25</FSAPrescription>
</Amount>
</Transaction>
</TStream>
</ns1:tran>
<ns1:pw>xyz</ns1:pw>
</ns1:CreditTransaction>
</SOAP-ENV:Body>
But here is what it's actually expecting...how can i match this:
<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mer="http://www.mercurypay.com" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<mer:CreditTransaction>
<mer:tran>
<?xml version="1.0"?>
<TStream>
<Transaction>
<MerchantID>******</MerchantID>
<TranType>Credit</TranType>
<TranCode>FSASale</TranCode>
<InvoiceNo>1</InvoiceNo>
<RefNo>1</RefNo>
<Account>
<AcctNo>************</AcctNo>
<ExpDate>****</ExpDate>
</Account>
<Amount>
<Purchase>63.54</Purchase>
<FSAPrescription>63.54</FSAPrescription>
</Amount>
</Transaction>
</TStream>
</mer:tran>
<mer:pw>xyz</mer:pw>
</mer:CreditTransaction>
</soapenv:Body>
</soapenv:Envelope>
You'll notice the "mer:" all over the place. I believe this is what I need to make get a proper response from the server. Please help me out, this is supposed to go out for testing tomorrow and we just realized that the responses from this are very inconsistant.
Thanks for any help you can provide, I really appreciate it.