NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Webservice not return variables sent to it.


Joined: 02 Jan 2004
Posts: 4
Reply with quote
I have a .NET webservice. I have successfully written pages to consume it using ASP, ASP.NET, and an HTML page using JaveScript, but I cannot get a PHP page to do so.

I am using NuSOAP, and I know the code is successfully contacting the webservice and returning information, but it does not return the variables I am sending it?!

The webservice is available to the public, so by using the code below, you should get the same results I do.

<?php
require_once('NuSOAP/nusoap-0.6.1/nusoap.php');
$client = new soapclient('http://www.astro-matchmaker.com/aspnet_sample/Simple_Test.asmx?wsdl', 'wsdl');
$param = array('strFirstName'=>'Dana','strLastName'=>'Williams');

$namespace = "urn:ns_www.astromatchmaker.com";
$response = $client->call("test", $param, $namespace);

// Display the request and response
echo '<h2>Request</h2>';
echo '' . htmlspecialchars($client->request, ENT_QUOTES) . '';
echo '<h2>Response</h2>';
echo '' . htmlspecialchars($client->response, ENT_QUOTES) . '';



// if a fault occurred, output error info
if (isset($fault)) {
print "Error: ". $fault;
}
else {
print "no errors";
}

print "<BR>";
print 'The response is:<pre>';
print "</pre><br>";
print(htmlentities($response));


// kill object
unset($client);


?>
View user's profileFind all posts by rrhandleSend private messageAIM Address
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Could you correct and test your function call according to the code below ?

Code:

 $client = new soapclient('http://www.astro-matchmaker.com/aspnet_sample/Simple_Test.asmx?wsdl', 'wsdl');
 $proxy = $client->getProxy();
 $param = array('strFirstName'=>'Dana','strLastName'=>'Williams');
 $namespace = "urn:ns_www.astromatchmaker.com";
 $response = $proxy->test($param, $namespace);


If after all you still don't get the results, I'd recommend you step through the code with debugger.
Also, don't forget to update to nusoap 0.6.3 that comes with phped.
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
The problem is that according to your WSDL
Code:
... operation name="test">
  <soap:operation soapAction="ns.www.astromatchmaker.com/test" style="document" />
 <input>
  <soap:body use="literal" />


literal means that you can pass literal parameter, not an array.

I'd recommend you use
Code:
<soap:body use="encoded" namespace="http://soapinterop.org/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />


Have a look at your WSDL.

Best regards,
Dmitri.
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 02 Jan 2004
Posts: 4
Reply with quote
Dmitri.

Thanks again for you thoughts.

I discovered I could make it work by setting the array to:
$params = array("<test xmlns='ns.www.astromatchmaker.com'><strFirstName>Robin</strFirstName><strLastName>Williams</strLastName></test>");

I suspect this has something to do with the "literatal" comment you made.

I would be afraid to change the WSDL as you suggested because it is the default setting, and other clients using ASP, ASP.NET, and Javascript are consuming it without a problem. Hate to throw everyone for a loop unless you can give me a good reason for doing so. Remember, I am new at this, so if you have words of wisdom to share, please speak them!
View user's profileFind all posts by rrhandleSend private messageAIM Address
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Oh, well,
if you believe literals would add your software a bit more portability and interoperability, great, just go ahead and pass the parameters as you did in a plain text Smile...
I think, we need to post it as a FAQ. Really not an obvious stuff , is it ?

Good luck,
Dmitri.
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 02 Jan 2004
Posts: 4
Reply with quote
FAQ's??? I think we need to tell the world!!!

Maybe it is because I am new to NuSoap and Webservices, but I'll tell you this, I have never been stuck for so long on a problem, nor have I ever posted a problem to so many forums and received so little feedback. I hate to think of the number of people who will get tripped up by using NuSoap to connect to a .NET webservice.

Anyways, while I did figure out a way to make it work, it was you who found the real answer. Kudos to the master; grasshopper will be forever thankful. Wink
View user's profileFind all posts by rrhandleSend private messageAIM Address
Webservice not return variables sent to it.
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic