I'm having problems getting the results I want from the WSDL.
My script:
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/lib/classes/class.glssoap.php');
$glssoap = new GLSSoap;
echo "<pre>";
//print_r($glssoap->GetOneParcelShop(96101)); // SUCCESS
//print_r($glssoap->GetAllParcelShops()); // SUCCESS
print_r($glssoap->GetAllParcelShopsInZipcode(8000)); // FAILS : RETURNS operation GetAllParcelShopsInZipcode not present.
print_r($glssoap->GetNearestParcelShops('Kriegersvej 8', '8000')); // FAILS : RETURNS operation GetNearestParcelShops not present.
print_r($glssoap->SearchNearstParcelShops('Kriegersvej 8', '8000')); // FAILS : RETURNS operation SearchNearstParcelShops not present.
echo "</pre>";
?>
The class:
<?php
class GLSSoap {
//Get one ParcelShop
public function GetOneParcelShop($parcelShopNumber)
{
$gls_params = array();
$gls_params['ParcelShopNumber'] = $parcelShopNumber;
$result = $this->_soapcall('GetOneParcelShop', $gls_params);
return $result;
}
//Returns all ParcelShops in Denmark
public function GetAllParcelShops()
{
$gls_params = array();
$result = $this->_soapcall('GetAllParcelShops', $gls_params);
return $result;
}
//Returns all ParcelShops in a zipcode
public function GetAllParcelShopsInZipcode($zipCode)
{
$gls_params = array();
$gls_params['Zipcode'] = $zipCode;
$result = $this->_soapcall('GetAllParcelShopsInZipcode', $gls_params);
return $result;
}
//Search for the nearest ParcelShops to an address - Strict version - used for automated processing
public function GetNearestParcelShops($street, $zipCode, $amount = 4)
{
$gls_params = array();
$gls_params['Street'] = $street;
$gls_params['zipcode'] = $zipCode;
$gls_params['amount'] = $amount;
$result = $this->_soapcall('GetNearestParcelShops', $gls_params);
return $result;
}
//Search for the nearest ParcelShops to an address - Loose version - user should veryfi data
public function SearchNearstParcelShops($street, $zipCode, $amount = 4)
{
$gls_params = array();
$gls_params['Street'] = $street;
$gls_params['zipcode'] = $zipCode;
$gls_params['amount'] = $amount;
$result = $this->_soapcall('SearchNearstParcelShops', $gls_params);
return $result;
}
private function _soapcall($call, $params)
{
require_once(dirname(__FILE__).'/class.nusoap.php');
$soapclient = new nusoap_client('http://www.gls.dk/webservices_v2/wsPakkeshop.asmx?WSDL','wsdl');
$result = $soapclient->call($call, array('parameters' => $params));
/* Debug */
echo '<h2>Request</h2><pre>' . htmlspecialchars($soapclient->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2><pre>' . htmlspecialchars($soapclient->response, ENT_QUOTES) . '</pre>';
//echo '<h2>Debug</h2><pre>' . htmlspecialchars($soapclient->debug_str, ENT_QUOTES) . '</pre>';
echo '<pre>'; print_r($result); echo '</pre>';
// Check for a fault
if ($soapclient->fault) {
echo '<div class="alert error"><h2>Fault</h2><pre>';
print_r($result);
echo '</pre></div>';
} else {
// Check for errors
$err = $soapclient->getError();
if ($err) {
// Display the error
echo '<div class="alert error"><h2>Error</h2><pre>' . $err . '</pre></div>';
} else {
return $result;
}
}
return false;
}
};
?>
Further more I use the NUSOAP class as represented here: http://sourceforge.net/projects/nusoap/
My problem is that GetAllParcelShopsInZipcode, GetNearestParcelShops & SearchNearestParcelShops all returns "operation X not present".
The service I'm using is located here: http://www.gls.dk/webservices_v2/wsPakkeshop.asmx
Can anyone please give me a hint what I'm doing wrong?
Thanks in advance
For anyone stumbling across this question at a later time, the problem lies with GLS documentation not being updated properly. Notice the names of the different methods at their online webservice.