LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   SOAP server returns array using NuSOAP Library Not Working (https://www.linuxquestions.org/questions/programming-9/soap-server-returns-array-using-nusoap-library-not-working-4175490409/)

sobin.babu 01-07-2014 05:26 AM

SOAP server returns array using NuSOAP Library Not Working
 
Hi,

I am using NuSOAP library to write a SOAP server code. I am generating a return array and I am writing the return xml to a log folder and it shows that return was null. Here is the sample code I used,

$server->wsdl->addComplexType( 'Customers' => array('name' => 'Customers', 'type' => 'tns:ArrayOfWebCustomerDto', 'minOccurs' => '0', 'maxOccurs' => '1')));

$server->wsdl->addComplexType( 'ArrayOfWebCustomerDto', 'complexType', 'struct', 'all', '', array( 'CustomerInterface' => array('name' => 'CustomerInterface', 'type' => 'tns:WebCustomerDto', 'minOccurs' => '0', 'maxOccurs' => 'unbounded', 'nillable' => 'true' )) );

$server->wsdl->addComplexType( 'WebCustomerDto', 'complexType', 'struct', 'all', '', array( 'ChangeId' => array('name' => 'ChangeId','type' => 'xsd:int', 'minOccurs' => '1', 'maxOccurs' => '1', 'nillable' => 'true'), 'Username' => array('name' => 'Username', 'type' => 'xsd:string', 'minOccurs' => '0', 'maxOccurs' => '1'), 'Email' => array('name' => 'Email', 'type' => 'xsd:string', 'minOccurs' => '0', 'maxOccurs' => '1'), 'FirstName' => array('name' => 'FirstName', 'type' => 'xsd:string', 'minOccurs' => '0', 'maxOccurs' => '1'), 'LastName' => array('name' => 'LastName', 'type' => 'xsd:string', 'minOccurs' => '0', 'maxOccurs' => '1'), 'StreetAddress' => array('name' => 'StreetAddress', 'type' => 'xsd:string', 'minOccurs' => '0', 'maxOccurs' => '1'), 'StreetAddress2' => array('name' => 'StreetAddress2', 'type' => 'xsd:string', 'minOccurs' => '0', 'maxOccurs' => '1'), 'City' => array('name' => 'City', 'type' => 'xsd:string', 'minOccurs' => '0', 'maxOccurs' => '1'), 'ZipPostalCode' => array('name' => 'ZipPostalCode', 'type' => 'xsd:string', 'minOccurs' => '0', 'maxOccurs' => '1'), 'PhoneNumber' => array('name' => 'PhoneNumber', 'type' => 'xsd:string', 'minOccurs' => '0', 'maxOccurs' => '1') ) );

Here is the result xml format needed,
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ExchangeInterfaceDataResponse xmlns="http://test.com/">
<ExchangeInterfaceDataResult>
<Customers>
<CustomerInterface>
<ChangeId>int</ChangeId>
<Username>string</Username>
<Email>string</Email>
<FirstName>string</FirstName>
<LastName>string</LastName>
<StreetAddress>string</StreetAddress>
<StreetAddress2>string</StreetAddress2>
<City>string</City>
<ZipPostalCode>string</ZipPostalCode>
<PhoneNumber>string</PhoneNumber>
</CustomerInterface>
<CustomerInterface>
<ChangeId>int</ChangeId>
<Username>string</Username>
<Email>string</Email>
<FirstName>string</FirstName>
<LastName>string</LastName>
<StreetAddress>string</StreetAddress>
<StreetAddress2>string</StreetAddress2>
<City>string</City>
<ZipPostalCode>string</ZipPostalCode>
<PhoneNumber>string</PhoneNumber>
</CustomerInterface>
</Customers>
</ExchangeInterfaceDataResult>
</ExchangeInterfaceDataResponse>
</soap:Body>
</soap:Envelope>

This is the array I am generating,

Array
( [ExchangeInterfaceDataResult] => Array
(
[Customers] => Array
(
[CustomerInterface] => Array
(
[0] => Array
(
[ChangeId] => 1
[Username] => test1@test1.com
[Email] => test1@test1.com
[FirstName] => Test1
[LastName] => Test1
[StreetAddress] => Test 1
[StreetAddress2] =>
[City] => Test
[ZipPostalCode] => 1234
[PhoneNumber] => 123456
)

[1] => Array
(
[ChangeId] => 2
[Username] => test2@test2.com
[Email] => test2@test2.com
[FirstName] => Test2
[LastName] => Test2
[StreetAddress] => Test 2
[StreetAddress2] =>
[City] => Test
[ZipPostalCode] => 4321
[PhoneNumber] => 654321
)

)

)

)

)


All times are GMT -5. The time now is 06:53 PM.