Jump to content

SOAP Help Needed


iPixel

Recommended Posts

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@test.com__</mod:userName><!--Optional:-->
         </impl:principal>
         <impl:validationType>email</impl:validationType>
         <impl:validationId>email@test.com</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' => 'test@email.com');

$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@test.com</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!

Link to comment
Share on other sites

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@test.com</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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Any idea how i could do that? I tried re-working the parameters array like so :

 

<?php
$principalParameters = array('impl'=>array('mod' => array('userName' => 'test@email.com', 
									   	     'signupName' => 'org', 
										     'password' => 'orgpass'),
						   'validationType' => 'email', 
						   'validationId' => 'test@email.com'));
?>

 

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>test@email.com</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.

Link to comment
Share on other sites

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' => 'test@email.com', 'signupName' => 'org', 'password' => 'org123'), 'validationType' => 'email', 'validationId' => 'test@email.com'));

$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>test@email.com</ns1:userName>
		</ns2:principal>
		<ns2:validationType>email</ns2:validationType>
		<ns2:validationId>test@email.com</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.

Link to comment
Share on other sites

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.

Link to comment
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.