似乎无法从我的SoapClient获得响应

时间:2012-01-06 09:57:33

标签: php soap wsdl

我刚刚开始通过php进行肥皂交流。

我可以访问依赖于三个属性'username','password'和'domain'

返回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>

我是否错过了至关重要的事情? 感谢您的帮助,非常感谢!

1 个答案:

答案 0 :(得分:3)

我认为您需要$username而不是此行中的$email

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

还尝试将数组中的参数名称指定为:

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