iPixel Posted April 4, 2012 Share Posted April 4, 2012 Hello everyone. So I need to make a SOAP request to an external application written in ASP.net. We run a PHP shop, so SOAP is what they offer us as means of communication. This is the request that will give the correct response. <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:impl="http://tempuri.com" xmlns:mod="http://tempuri.com"> <soapenv:Header/> <soapenv:Body> <impl:GetRegistrationURL> <impl:principal> <mod:password>__password__</mod:password><!--Optional:--> <mod:signupName>__signupName__</mod:signupName><!--Optional:--> <mod:userName>[email protected]__</mod:userName><!--Optional:--> </impl:principal> <impl:validationType>email</impl:validationType> <impl:validationId>[email protected]</impl:validationId> </impl:GetRegistrationURL> </soapenv:Body> </soapenv:Envelope> Here is what i got PHP-wise so far... it kind of works, but i get soapFault error of Credentials not supplied. My assumption is i'm just doing it wrong. PHP Code: <?php $client = new SoapClient("https://tempuri/webservices/RegistrationServiceImpl?wsdl",array("trace"=> 1, "exceptions" => 0)); $params = array('validationType' => 'email', 'validationId' => '[email protected]'); $client->__soapCall("GetRegistrationURL", array('impl'=>$params)); ?> The above code renders this XML Request: <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://tempuri.com"> <SOAP-ENV:Body> <ns1:GetRegistrationURL> <ns1:principal xsi:nil="true"/> <ns1:validationType>email</ns1:validationType> <ns1:validationId>[email protected]</ns1:validationId> </ns1:GetRegistrationURL> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Which seems to be kind of right, but not exactly as the response becomes the following: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <ns1:GetRegistrationURLResponse xmlns:ns1="http://tempuri.com"> <ns1:out> <errorCode xmlns="http://tempuri.com">101</errorCode> <errorMessage xmlns="http://tempuri.com">Credentials not supplied</errorMessage> <registrationURL xmlns="http://tempuri.com" xsi:nil="true" /> </ns1:out> </ns1:GetRegistrationURLResponse> </soap:Body> </soap:Envelope> So, basically i need help properly passing these credentials main validationType and validationId as those are the only required ones. Thanks for the help in advance! Quote Link to comment https://forums.phpfreaks.com/topic/260354-soap-help-needed/ Share on other sites More sharing options...
iPixel Posted April 4, 2012 Author Share Posted April 4, 2012 Could it be that it's because the generated request uses ns1 instead of impl like the actual request has? <ns1:principal xsi:nil="true"/> <ns1:validationType>email</ns1:validationType> <ns1:validationId>[email protected]</ns1:validationId> if so, how can i force it to use impl instead of ns1... i figured doing 'impl'=>$params would have dont that trick. Quote Link to comment https://forums.phpfreaks.com/topic/260354-soap-help-needed/#findComment-1334461 Share on other sites More sharing options...
samshel Posted April 4, 2012 Share Posted April 4, 2012 Check with the webservice hosts if you need to pass anything in the headers. Generally webservices are secured with a username password to avoid genera public misuse. Quote Link to comment https://forums.phpfreaks.com/topic/260354-soap-help-needed/#findComment-1334486 Share on other sites More sharing options...
iPixel Posted April 5, 2012 Author Share Posted April 5, 2012 The initial request code I posted was given to us by the dev team of that company, as you can see they did not have any headers... so i would assume they know what they are doing. Quote Link to comment https://forums.phpfreaks.com/topic/260354-soap-help-needed/#findComment-1334507 Share on other sites More sharing options...
btherl Posted April 5, 2012 Share Posted April 5, 2012 ns1 in your code is the same namespace as both impl and mod in the sample request, so the namespaces look ok. The obvious thing missing is ns1:principal, which is impl:principal in the sample - is it really optional like the sample says? I would try adding it in and see what happens. Quote Link to comment https://forums.phpfreaks.com/topic/260354-soap-help-needed/#findComment-1334511 Share on other sites More sharing options...
iPixel Posted April 5, 2012 Author Share Posted April 5, 2012 Any idea how i could do that? I tried re-working the parameters array like so : <?php $principalParameters = array('impl'=>array('mod' => array('userName' => '[email protected]', 'signupName' => 'org', 'password' => 'orgpass'), 'validationType' => 'email', 'validationId' => '[email protected]')); ?> But no luck at all, it completely disregards the mod=>array() and only reads into the impl=>array(); So the result still looks like so: <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://impl.tempuri.com"> <SOAP-ENV:Body> <ns1:GetRegistrationURL> <ns1:principal xsi:nil="true"/> <ns1:validationType>email</ns1:validationType> <ns1:validationId>[email protected]</ns1:validationId> </ns1:GetRegistrationURL> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Sorry, this is my first SOAP-ing so I'm having difficulty figuring out how to tell the wsdl file what i want my request to look like. Quote Link to comment https://forums.phpfreaks.com/topic/260354-soap-help-needed/#findComment-1334603 Share on other sites More sharing options...
iPixel Posted April 5, 2012 Author Share Posted April 5, 2012 Ok i managed to get the $parameters array working properly. It now creates a request soap call that looks just like the example they provided. At this point I'm getting a response of "logon denied" which most likely means the test account info they gave us is bogus... but take a look below to confirm. $client = new SoapClient("https://www.tempuri.com/webservices/RegistrationServiceImpl?wsdl",array("trace"=> 1, "exceptions" => 0)); $parameters = array('impl' => array('principal' => array('userName' => '[email protected]', 'signupName' => 'org', 'password' => 'org123'), 'validationType' => 'email', 'validationId' => '[email protected]')); $client->__soapCall("GetRegistrationURL", $parameters); Creates : <!-- THIS IS THE REQUEST SOAP CODE GENERATED VIA PHP SCRIPT --> <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://model.tempuri.com" xmlns:ns2="http://impl.tempuri.com"> <SOAP-ENV:Body> <ns2:GetRegistrationURL> <ns2:principal> <ns1:password>org123</ns1:password> <ns1:signupName>org</ns1:signupName> <ns1:userName>[email protected]</ns1:userName> </ns2:principal> <ns2:validationType>email</ns2:validationType> <ns2:validationId>[email protected]</ns2:validationId> </ns2:GetRegistrationURL> </SOAP-ENV:Body> </SOAP-ENV:Envelope> <!-- THIS IS THE RESPONSE SENT BACK --> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <soap:Fault> <faultcode>soap:Client</faultcode> <faultstring>Could not get JDBC Connection; nested exception is java.sql.SQLException: ORA-01017: invalid username/password; logon denied</faultstring> </soap:Fault> </soap:Body> </soap:Envelope> Thanks! - hopefully it's the logon info that's wrong. I'll post back if otherwise. Quote Link to comment https://forums.phpfreaks.com/topic/260354-soap-help-needed/#findComment-1334619 Share on other sites More sharing options...
btherl Posted April 12, 2012 Share Posted April 12, 2012 Well that sounds better than "credentials not supplied". A change of error message is usually a good thing Also I noticed your namespaces are different now.. Anyway, is it working now? It's a week since your last post. Quote Link to comment https://forums.phpfreaks.com/topic/260354-soap-help-needed/#findComment-1336591 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.