使用PHP SoapClient来使用WCF API

时间:2015-11-13 09:32:28

标签: php wcf soap-client

我第一次使用PHP SoapClient尝试使用WCF API,但到目前为止还没有锁定。

WSDL is copied here

开始时,我需要从LOGIN函数中检索一个令牌,并在调用其他函数时使用此令牌。登录详细信息:

  • 用户名:'常规'
  • Passord:'' (空白,非空)

到目前为止,我已尝试了多种组合,通常是这样的:

<?php

ini_set('soap.wsdl_cache_enabled',0);
ini_set('soap.wsdl_cache_ttl',0);

$params  = array(
    "soap_version" => SOAP_1_2,
    "trace" => 1,
    "exceptions" => 0,
);

$client = new SoapClient('http://bibjure.rwaao.no:8001/Jussystemer/BibjureService?singleWsdl', $params);

$retval = $client->Login('regular','');

if (is_soap_fault($retval)) {
    trigger_error("SOAP Fault: (faultcode: {$retval->faultcode}, faultstring: {$retval->faultstring})", E_USER_ERROR);
}

var_dump($retval);

导致以下错误: PHP Fatal error: SOAP Fault: (faultcode: s:Sender, faultstring: The creator of this fault did not specify a Reason.) in /mnt/data/fredrik/wcf-test.php on line 17

我不知道如何解决此错误。我希望有人可能会在我的代码中看到错误。

非常感谢。

1 个答案:

答案 0 :(得分:0)

添加soap标头并尝试这样的方法。它可能有用

        $client = new SoapClient('http://bibjure.rwaao.no:8001/Jussystemer/BibjureService?singleWsdl', $params);

        $actionHeader = new SoapHeader('http://www.w3.org/2005/08/addressing','Action','http://tempuri.org/IService/GetData',true);
        $client->__setSoapHeaders($actionHeader);

        $retval = $client->Login('regular',''); 
相关问题