burdeen wrote in message news:<1b62743a.0410280834.3c99ab79@posting.google. com>...[color=blue]
> I've been trying to return an array with PHP5 soap. Is this not
> supported? or am i doing it wrong? Seems to return on the last element
> in the array. In my WSDL i've defined my return type as a complex
> type:
>[/color]
So, I've solved my own problem... I believe it was the fault of the
WSDL, maybe PHP/Soap is sensitive to my weird namespaces. The thing
that helped the most was the PHP/Soap unit tests; i was able to write
a wsdl that was able to get the results i wanted. take a look here:
http://cvs.php.net/pecl/soap/tests/schema
Hopefully this will help someone else. There is very little (or no?)
documents yet on how to return complex types from the server... so
here is an example. Server will return an array of strings to the
client as SOAP-ENC:arrayType string[].
client2.php ===
<?php
$client = new SoapClient("http://localhost:84/server2.wsdl",
array("trace"=>1,"exceptions"=>1));
$test = $client->test();
var_dump($test);
?>
server2.php ===
<?php
function test() {
return array("ham","cheese","bacon");
}
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$server = new SoapServer("server2.wsdl");
$server->addFunction("test");
$server->handle();
?>
server2.wsdl ===
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://test-uri/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:ns="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:ns1="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://test-uri/" name="InteropTest">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://test-uri/">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
<complexType name="testType">
<complexContent>
<restriction base="SOAP-ENC:Array">
<attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="string[]"/>
</restriction>
</complexContent>
</complexType>
</schema>
</wsdl:types>
<message name="testMessage">
<part name="testParam" type="tns:testType"/>
</message>
<portType name="testPortType">
<operation name="test">
<output message="tns:testMessage"/>
</operation>
</portType>
<binding name="testBinding" type="tns:testPortType">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="test">
<soap:operation soapAction="test" style="document"/>
<output>
<soap:body parts="body" use="literal"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://test-uri/"/>
</output>
</operation>
</binding>
<service name="testService">
<port name="testPort" binding="tns:testBinding">
<soap:address location="http://localhost:84/server2.php?wsdl"/>
</port>
</service>
</wsdl:definitions>