Need example of GSOAP deserializing PHP array
| From: | (PHPDiscuss - PHP Newsgroups and mailing lists) | Date: | Wed, 12 May 2004 01:22:13 +0000 |
| Subject: | Need example of GSOAP deserializing PHP array | ||
| Groups: | php.soap | ||
| Request: | Send a blank email to php-soap+get-1516@lists.php.net to get a copy of this message | ||
Does anyone have an example of using a GSOAP client that sends a request
to a PEAR::SOAP PHP server and successfully deserializes the returned
array?
I have a simple example of a GSOAP requests that provides a person's name
and receives a greeting and age of a person. Here's the GSOAP header file:
<snip>
//gsoap ns schema namespace: urn:test_Server
typedef char * xsd__string;
typedef int xsd__int;
struct ns__sendbackmultResponse {
xsd__string _greeting_;
xsd__int _age_;
};
int ns__sendbackmult (
char * user_name,
struct ns__sendbackmultResponse * out
);
~
</snip>
The PHP code return the following XML:
<snip>
HTTP/1.1 200 OK
Date: Tue, 11 May 2004 14:43:03 GMT
Server: Apache/1.3.27 (Unix) PHP/4.3.1 DAV/1.0.3 mod_ssl/2.8.14
OpenSSL/0.9.6b
X-Powered-By: PHP/4.3.1
Status: 200 OK
Content-Length: 693
Connection: close
Content-Type: text/xml; charset=UTF-8
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
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:ns4="urn:test_Server"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns4:sendbackmultResponse>
<return xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[2]"
SOAP-ENC:offset="[0]">
<item xsi:type="xsd:string">Hello bonnie_girl</item>
<item
xsi:type="xsd:int">48</item></return></ns4:sendbackmultResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</snip>
Here is the calling C++ code:
<snip>
#include "soapH.h" /* include generated proxy and SOAP support */
#include "ns.nsmap"
const char server[] =
"http://192.168.2.102/test/pear_soap/examples/ws/testserver1.php";
int main(int argc, char **argv)
{
struct soap soap;
struct ns__sendbackmultResponse q;
soap_init(&soap);
if (soap_call_ns__sendbackmult(&soap, server,
"", "bonnie_girl", &q) == 0)
printf("Input was %s soap string returned - %s soap int returned
- %d\n", "bonnie_girl", q._greeting_, q._age_);
else
soap_print_fault(&soap, stderr);
soap_end(&soap);
soap_done(&soap);
return 0;
}
</snip>
However, the <item> tags are not fully deserialized and I receive the
following:
<snip>
[root@localhost sendback_mult]# sendback_mult
Input was bonnie_girl soap string returned -
<item xsi:type="xsd:string">Hello bonnie_girl</item>
<item xsi:type="xsd:int">48</item> soap int returned - 0
</snip>
Does anyone have any sample code that demonstrates how to correctly decode
a PHP array as part of the SOAP response?
Thanks in advance
Norb