I want to access some of my client's data through a web service. He has provided me below information to get this data in XML format.
http://www.clients-domain.com/erpsync/erp_sync.asmx
User = abcd
Password = 1234
Detail of Functions:
GetAllItemData - Will return all the items selected for web, with their price
GetItemDataByDate - Will return all the items updated between a specific date
GetAllItemStock - Will return updated stock of all items for website
GetStockByItem - Will return stock of single Item.
This web service is on a windows based server.
I dont know how to call above URL in PHP to get this data. He told me that the return value of this web service would be in XML format.
Also it is SOAP 1.1
Any help appriciated
Since he stated SOAP simple extend the soap client
1st establish a connection to the SOAP
$soapCon = new Utils_SoapClient("http://www.clients-domain.com/erpsync/erp_sync.asmx", array());
$soapCon->setCredentialsHeader(User, Password);
Create a struct to pass variables
$struct = new stdClass();
$struct->item1 = $item1;
Call functions that client gives you with passed parameters / variables
GetAllItemData - Will return all the items selected for web, with their price
$result = $soapCon->GetAllItemData(new SoapVar($struct, SOAP_ENC_OBJECT));
GetItemDataByDate - Will return all the items updated between a specific date
$result = $soapCon->GetItemDataByDate(new SoapVar($struct, SOAP_ENC_OBJECT));
GetAllItemStock - Will return updated stock of all items for website
$result = $soapCon->GetAllItemStock(new SoapVar($struct, SOAP_ENC_OBJECT));
GetStockByItem - Will return stock of single Item.
$result = $soapCon->GetStockByItem(new SoapVar($struct, SOAP_ENC_OBJECT));
Soap Client Class
class Utils_SoapClient extends SoapClient {
protected $_targetNamespace;
public function __construct($wsdl, $options){
parent::__construct($wsdl, $options);
// detect target namespace
$xml = simplexml_load_file($wsdl);
$this->_targetNamespace = (string) $xml['targetNamespace'];
}
public function setCredentialsHeader($login, $password) {
$header = new SoapHeader($this->_targetNamespace,
'CredentialsSoapHeader',
new SoapVar(
array(
'Login' => $login,
'Password' => $password,
),
SOAP_ENC_OBJECT,
'CredentialsSoapHeader',
$this->_targetNamespace
)
);
$this->__setSoapHeaders(array($header));
}
}