ajlisowski Posted April 6, 2011 Share Posted April 6, 2011 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 More sharing options...
ajlisowski Posted April 6, 2011 Author Share Posted April 6, 2011 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 More sharing options...
ajlisowski Posted April 6, 2011 Author Share Posted April 6, 2011 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 More sharing options...
ajlisowski Posted April 6, 2011 Author Share Posted April 6, 2011 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.