【问题标题】:PHP Soap Client call to WCF service?PHP Soap 客户端调用 WCF 服务?
【发布时间】:2020-02-20 07:27:30
【问题描述】:

如何做到这一点,我是新的 Soap API,任何示例代码 $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 soap-client wcf-binding nusoap


    【解决方案1】:

    WCF 也是SOAP web service 的实现,因此我们应该像调用 SOAP Web 服务一样调用服务。请参考官方文档。
    https://www.php.net/manual/en/book.soap
    https://www.php.net/manual/en/class.soapclient
    另外,这里有一些相关的链接,希望对你有帮助。
    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
    如果有什么可以帮助的,请随时告诉我。

    【讨论】:

    • 我写的代码是正确的吗???我收到此错误:(alert('Sorry, blah 返回以下错误:Client-Function ("GetInventory") 不是此服务的有效方法。我们现在将带您返回我们的主页。'); 窗口.location = 'main.php';)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 2011-03-12
    • 2021-07-28
    • 2012-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多