OptimusCrime
OptimusCrime

Reputation: 14863

Soap not getting sent correctly, need to get the request

I have this class to send a SOAP-request (the class also defines the header)

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;
    }
}

The problem is that there's something wrong with my function and the response is an error. I'd like to find out what content I am sending with my request, but I can't figure out how.

I've tried a try/catch-block in the hentPersoninfo-function that calls $this->soap->__getLastRequest but it is always empty.

What am I doing wrong?

Upvotes: 1

Views: 438

Answers (1)

Zack Marrapese
Zack Marrapese

Reputation: 12090

Before I ever start accessing a service programmatically, I use SoapUI to ensure that I know what needs sent to the service, and what I should expect back.

This way, you can ensure the issue isn't in the web service and/or in your understanding of how you should access the web service.

After you understand this, you can narrow your focus onto making the relevant SOAP framework do what you need it to do.

Upvotes: 5

Related Questions