问题
How to do this, I m new Soap API, Any sample Code $soapClient = new SoapClient("http://website.com/EComintegration/IntegrationService.svc?wsdl");
// Prepare SoapHeader parameters
$sh_param = array(
'UserName' => 'admin',
'Password' => 'admin');
//'ClientID' => 1,
//'OutletID' => 1,
//'TerminalID' => 1);
$headers = new SoapHeader('http://website.com/EComintegration/IntegrationService.svc', 'UserCredentials', $sh_param);
// Prepare Soap Client
$soapClient->__setSoapHeaders(array($headers));
// Setup the RemoteFunction parameters
$ap_param = array(
'Location' => 2,
'DateFilter'=>'20200220'
);
// Call RemoteFunction ()
$error = 0;
try {
$info = $soapClient->__call("GetInventory", array($ap_param));
} catch (SoapFault $fault) {
$error = 1;
print("
alert('Sorry, blah returned the following ERROR: ".$fault->faultcode."-".$fault->faultstring.". We will now take you back to our home page.');
window.location = 'main.php';
");
}
if ($error == 0) {
$auth_num = $info->ItemName;
}
回答1:
WCF is also an implementation of SOAP web service
, thereby we should call the service like calling a SOAP web service. Please refer to the official documentation.
https://www.php.net/manual/en/book.soap
https://www.php.net/manual/en/class.soapclient
Also, here are some relevant links, wish it is helpful to you.
How to consume a WCF Web Service that uses custom username validation with a PHP page?
https://forums.asp.net/t/1602125.aspx
https://social.msdn.microsoft.com/Forums/vstudio/en-US/4abef020-7fb5-40ef-be77-227d329bb172/call-wcf-service-from-php-with-authentication?forum=wcf
Feel free to let me know if there is anything I can help with.
来源:https://stackoverflow.com/questions/60314839/php-soap-client-call-to-wcf-service