Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting empty response from web service build with php
    primarykey
    data
    text
    <p>I wanted to create a web service with php and zend framework. The server side code is as follow:</p> <p><strong>csiService.php:</strong></p> <pre><code>&lt;?php require_once 'Zend/Loader.php'; require_once 'CSI.php'; $WSDL_URI="http://csi.chemicalseeker.com/csiService.php?WSDL"; if(isset($_GET["WSDL"])) { Zend_Loader::loadClass('Zend_Soap_AutoDiscover'); Zend_Loader::loadClass('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence'); $autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence'); $autodiscover-&gt;setBindingStyle(array('style' =&gt; 'document')); $autodiscover-&gt;setOperationBodyStyle(array('use' =&gt; 'literal')); $autodiscover-&gt;setClass('CSI'); $autodiscover-&gt;handle(); } else { Zend_Loader::loadClass('Zend_Soap_Server'); $server = new Zend_Soap_Server($WSDL_URI); $server-&gt;setClass('CSI'); $server-&gt;handle(); } ?&gt; </code></pre> <p>Which includes the <strong>CSI.php</strong>:</p> <pre><code>&lt;?php class CSI { /** * @return string */ function helloWorld() { return("Hello"); } } ?&gt; </code></pre> <p>*<em>I edited the host file, in order to bind the domain "csi.chemicalseeker.com" to 127.0.0.1</em> The WSDL just works well as I visit "http://csi.chemicalseeker.com/csiService.php?WSDL" in my browser:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://csi.chemicalseeker.com/csiService.php" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="CSI" targetNamespace="http://csi.chemicalseeker.com/csiService.php"&gt; &lt;types&gt; &lt;xsd:schema targetNamespace="http://csi.chemicalseeker.com/csiService.php"&gt; &lt;xsd:element name="helloWorld"&gt; &lt;xsd:complexType /&gt; &lt;/xsd:element&gt; &lt;xsd:element name="helloWorldResponse"&gt; &lt;xsd:complexType&gt; &lt;xsd:sequence&gt; &lt;xsd:element name="helloWorldResult" type="xsd:string" /&gt; &lt;/xsd:sequence&gt; &lt;/xsd:complexType&gt; &lt;/xsd:element&gt; &lt;/xsd:schema&gt; &lt;/types&gt; &lt;portType name="CSIPort"&gt; &lt;operation name="helloWorld"&gt; &lt;documentation&gt;@return string&lt;/documentation&gt; &lt;input message="tns:helloWorldIn" /&gt; &lt;output message="tns:helloWorldOut" /&gt; &lt;/operation&gt; &lt;/portType&gt; &lt;binding name="CSIBinding" type="tns:CSIPort"&gt; &lt;soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /&gt; &lt;operation name="helloWorld"&gt; &lt;soap:operation soapAction="http://csi.chemicalseeker.com/csiService.php#helloWorld" /&gt; &lt;input&gt; &lt;soap:body use="literal" /&gt; &lt;/input&gt; &lt;output&gt; &lt;soap:body use="literal" /&gt; &lt;/output&gt; &lt;/operation&gt; &lt;/binding&gt; &lt;service name="CSIService"&gt; &lt;port name="CSIPort" binding="tns:CSIBinding"&gt; &lt;soap:address location="http://csi.chemicalseeker.com/csiService.php" /&gt; &lt;/port&gt; &lt;/service&gt; &lt;message name="helloWorldIn"&gt; &lt;part name="parameters" element="tns:helloWorld" /&gt; &lt;/message&gt; &lt;message name="helloWorldOut"&gt; &lt;part name="parameters" element="tns:helloWorldResponse" /&gt; &lt;/message&gt; &lt;/definitions&gt; </code></pre> <p>I also wrote a php client file called CSIClient.php and visited it from the browser:</p> <p><strong>CSIClient.php</strong></p> <pre><code>&lt;?php require_once 'Zend/Loader.php'; require_once 'CSI.php'; Zend_Loader::loadClass('Zend_Soap_Client'); $WSDL_URI="http://csi.chemicalseeker.com/csiService.php?WSDL"; $client = new Zend_Soap_Client($WSDL_URI); echo('&lt;pre&gt;'); var_dump($client-&gt;helloWorld()); echo('&lt;/pre&gt;'); ?&gt; </code></pre> <p>The result is expected to be a string with the content of "Hello", but it shows an empty stdObject:</p> <pre><code>object(stdClass)#3 (0) { } </code></pre> <p>I can get the function list and type list via "$client->getFunctions()" and "$client->getTypes()", it means the "CSI" class has been connected to the web service successfully. But the result can not be returned correctly.</p> <p>I've also tried other methods to invoke the web service. I used Flash Builder to call the helloWorld() function, the response from server is as follow:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://csi.chemicalseeker.com/csiService.php"&gt; &lt;SOAP-ENV:Body&gt; &lt;ns1:helloWorldResponse/&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>As we can see that the expected result "Hello" is not included in the SOAP envelope either. Did I missed something important or made some mistakes in my code? Help me please if you have a clue. Thank you!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload