SoapFault - 响应后找不到类

时间:2012-05-08 12:07:46

标签: php soap

我得到这个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>

SoapFault:

Class 'CodewordStemExistsResponse' not found

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

之前有人见过吗?感谢。

1 个答案:

答案 0 :(得分:3)

检查这是否需要正确的命名空间,例如\vendor\CodewordStemExistsResponse