I am using the built in SoapServer and SoapClient objects in PHP5 to serve and consume web services. Everything was working fine until I changed the SoapServer host to a different machine. Now, the call from the client to the server that is made works but returns a difficult to parse nested stdClass object instead of what I intended to return: an array containing other, associative, arrays.
For example, where it should return
[0] > Array ('key1'=>'value1','key2'=>'value2')
is now returning something to the effect of:
stdClass (Array([item]=>stdClass (Arr....etc. etc.
I've seen several references to this problem elsewhere but I have yet to see an applicable solution. The interesting thing is that I tried using nusoap instead of the built in PHP5 client but it returned the same strangely organized array hierarchy. So it seems that the problem lies in the server and perhaps the wsdl file.
Has anyone else experienced this problem?
Thanks for your help,
KarimInteresting ... can you post a linke to or a copy of the WSDL file? Aslo, what are the differences between the two machines. Namely are the versions of PHP identical and on the same OS?
Also, could you link to these other references?Thanks for your reply. You can see the wsdl file here:
<!-- m --><a class="postlink" href="http://www.probuiltconstruction.net/gallery/share.wsdl">http://www.probuiltconstruction.net/gallery/share.wsdl</a><!-- m -->
That's on the server that doesn't seem to be working quite right.
You can also see the version of php being used here:
<!-- m --><a class="postlink" href="http://www.probuiltconstruction.net/gallery/phpinfo.php">http://www.probuiltconstruction.net/gallery/phpinfo.php</a><!-- m -->
And here's the one that is working:
<!-- m --><a class="postlink" href="http://www.integratorportal.com/probuilt/share.wsdl">http://www.integratorportal.com/probuilt/share.wsdl</a><!-- m -->
with phpinfo here:
<!-- m --><a class="postlink" href="http://www.integratorportal.com/probuilt/phpinfo.php">http://www.integratorportal.com/probuilt/phpinfo.php</a><!-- m -->
And you can see the PHP versions are different.The ealier version of PHP seems to work fine. The later also has an older version of libxml. I doubt this makes a difference though.
Another thing you can do it turn on trace mode when creating the soap client and examining the the requests nad resposnees using Soapcleint->getLastResponse() and SoapClient->getLastRequest(). You can then check whether the server is returning the correct response and if not what is wrong with it.Thanks for the suggestion. I took a look at the differences. The version being returned from the working server includes type information:
<documents SOAP-ENC:arrayType="ns2:Map[25]" xsi:type="SOAP-ENC:Array"><item xsi:type="ns2:Map"><item><key xsi:type="xsd:string">id</key><value xsi:type="xsd:string">78</value></item>
Whereas the server that doesn't seem to be working quite right posts the following:
<documents><item><item><key>id</key><value>78</value></item>
That is likely the cause of the problem. The question is, what's making the difference given that it's exactly the same code that generates the response. Seems like it has to be either a different PHP setting or some difference in the way that these versions of PHP are working.
Thanks again,
KarimCould you post the code too? The XML you posted is incomplete. Was there not more returned by the server?
Also, did you write the wsdl file yourself? I am not all too familiar with it and I cannot find the location where a type Map is declared in the WSDL file.I can't post the entire response because it includes binary data and is very very large. But I have narrowed down the problem to the generated XML on the server side.
Where there is :
<item><key>filename</key><value>01.jpg</value></item>
It should actually read:
<item><key xsi:type="xsd:string">filename</key><value xsi:type="xsd:string">01.jpg</value></item>
So the question is why isn't the SoapServer class on the newer host not inserting type information when they are using the same WSDL file (which i've attached to this message)?
And, by the way, I have installed both versions of php (5.1.2 and 5.1.4) locally and queried the service and it worked in both cases. Not sure what's so special about this new server.I have a hunch that it might have something to do with the servers ability to make HTTP connections. The type information resides in XML Schema files and the server may be attempting to make an HTTP connection and get at the data in the name space URI's.
Does a simple http request work?
echo(file_get_contents("http://www.google.com/"));
If not, i am stumped. It might be worth trying to run the code on Windows and see if you hit the same problem. If so it oculd be an issue with the OS you are using.Hi all
I'am new to SOAP and I want write my first SOAP server / client
I wrote a very simple server (looks like works) and a client that not work.
The server:
<?php
require_once('SOAP/Server.php');
class Teszt {
function Teszt() {}
function sayHello($name) {
return "Hello $name";
}
}
?>
Is it enought for a simple server or i write something wrong?
And the client:
<?php
require_once('SOAP/Client.php');
$client = new Soap_Client("http://localhost/Soap/Simple_Server.php");
$params = array("name" => "Viktor");
$response = $client->call('sayHello',$params);
?>
If I print the $response i get: Object id #5
Plase help to write my first SOAP sever / client ..
Thx
For example, where it should return
[0] > Array ('key1'=>'value1','key2'=>'value2')
is now returning something to the effect of:
stdClass (Array([item]=>stdClass (Arr....etc. etc.
I've seen several references to this problem elsewhere but I have yet to see an applicable solution. The interesting thing is that I tried using nusoap instead of the built in PHP5 client but it returned the same strangely organized array hierarchy. So it seems that the problem lies in the server and perhaps the wsdl file.
Has anyone else experienced this problem?
Thanks for your help,
KarimInteresting ... can you post a linke to or a copy of the WSDL file? Aslo, what are the differences between the two machines. Namely are the versions of PHP identical and on the same OS?
Also, could you link to these other references?Thanks for your reply. You can see the wsdl file here:
<!-- m --><a class="postlink" href="http://www.probuiltconstruction.net/gallery/share.wsdl">http://www.probuiltconstruction.net/gallery/share.wsdl</a><!-- m -->
That's on the server that doesn't seem to be working quite right.
You can also see the version of php being used here:
<!-- m --><a class="postlink" href="http://www.probuiltconstruction.net/gallery/phpinfo.php">http://www.probuiltconstruction.net/gallery/phpinfo.php</a><!-- m -->
And here's the one that is working:
<!-- m --><a class="postlink" href="http://www.integratorportal.com/probuilt/share.wsdl">http://www.integratorportal.com/probuilt/share.wsdl</a><!-- m -->
with phpinfo here:
<!-- m --><a class="postlink" href="http://www.integratorportal.com/probuilt/phpinfo.php">http://www.integratorportal.com/probuilt/phpinfo.php</a><!-- m -->
And you can see the PHP versions are different.The ealier version of PHP seems to work fine. The later also has an older version of libxml. I doubt this makes a difference though.
Another thing you can do it turn on trace mode when creating the soap client and examining the the requests nad resposnees using Soapcleint->getLastResponse() and SoapClient->getLastRequest(). You can then check whether the server is returning the correct response and if not what is wrong with it.Thanks for the suggestion. I took a look at the differences. The version being returned from the working server includes type information:
<documents SOAP-ENC:arrayType="ns2:Map[25]" xsi:type="SOAP-ENC:Array"><item xsi:type="ns2:Map"><item><key xsi:type="xsd:string">id</key><value xsi:type="xsd:string">78</value></item>
Whereas the server that doesn't seem to be working quite right posts the following:
<documents><item><item><key>id</key><value>78</value></item>
That is likely the cause of the problem. The question is, what's making the difference given that it's exactly the same code that generates the response. Seems like it has to be either a different PHP setting or some difference in the way that these versions of PHP are working.
Thanks again,
KarimCould you post the code too? The XML you posted is incomplete. Was there not more returned by the server?
Also, did you write the wsdl file yourself? I am not all too familiar with it and I cannot find the location where a type Map is declared in the WSDL file.I can't post the entire response because it includes binary data and is very very large. But I have narrowed down the problem to the generated XML on the server side.
Where there is :
<item><key>filename</key><value>01.jpg</value></item>
It should actually read:
<item><key xsi:type="xsd:string">filename</key><value xsi:type="xsd:string">01.jpg</value></item>
So the question is why isn't the SoapServer class on the newer host not inserting type information when they are using the same WSDL file (which i've attached to this message)?
And, by the way, I have installed both versions of php (5.1.2 and 5.1.4) locally and queried the service and it worked in both cases. Not sure what's so special about this new server.I have a hunch that it might have something to do with the servers ability to make HTTP connections. The type information resides in XML Schema files and the server may be attempting to make an HTTP connection and get at the data in the name space URI's.
Does a simple http request work?
echo(file_get_contents("http://www.google.com/"));
If not, i am stumped. It might be worth trying to run the code on Windows and see if you hit the same problem. If so it oculd be an issue with the OS you are using.Hi all
I'am new to SOAP and I want write my first SOAP server / client
I wrote a very simple server (looks like works) and a client that not work.
The server:
<?php
require_once('SOAP/Server.php');
class Teszt {
function Teszt() {}
function sayHello($name) {
return "Hello $name";
}
}
?>
Is it enought for a simple server or i write something wrong?
And the client:
<?php
require_once('SOAP/Client.php');
$client = new Soap_Client("http://localhost/Soap/Simple_Server.php");
$params = array("name" => "Viktor");
$response = $client->call('sayHello',$params);
?>
If I print the $response i get: Object id #5
Plase help to write my first SOAP sever / client ..
Thx