|
From: Josef Z. <za...@hw...> - 2002-11-26 17:04:32
|
Hi folks,
I have serious problem with catching array results in client
application. I'm using Nusoap version 0.6.3 a php 4.2.3. Server side
is built on MS SQL server with webservices accessible whereby SOAP.
I would like get array with two parts, "kod" and "nazev". So I wrote
small piece of php code:
-------------------
<?php
require_once('nusoap.php');
$uname = 'myname';
$upasswd = 'xxx';
$serverpath = 'http://www.xxxx.cz/webservices/ciselniky.asmx';
$SOAPAction = 'http://www.xxxx.cz/webservices/Kategorie';
$namespace = 'http://www.xxxx.cz/webservices';
$param=array('strUzivatelskeJmeno'=>$uname,'strUzivatelskeHeslo'=>$upa
sswd);
$client = new soapclient($serverpath);
$result = $client->call('Kategorie',$param,$namespace,$SOAPAction);
if($client->fault){
echo "FAULT: <p>Code: {$client->faultcode} <br />";
echo "String: {$client->faultstring} </p>";
}
unset($client);
foreach ($result['diffgram']['NewDataSet'] as $r)
{
echo $r['kod']."\n";
echo $r['nazev']."\n";
}
-------------------------
But... variable $result hold only the last pair of "kod"-"nazev". I
known there is about 31 pairs.
There is catched communication by the packet sniffer:
------------------------
POST /webservices/ciselniky.asmx HTTP/1.0
User-Agent: NuSOAP/0.6.3
Host: www.xxxx.cz
Content-Type: text/xml; charset="ISO-8859-1"
Content-Length: 650
SOAPAction: "http://www.xxxx.cz/webservices/Kategorie"
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope SOAP-
ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
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:si="http://soapinterop.org/xsd">
<SOAP-ENV:Body>
<Kategorie xmlns="http://www.xxxx.cz/webservices">
<strUzivatelskeJmeno
xsi:type="xsd:string">myname</strUzivatelskeJmeno>
<strUzivatelskeHeslo
xsi:type="xsd:string">xxx</strUzivatelskeHeslo>
</Kategorie>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
+=+=+=+=+=+=+=+=+=+=+=+=+
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Tue, 26 Nov 2002 16:13:53 GMT
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Content-Length: 4541
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<KategorieResponse xmlns="http://www.xxxx.cz/webservices">
<KategorieResult>
<xs:schema id="NewDataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-
microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true"
msdata:Locale="cs-CZ">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="kod" type="xs:string" minOccurs="0" />
<xs:element name="nazev" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Table diffgr:id="Table1" msdata:rowOrder="0">
<kod>PROJEKCE</kod>
<nazev>Comodity1</nazev>
</Table>
.
.so and so....
.
<Table diffgr:id="Table32" msdata:rowOrder="31">
<kod>HW - UPS</kod>
<nazev>ZALOZNI ZDROJE</nazev>
</Table>
</NewDataSet>
</diffgr:diffgram>
</KategorieResult>
</KategorieResponse>
</soap:Body>
</soap:Envelope>
-----------------------------------
Variable $result reported by the php var_dump:
-----------------------------------
array(2) {
["schema"]=>
array(1) {
["element"]=>
array(1) {
["complexType"]=>
array(1) {
["choice"]=>
array(1) {
["element"]=>
array(1) {
["complexType"]=>
array(1) {
["sequence"]=>
array(1) {
["element"]=>
string(0) ""
}
}
}
}
}
}
}
["diffgram"]=>
array(1) {
["NewDataSet"]=>
array(1) {
["Table"]=>
array(2) {
["kod"]=>
string(8) "HW - UPS"
["nazev"]=>
string(17) "ZALOZNI ZDROJE"
}
}
}
}
-----------------------------
As you can see there is the only one catched pair "kod"-"nazev". I'm
not sure is there is bug in NuSopap, MS server or myself. If somebody
can, please help me with guidance. Thanks.
Josef
|