Dawno, dawno temu wyprodukowałem taki kod:
var zupa = new Array();
function SOAPParameter(name,value) {
this.name = name;
this.value = value;
return this;
}
function getIds(id) {
if( id == undefined ) {
id = 0;
}
mySOAPCall = new SOAPCall();
mySOAParametr = new SOAPParameter('id',id);
arr = new Array(mySOAParametr);
object = new Array();
mySOAPCall.transportURI = "http://splatch.hopto.org/xul-builder/www/soap/server3.php"
mySOAPCall.encode(0, "getList", object, 0, null, arr.length, arr);
response = mySOAPCall.invoke();
r = response.getParameters(false, {});
result = new Array();
for( i in r ) {
result[ r[i].name ] = r[i].value;
}
appendChildsFromResult(result);
}
function appendChildsFromResult(result) {
chi = new Array();
li1 = document.createElement('listitem');
for( i in result ) {
chi[chi.length] = create_child(result[i]);
}
for( i in chi ) {
li1.appendChild(chi[i]);
}
listbox = window.document.getElementById('listMethodsListBox');
listbox.appendChild(li1);
}
function getAll() {
mySOAPCall = new SOAPCall();
object = new Array();
mySOAPCall.transportURI = "http://splatch.hopto.org/xul-builder/www/soap/server4.php"
mySOAPCall.encode(0, "getAll", object, 0, null, 0, null);
response = mySOAPCall.invoke();
z = soap_response_to_array(response);
for( i in z ) {
appendChildsFromResult(z[i]);
}
}
function soap_response_to_array(r) {
data = new Array();
r = r.getParameters(false,{});
r = r[0].element.childNodes;
for( i = 0; i < r.length; i++ ) {
o = r[i].childNodes;
data[i] = new Array();
for( j = 0; j < o.length; j++ ) {
data[i][ o[j].childNodes[0].childNodes[0].data ] = o[j].childNodes[1].childNodes[0].data;
}
}
return data;
}
function create_child(label) {
child = document.createElement('listcell');
child.setAttribute('label',label);
return child;
}
function var_dump(obj) {
str = '';
for( i in obj ) {
str = str + i +"=>"+ obj[i] +"\n";
}
return str;
}
Wygląd wiersza:
<?php
'imie' => 'Lukasz',
'nazwisko' => 'Pak',
'kod_kreskowy' =>'82-213',
'miasto' =>'Wąbrzeźno');
?>
WSDL:
<?xml version='1.0' encoding='UTF-8' ?>
<definitions name='Get'
targetNamespace='http://download/xul-builder/www/soap/stocquote.wsdl'
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/'>
<types>
<xsd:schema targetNamespace="http://www.xmethods.net/interfaces/query.xsd">
<xsd:complexType name="UserData">
<xsd:all>
<xsd:element name="imie" nillable="true" type="xsd:string"/>
<xsd:element name="nazwisko" nillable="true" type="xsd:string"/>
<xsd:element name="kod_kreskowy" nillable="true" type="xsd:string"/>
<xsd:element name="miasto" nillable="true" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="ArrayOfUserData">
<xsd:complexContent>
<xsd:restriction base="soapenc:Array">
<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:UserData[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
</types>
<message name='getListRequest'>
<part name='id' type='xsd:int'/>
</message>
<message name='getListResponse'>
<part name="data" type="xsd:UserData"/>
</message>
<message name='GetAllRequest'/>
<message name='GetAllResponse'>
<part name="Result" type="xsd:ArrayOfUserData"/>
</message>
<portType name='GetPortType'>
<operation name='getList'>
<input message='tns:getListRequest'/>
<output message='tns:getListResponse'/>
</operation>
<operation name='GetAll'>
<input message='tns:GetAllRequest'/>
<output message='tns:GetAllResponse'/>
</operation>
</portType>
<binding name='GetBinding' type='tns:GetPortType'>
<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>
<operation name='GetAll'>
<soap:operation soapAction='urn:xmethods-delayed-quotes#GetAll'/>
<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='GetService'>
<port name='GetPort' binding='GetBinding'>
<soap:address location='http://download/xul-builder/www/soap/server4.php'/>
</port>
</service>
</definitions>