3

我得到这个 SoapFault 我不明白。调用下面的函数,codewordStemExists(),应该创建一个 SoapClient,它连接到一个已启动并正在运行的 SoapServer(我找不到服务器端报告的错误)。

private static function initClient() {
    ini_set("soap.wsdl_cache_enabled", "0");
    $classmap = array(
        'CodewordStemExists' => 'CodewordStemExists',
        'CodewordStemExistsResponse' => 'CodewordStemExistsResponse',
    );
    $client = new \SoapClient("http://..../service.wsdl", array(
        "trace" => true,
        "exceptions" => true,
        "classmap" => $classmap
    ));
    return $client;
}

public static function codewordStemExists($stem) {
    $client = self::initClient();
    try {
        $req = new CodewordStemExists();
        $req->username = "....";
        $req->password = "....";
        $req->codewordStem = $stem;

        $res = $client->codewordStemExists($req);
        return (bool)$res->result;
    }
    catch (\SoapFault $e) {
        var_dump($client->__getLastResponse());

}

/** The result from var_dump: */
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://....">
<SOAP-ENV:Body>
    <ns1:CodewordStemExistsResponse><ns1:result>false</ns1:result>
    </ns1:CodewordStemExistsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

肥皂故障:

Class 'CodewordStemExistsResponse' not found

引导时需要 CodewordStemExistsResponse,可以随时实例化它。

有人见过这个吗?谢谢。

4

1 回答 1

3

检查这是否需要适当的命名空间,例如\vendor\CodewordStemExistsResponse.

于 2012-05-08T12:32:26.753 回答