JasonHarper Posted April 28, 2014 Share Posted April 28, 2014 I'm trying to use the code below to make a SOAP request to a vendor's web service: $client = new SoapClient('http://my.domain.com/wsdl/GuestService.WSDL', array('connection_timeout' => 15, 'trace' => 1)); $ns = 'http://vendor.domain.com/'; $headerbody = array('brand' => 'BRAND1', 'locale' => 'en_us', 'securityCredentials'=>array('applicationId'=>'ABCDEF', 'token'=>'123456789123456789123456789')); $header = new SoapHeader($ns, 'Header', $headerbody); $client->__setSoapHeaders($header); $result = $client->getGuest(array('guestID' => '000787')); However, I'm getting an error back that no credentials were supplied so I must be doing something wrong. Error message: Uncaught SoapFault exception: [soapenv:NO_CREDENTIALS] I reached out to the vendor and they sent me an XML sample of how they're expecting to receive the data: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:prox="http://vendor.domain.com" xmlns:gues="http://vendor.domain.com/guest"> <soapenv:Header> <prox:brand>BRAND1</prox:brand> <prox:locale>en_us</prox:locale> <prox:securityCredentials> <prox:applicationId>ABCDEF</prox:applicationId> <prox:token> 123456789123456789123456789</prox:token> </prox:securityCredentials> </soapenv:Header> <soapenv:Body> <gues:getGuest> <guestID>000787</guestID> </gues:getGuest> </soapenv:Body> </soapenv:Envelope> I thought I had accounted for everything in the above but maybe I'm missing something obvious. Really appreciate any help! Quote Link to comment https://forums.phpfreaks.com/topic/288093-php-soap-request-with-authentication/ Share on other sites More sharing options...
JasonHarper Posted April 28, 2014 Author Share Posted April 28, 2014 UPDATE: I downloaded SoapUI so I could see what's going on. It turns out the XML being generated is almost correct with one small issue....the header is inserting <item> and <key> tags within the XML: <securityCredentials> <item> <key>applicationId</key> <value>ABCDEF</key> </item> </securityCredentials> What I need is: <securityCredentials> <applicationId>ABCDEF</applicationId> <token>123456</token> </securityCredentials> If I could eliminate the tags, the XML would be correct. I've researched and can't seem to find a specific flag or setting so still stuck on what to do next. Quote Link to comment https://forums.phpfreaks.com/topic/288093-php-soap-request-with-authentication/#findComment-1477557 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.