2012-01-06 85 views
0

我刚刚开始使用php进行soap通信。似乎无法从我的SoapClient获得响应

我访问返回一个true或false取决于三个属性的“用户名”,“密码”和“域”

这里是我的匿名请求代码web服务:

//VARS 
$username = 'example'; 
$password = 'example'; 
$domain = 'example'; 

$client = new SoapClient("https://www.example.com/example.wsdl"); 

try { 
    $client->authenticate(array($email, $password, $domain)); 
    echo $client->__getLastResponse(); 
} catch (SoapFault $e) { 
    echo $e->getMessage(); 
} 

die(); 

现在,正如我所提到的,我是新手,所以我不确定我写的内容是否正确,请帮忙!

这里是WSDL的相关部分(再次,匿名):

//MESSAGE 
<message name="AuthenticateRequest"> 
    <part type="xsd:string" name="username"/> 
    <part type="xsd:string" name="password"/> 
    <part type="xsd:string" name="domain"/> 
</message> 
<message name="AuthenticateResponse"> 
    <part type="xsd:boolean" name="authenticationResponse"/> 
</message> 

//OPERATION 
<portType name="LDAPPortType"> 
    <operation name="authenticate"> 
     <documentation> 
      Connects to the LDAP server with the parameters provided. If successful, this function then attempts to bind to the LDAP directory with the user's credentials. The function returns TRUE on success or FALSE on failure. 
     </documentation> 
     <input message="tns:AuthenticateRequest"/> 
     <output message="tns:AuthenticateResponse"/> 
    </operation> 
</portType> 

我错过了什么重要的?
感谢您的帮助,非常感谢!

回答

3

我想你会需要$username,而不是$email在此行

$client->authenticate(array($email, $password, $domain)); 
          ^

还试着用数组来指定参数名称为:

$client->authenticate(array("username"=>$username, 
       "password"=>$password, "domain"=>$domain)); 
+0

啊,感谢察觉我的错误!不幸的是,我仍然无法获得回报。我使用了上面例子中详细描述的参数名称。我没有收到错误,或任何异常都没有回应到页面。 – 2012-01-06 10:11:31

+0

@DanielHanly:尝试查看由'echo“创建的请求REQUEST:”。 $ proxy - > __ getLastRequest()。 “”;'在你通过认证之后。您需要查看页面源以查看此内容。还保存你的返回到一个变量和打印,作为'$结果= $客户端 - >认证(数组(“用户名”=> $用户名, “密码”=> $密码,“域”=> $域)); print_r($ result);'你也应该捕获异常,而不是SoapFault来查看其他异常,如'catch(Exception $ e){echo $ e-> getMessage(); }' – 2012-01-06 10:14:42

+0

没有运气,我很害怕。 wsdl是https,这会影响结果吗? $ proxy变量来自哪里?我试着'echo“REQUEST:”。 $ client - > __ getLastRequest()。 “”;“但没有回应,我收到了REQUEST这个词......但再次感谢您的帮助。 – 2012-01-06 10:33:32