Es mi primera vez haciendo este tipo de conexiones, la idea es obtener una serie de valores de este servidor.
"En teoría", el código debería devolver un archivo xml
.
Este es mi código:
$soap_request = 'xml='.urlencode(trim('
<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>
<WSGetReceiptTracking xmlns="\http://s5.stephytrackingonline.com\">
<Username>MIUSER</Username>
<Password>MIPASS</Password>
<Serial>MISERIAL</Serial>
<CustomerType>0</CustomerType>
<Receipt>VALOR</Receipt>
</WSGetReceiptTracking>
</soap:Body>
</soap:Envelope>'));
$header = array(
'POST /stows/stows.asmx HTTP/1.1',
'Host: s5.stephytrackingonline.com',
'Content-Type: text/xml; charset=utf-8',
'Content-Length: '.strlen($soap_request),
);
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, 'http://s5.stephytrackingonline.com/stows/stows.asmx?op=WSGetReceiptTracking');
curl_setopt($soap_do, CURLOPT_HEADER, false);
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 100);
curl_setopt($soap_do, CURLOPT_TIMEOUT, 100);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header);
curl_setopt($soap_do, CURLOPT_POST, true);
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $soap_request);
curl_setopt($soap_do, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');
$output = curl_exec($soap_do);
$info = curl_getinfo($soap_do);
if (curl_exec($soap_do) === FALSE) {
$err = 'Curl error: ' . curl_error($soap_do);
curl_close($soap_do);
print $err;
}
else {
curl_close($soap_do);
}
echo '<br><br><b>The server responded:</b> '.$info['http_code']."\n";
echo '<br><br><b>Output:</b> '.$output;
echo "\n";
Y esta es la respuesta del proveedor del servidor:
POST /stows/stows.asmx HTTP/1.1
Host: s5.stephytrackingonline.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://s5.stephytrackingonline.com/WSGetReceiptTracking"
<?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>
<WSGetReceiptTracking xmlns="http://s5.stephytrackingonline.com">
<Username>string</Username>
<Password>string</Password>
<Serial>string</Serial>
<CustomerType>string</CustomerType>
<Receipt>string</Receipt>
<Tracking>string</Tracking>
<FromDate>string</FromDate>
<ToDate>string</ToDate>
</WSGetReceiptTracking>
</soap:Body>
</soap:Envelope>