SOAP Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ajlisowski
Forum Newbie
Posts: 22
Joined: Wed Dec 16, 2009 8:22 pm

SOAP Help

Post by ajlisowski »

Hey all, I am in the midst of building an application that requires a soap request. I know very little about this coming in, so I have been banging my head a few times here.

I am using Zend Framework for this application so I am using it's soap_client.

Basically, things seem like they would be simple enough. I point the client ad the wsdl file then call the appropriate function. I was getting back a message that says: Invalid Username/Password. So I looked into ZFs class and added a login and password and now I get back Unauthorized.

I contacted my point of contact with the company we are doing the soap call to and they said to authorize I need to add the following xml to the header:

Code: Select all

<wsse:Security xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
                 soapenv:mustUnderstand="0"
                 xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
                <wsse:UsernameToken wsu:Id="id-734e5a5c-ccd0-11db-90b7-512fcdfa7c5f"
                  xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
                <wsse:Username> username </wsse:Username>
                <wsse:Password> password </wsse:Password>
                </wsse:UsernameToken></wsse:Security>
However, I am not sure how to go about doing this.
ajlisowski
Forum Newbie
Posts: 22
Joined: Wed Dec 16, 2009 8:22 pm

Re: SOAP Help

Post by ajlisowski »

This is what I have for my code (it is returning the invalid Username/Password exception, which is what happens if I do nothing)

Code: Select all

$xml_auth_header = '<UsernameToken>
                <Username> '.$username.' </Username>
                <Password> '.$password.' </Password>
                </UsernameToken>';
$auth_header = new SoapVar($xml_auth_header, XSD_ANYXML);
$ns='http://schemas.xmlsoap.org/soap/envelope/';
$actor='http://schemas.xmlsoap.org/soap/actor/next';
$header = new SoapHeader($ns,'Security', $auth_header, false,$actor);
$client->addSoapInputHeader($header);
Im not sure what all that wsse stuff is for though...perhaps that is needed. The namespace also confuses me.
Post Reply