Soap发送不正确,需要获取请求



我有这个类来发送SOAP请求(该类还定义了头)

class Personinfo
{
    function __construct() {
        $this->soap = new SoapClient('mysource.wsdl',array('trace' => 1));
    }
    private function build_auth_header() {
        $auth->BrukerID = 'userid';
        $auth->Passord = 'pass';
        $auth->SluttBruker = 'name';
        $auth->Versjon = 'v1-1-0';
        $authvalues = new SoapVar($auth, SOAP_ENC_OBJECT);
        $header =  new SoapHeader('http://www.example.com', "BrukerAutorisasjon", // Rename this to the tag you need
        $authvalues, false);
        $this->soap->__setSoapHeaders(array($header));
    }
    public function hentPersoninfo($params){
        $this->build_auth_header();
        $res = $this->soap->hentPersoninfo($params);
        return $res;
    }
}

问题是我的函数出了问题,而响应是一个错误。我想知道我的请求发送了什么内容,但我不知道如何发送。

我在hentPersonifo函数中尝试过一个调用$this->soap->__getLastRequest的try/catch块,但它总是空的。

我做错了什么?

在开始以编程方式访问服务之前,我使用SoapUI来确保我知道需要向服务发送什么,以及应该返回什么。

通过这种方式,您可以确保问题不在web服务和/或您对如何访问web服务的理解中。

在您理解了这一点之后,您可以将重点缩小到让相关的SOAP框架做您需要它做的事情上。

最新更新