Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: WS, Nusoap i przesyłanie złożonych tablic
Forum PHP.pl > Forum > PHP
masterix
Witam,

Mam taki problem: piszę prosty webservice i niestety nie mogę się uporać ze zwracaniem przez funkcję tablicy tablic asocjacyjnych. Próbowałem tak jak jest to zrobione tutaj: http://www.koders.com/php/fidD92AAAEC4C749...nusoap+array#L9
Ale niestety nie udało mi się. Otrzymuję zamiast tablicy wartość false.

Wrzucam kod WSDL, może znajdziecie błąd:
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 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/" xmlns:tns="http://localhost/adwordsapi" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://localhost/adwordsapi">
  3. <types><xsd:schema targetNamespace="http://localhost/adwordsapi"
  4. >
  5. <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
  6. <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
  7. <xsd:complexType name="ArrayOfstring">
  8.  <xsd:complexContent>
  9.   <xsd:restriction base="SOAP-ENC:Array">
  10.    <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="string[]"/>
  11.   </xsd:restriction>
  12.  
  13.  </xsd:complexContent>
  14. </xsd:complexType>
  15. <xsd:complexType name="GroupObject">
  16.  <xsd:sequence>
  17.   <xsd:element name="lwPos" type="xsd:float"/>
  18.   <xsd:element name="upPos" type="xsd:float"/>
  19.   <xsd:element name="text" type="xsd:string"/>
  20.  </xsd:sequence>
  21. </xsd:complexType>
  22.  
  23. <xsd:complexType name="ArrayOfGroupObject">
  24.  <xsd:complexContent>
  25.   <xsd:restriction base="SOAP-ENC:Array">
  26.    <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:GroupObject[]"/>
  27.   </xsd:restriction>
  28.  </xsd:complexContent>
  29. </xsd:complexType>
  30. </xsd:schema>
  31. </types>
  32. <message name="helloRequest"><part name="parm" type="xsd:string" /></message>
  33.  
  34. <message name="helloResponse"><part name="helloResponse" type="xsd:string" /></message>
  35. <message name="userRequest"><part name="func" type="xsd:string" /><part name="params" type="tns:ArrayOfstring" /></message>
  36. <message name="userResponse"><part name="userResponse" type="tns:ArrayOfstring" /></message>
  37. <message name="groupRequest"><part name="params" type="tns:ArrayOfstring" /></message>
  38. <message name="groupResponse"><part name="groupResponse" type="tns:ArrayOfGroupObject" /></message>
  39. <portType name="GForgeAPIPortType"><operation name="hello"><input message="tns:helloRequest"/><output message="tns:helloResponse"/></operation><operation name="user"><input message="tns:userRequest"/><output message="tns:userResponse"/></operation><operation name="group"><input message="tns:groupRequest"/><output message="tns:groupResponse"/></operation></portType>
  40. <binding name="GForgeAPIBinding" type="tns:GForgeAPIPortType"><soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/><operation name="hello"><soap:operation soapAction="http://localhost/adwordsapi/soap2.php/hello" style="rpc"/><input><soap:body use="encoded" namespace="http://localhost/adwordsapi" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input><output><soap:body use="encoded" namespace="http://localhost/adwordsapi" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output></operation><operation name="user"><soap:operation soapAction="http://localhost/adwordsapi/soap2.php/user" style="rpc"/><input><soap:body use="encoded" namespace="http://localhost/adwordsapi" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input><output><soap:body use="encoded" namespace="http://localhost/adwordsapi" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output></operation><operation name="group"><soap:operation soapAction="http://localhost/adwordsapi/soap2.php/group" style="rpc"/><input><soap:body use="encoded" namespace="http://localhost/adwordsapi" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input><output><soap:body use="encoded" namespace="http://localhost/adwordsapi" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output></operation></binding>
  41. <service name="GForgeAPI"><port name="GForgeAPIPort" binding="tns:GForgeAPIBinding"><soap:address location="http://localhost/adwordsapi/soap2.php"/></port></service>
  42. </definitions>


Kod klienta:
  1. <?php
  2. $client = new soapclientNusoap( 'htt://localhost/adwordsapi/soap2.php?wsdl', true );
  3.      $result_array =  array( 'XYZ', 'ABC' );
  4.      $response = $client->call( 'group', array( "XYZ", "ABC" ) );
  5.      var_dump( $response );
  6. ?>


Natomaist var_dump( group(array( "XYZ", "ABC" ))); w serwerze dał mi oczekiwany rezultat.

Liczę na Waszą pomoc smile.gif Może być także działający przykład - nie mam nic przeciwko winksmiley.jpg

pzdr.
Soulik
Jeżeli rozwiązałeś swój problem w tamtym czasie daj znać. Jestem w dużej potrzebie.

Pozdrawiam
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.