Jump to content

Recommended Posts

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:

 

<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. I also do not know how to check my last request to see what I sent because ZF kills the application when it runs into a bad response it seems. If I could keep going forward and see the last request I may have a better idea of what to do. But right now Im sort of lost.

Link to comment
https://forums.phpfreaks.com/topic/232881-soap-help/
Share on other sites

Ok, Im a dummy and I didnt catch the exception from soap causing it to error. Now I have but when I call Zend_Soap_Client->getLastRequest() it is empty...

 

Im running a similar test outside of zend where I just point the standard soapclient to the wsdl and then run the call. I still get the same results. Using soapclient->__getLastRequest() returns nothing. How can I see what my request was?

Link to comment
https://forums.phpfreaks.com/topic/232881-soap-help/#findComment-1197784
Share on other sites

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

 

$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.

Link to comment
https://forums.phpfreaks.com/topic/232881-soap-help/#findComment-1197792
Share on other sites

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

 

$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.

Link to comment
https://forums.phpfreaks.com/topic/232881-soap-help/#findComment-1197793
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.