Problem connecting gSoap server with PHP soap client

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi, I'm developing an application in C++ and I planned also for it to have a web frontent. I'm trying to do that with SOAP, and I used gSoap to generate the skeletons and the WSDL file. So far the server's done, and a test client made with gSoap works OK.


However, when I tried to use PHP5/SOAP to connect to the C++ server I'm not getting quite the results I'm expecting. The returning result is supposed to be an Array of both strings and integers, and the PHP client seems to get the types ok, however, it only returns the last element of the array.

I also tried PEAR::SOAP and I get the same results, so I'm not sure if it's a PHP thing or a SOAP thing.

If anyone has any idea of what's going on I would really appreciate some help.

 I'm posting the WSDL file, and some tests I ran with PHP.

 Thanks in advance,
 Benjamin.


Here's the WSDL file:

<?xml version="1.0" encoding="UTF-8"?>
<definitions name="snService"
 targetNamespace="urn:snService"
 xmlns:tns="urn:snService"
 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
 xmlns:xsd="http://www.w3.org/2001/XMLSchema";
 xmlns:ns="urn:snService"
 xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/";
 xmlns:WSDL="http://schemas.xmlsoap.org/wsdl/";
 xmlns="http://schemas.xmlsoap.org/wsdl/";>

<types>

 <schema targetNamespace="urn:snService"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xmlns:xsd="http://www.w3.org/2001/XMLSchema";
  xmlns:ns="urn:snService"
  xmlns="http://www.w3.org/2001/XMLSchema";
  elementFormDefault="unqualified"
  attributeFormDefault="unqualified">

  <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>

<complexType name="responseListBinding">
<sequence>
<element name="id" type="xsd:int" minOccurs="1" maxOccurs="1"/>
<element name="name" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
</sequence>
</complexType>


<complexType name="connectionNumberListBinding">
<sequence>
<element name="level" type="xsd:int" minOccurs="1" maxOccurs="1"/>
<element name="connections" type="xsd:int" minOccurs="1" maxOccurs="1"/>
</sequence>
</complexType>


 </schema>

</types>

<message name="getConnectionsListRequest">
 <part name="node" type="xsd:int"/>
 <part name="start-node" type="xsd:int"/>
 <part name="end-node" type="xsd:int"/>
 <part name="max-level" type="xsd:int"/>
</message>

<message name="getConnectionsListResponse">
 <part name="result" type="ns:responseList"/>
</message>

<message name="getPathRequest">
 <part name="start-node" type="xsd:int"/>
 <part name="end-node" type="xsd:int"/>
 <part name="max-level" type="xsd:int"/>
</message>

<message name="getPathResponse">
 <part name="result" type="ns:responseList"/>
</message>

<message name="countConnectionsRequest">
 <part name="node" type="xsd:int"/>
 <part name="max-level" type="xsd:int"/>
</message>

<message name="countConnectionsResponse">
 <part name="result" type="ns:connectionNumberList"/>
</message>

<portType name="snServicePortType">

<operation name="getConnectionsList">
<documentation>Service definition of function ns__getConnectionsList</documentation>
<input message="tns:getConnectionsListRequest"/>
<output message="tns:getConnectionsListResponse"/>
</operation>


 <operation name="getPath">
  <documentation>Service definition of function ns__getPath</documentation>
  <input message="tns:getPathRequest"/>
  <output message="tns:getPathResponse"/>
 </operation>

<operation name="countConnections">
<documentation>Service definition of function ns__countConnections</documentation>
<input message="tns:countConnectionsRequest"/>
<output message="tns:countConnectionsResponse"/>
</operation>
</portType>


<binding name="snService" type="tns:snServicePortType">
<SOAP:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>


<operation name="getConnectionsList">
<SOAP:operation style="rpc" soapAction=""/>
<input>
<SOAP:body use="encoded" namespace="urn:snService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<SOAP:body use="encoded" namespace="urn:snService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>


<operation name="getPath">
<SOAP:operation style="rpc" soapAction=""/>
<input>
<SOAP:body use="encoded" namespace="urn:snService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<SOAP:body use="encoded" namespace="urn:snService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>


<operation name="countConnections">
<SOAP:operation style="rpc" soapAction=""/>
<input>
<SOAP:body use="encoded" namespace="urn:snService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<SOAP:body use="encoded" namespace="urn:snService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>


<service name="snService">
 <documentation>gSOAP 2.6.2 generated service definition</documentation>
 <port name="snService" binding="tns:snService">
  <SOAP:address location="http://localhost:10000"/>
 </port>
</service>

</definitions>


Here's my PHP test code:

<?
$client = new SoapClient("snService.wsdl", array("trace"=>1,"exceptions"=>0));
$obj = $client->getConnectionsList(1,1,10,4);


print "<pre>\n";
print "Functions:\n". htmlspecialchars(print_r($client->__getTypes())) ."\n";
print "Request :\n".htmlspecialchars($client->__getLastRequest()) ."\n";
print "Response:\n".htmlspecialchars($client->__getLastResponse())."\n";
print "</pre>";


        print_r($obj);

        foreach($obj->item as $hit) {
                print("<br>-- $hit->id, $hit->name<br>\n");
        }

?>


And here's the output I get:

Array
(
    [0] => struct responseListBinding {
 int id;
 string name;
}
    [1] => struct connectionNumberListBinding {
 int level;
 int connections;
}
)
Functions:
1
Request :
<?xml version="1.0" encoding="UTF-8"?>

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:ns1="urn:snService" xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"; SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>

<SOAP-ENV:Body>
  <ns1:getConnectionsList>
      <node xsi:type="xsd:int">1</node>
      <start-node xsi:type="xsd:int">1</start-node>
      <end-node xsi:type="xsd:int">10</end-node>
      <max-level xsi:type="xsd:int">4</max-level>
   </ns1:getConnectionsList>
</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

Response:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:ns="urn:snService">


<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"; id="_0">
<ns:getConnectionsListResponse><result xsi:type="ns:responseList">
<item xsi:type="ns:responseListBinding"><id>220</id><name>adrien</name></item>
<item xsi:type="ns:responseListBinding"><id>276</id><name>aguste</name></item>
<item xsi:type="ns:responseListBinding"><id>997</id><name>antonio</name></item>
<item xsi:type="ns:responseListBinding"><id>1033</id><name>appuglie</name></item>
<item xsi:type="ns:responseListBinding"><id>1557</id><name>babs</name></item>
<item xsi:type="ns:responseListBinding"><id>2152</id><name>berek</name></item>
<item xsi:type="ns:responseListBinding"><id>2632</id><name>bokij</name></item>
<item xsi:type="ns:responseListBinding"><id>2665</id><name>bonita</name></item>
<item xsi:type="ns:responseListBinding"><id>3465</id><name>calli</name></item>
<item xsi:type="ns:responseListBinding"><id>3713</id><name>caryn</name></item>
</result>
</ns:getConnectionsListResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


stdClass Object ( [item] => SoapVar Object ( [enc_type] => 0 [enc_value] => stdClass Object ( [id] => 3713 [name] => caryn ) [enc_stype] => responseListBinding [enc_ns] => urn:snService ) )
-- ,


-- 3713, caryn

-- ,

-- ,

As you can see, the soap response is conformed by an array of 10 items.. however PHP is getting just the last one.

Thanks again,
Benjamin.

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux