PHP Soap Client 调用 WCF 服务? [英] PHP Soap Client call to WCF service?
问题描述
如何做到这一点,我是新的 Soap API,任何示例代码$soapClient = new SoapClient("http://website.com/EComintegration/IntegrationService.svc?wsdl");
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;
}
推荐答案
WCF 也是 SOAP web service
的一个实现,因此我们应该像调用 SOAP web service 一样调用该服务.请参考官方文档.
https://www.php.net/manual/en/book.soap
https://www.php.net/manual/en/class.soapclient
另外,这里有一些相关链接,希望对您有所帮助.
如何使用对 PHP 页面使用自定义用户名验证的 WCF Web 服务?
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
如果有什么我可以帮忙的,请随时告诉我.
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.
这篇关于PHP Soap Client 调用 WCF 服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!