Reputation: 14588
The following is a sample SOAP 1.1 request and response
POST /DEMOWebServices2.8/service.asmx HTTP/1.1
Host: api.efxnow.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "https://api.efxnow.com/webservices2.3/DealRequestAtBest"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<Authenticator xmlns="https://api.efxnow.com/webservices2.3">
<ApplicationName>string</ApplicationName>
<IPAddress>string</IPAddress>
<UserID>string</UserID>
<MachineName>string</MachineName>
</Authenticator>
</soap:Header>
<soap:Body>
<DealRequestAtBest xmlns="https://api.efxnow.com/webservices2.3">
<UserID>string</UserID>
<PWD>string</PWD>
<Pair>string</Pair>
</DealRequestAtBest>
</soap:Body>
</soap:Envelope>
Response -
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<DealRequestAtBestResponse xmlns="https://api.efxnow.com/webservices2.3">
<DealRequestAtBestResult>
<Success>boolean</Success>
<ErrorDescription>string</ErrorDescription>
<ErrorNumber>int</ErrorNumber>
<Confirmation>string</Confirmation>
<ConfirmationNumber>string</ConfirmationNumber>
<Rate>double</Rate>
</DealRequestAtBestResult>
</DealRequestAtBestResponse>
</soap:Body>
</soap:Envelope>
i want to know how to make the request and how to handle response if this had to be done in php. i read this but i can't figure out how would __setSoapHeaders()
and __call()
be implemented in my case. thanks in advance.
Upvotes: 0
Views: 1228
Reputation: 361
There's a SOAP library for PHP, but for a simple exchange you might consider building XML request body as a string and the dispatch it using the curl library function. It's a much more low-level network api, which I at least find easier to use. Note that PHP needs to be compiled --with-curl[=DIR].
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $uri);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if ((bool)$proxy) {
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Pragma:','Cache-Control:'));
curl_setopt($ch, CURLOPT_PROXY, $proxy);
}
// Apply the XML to our curl call
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);
$out = curl_exec($ch);
curl_close($ch);
?>
Upvotes: 1