Postanowiłem zbudować na podstawie artykułu z zenda.
Taj więc mam plik wsdl oraz zarejestrowaną metodę przy serwerze. Cały problem polega na tym, że po 2 stronie może być przeglądarka a nie skrypt php, gdyby było to połączenie php-soap-php bez problemu funkcjonowałoby serialize/unserialize.
Ale co zrobić w przypadku php-soap-js?
Korzystam z klas dostarczanych przez php.
Obecnie mam kod serwera:
<?php
class GetList {
private $users = array();
function __construct() {
// Pobranie danych z bazy i stworzenie
// tablicy user_id -> dane np:
// $this->users[$user_id] = wiersz z bazy.
$this->users[2
] = array('Lukasz', 'Dywicki', '87-300', 'Brodnica'); }
function getList($user_id) {
if (isset($this->users[$user_id])) { return $this->users[$user_id]; //tablica!
} else {
throw new SoapFault(\"Server\",\"Unknown User Id '$user_id', please/\");
}
}
}
$server = new SoapServer(\"stockquote.wsdl\");
$server->setClass(\"GetList\");
$server->handle();
?>
Na pewno jest jakiś sposób na przesłanie tej tablicy, tylko go nie znam

. W tej chwili gdy wywołam $client->getList(2) dostaję w wyniku Array..
A i plik wsdl:
<?xml version='1.0' encoding='UTF-8' ?>
<definitions name='GetUserList'
targetNamespace='http://example.org/StockQuote'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
<message name='getListRequest'>
<part name='symbol' type='xsd:string'/>
</message>
<message name='getListResponse'>
<part name='Result' type='xsd:array'/><!-- czy to jest poprawne? -->
</message>
<portType name='GetListPortType'>
<operation name='getList'>
<input message='tns:getListRequest'/>
<output message='tns:getListResponse'/>
</operation>
</portType>
<binding name='GetListBinding' type='tns:GetListPortType'>
<soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='getList'>
<soap:operation soapAction='urn:xmethods-delayed-quotes#getList'/>
<input>
<soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
<soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
</operation>
</binding>
<service name='GetListService'>
<port name='GetListPort' binding='GetListBinding'>
<soap:address location='http://download/xul-builder/www/soap/server3.php'/>
</port>
</service>
</definitions>
Czy ktoś, kto dobrnął tak daleko jest w stanie mi pomóc?
Poradziłem sobie z problememZdefiniowałem typ UserData oraz ArrayOfUser data, następnie napisałem odpowiednią funkcję w JS, która konwertuje odpowiedź do tablicy.
Ten post edytował splatch 15.05.2005, 17:16:05