Sobin Babu - 2013-12-05

Hi,

I am in the process of developing a SOAP module for my project. I am new to SOAP coding. I am using NuSOAP library to handle the soap response and requests.
I need to create a client to generate a SOAP request in the following format to my SOAP server function.

<?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:Header>
<AuthHeader xmlns="http://yoursite.com/">
<Username>string</Username>
<Password>string</Password>
</AuthHeader>
</soap:Header>
<soap:Body>
<UpdateData xmlns="http://yoursite.com/">
<data>
<Products>
<ProductInterface>
<Name>string</Name>
<ShortDescription>string</ShortDescription>
<FullDescription>string</FullDescription>
<ProductVariants xsi:nil="true" />
<Deleted>boolean</Deleted>
</ProductInterface>
<ProductInterface>
...............
</ProductInterface>
</Products>
<Orders>
<OrderInterface>
<OrderId>int</OrderId>
<OrderStatusId>int</OrderStatusId>
<Username>string</Username>
</OrderInterface>
<OrderInterface>
..............
</OrderInterface>
</Orders>
</data>
</UpdateInterfaceData>
</soap:Body>
</soap:Envelope>

I wrote a wsdl file in the following format,

<?xml version="1.0" encoding="ISO-8859-1"?>
<definitions 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:tns="urn:SOAPAction" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:SOAPAction">
<types>
<xsd:schema targetNamespace="urn:SOAPAction"
>
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
<xsd:complexType name="data">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:UpdateInterface[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="UpdateInterface">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:UpdateInterfaceItem[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="UpdateInterfaceItem">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:UpdateInterfaceItems[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="UpdateInterfaceItems">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:UpdateInterfaceValues[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="UpdateInterfaceValues">
<xsd:all>
<xsd:element name="Username" type="xsd:string"/>
<xsd:element name="Password" type="xsd:string"/>
<xsd:element name="Name" type="xsd:string"/>
<xsd:element name="ShortDescription" type="xsd:string"/>
<xsd:element name="FullDescription" type="xsd:string"/>
<xsd:element name="OrderId" type="xsd:int"/>
<xsd:element name="OrderStatusId" type="xsd:int"/>
<xsd:element name="Email" type="xsd:string"/>
<xsd:element name="FirstName" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="UpdateResult">
<xsd:all>
<xsd:element name="Name" type="xsd:string"/>
<xsd:element name="ShortDescription" type="xsd:string"/>
<xsd:element name="FullDescription" type="xsd:string"/>
<xsd:element name="OrderId" type="xsd:int"/>
<xsd:element name="OrderStatusId" type="xsd:int"/>
<xsd:element name="Username" type="xsd:string"/>
<xsd:element name="Email" type="xsd:string"/>
<xsd:element name="FirstName" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="UpdateReturn">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:UpdateResult[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
</types>
<message name="UpdateInterfaceRequest">
<part name="params" type="tns:data" /></message>
<message name="UpdateInterfaceResponse">
<part name="return" type="tns:UpdateReturn" /></message>
<portType name="SOAPActionPortType">
<operation name="UpdateInterface">
<documentation>Update Interface</documentation>
<input message="tns:UpdateInterfaceRequest"/>
<output message="tns:UpdateInterfaceResponse"/>
</operation>
</portType>
<binding name="SOAPActionBinding" type="tns:SOAPActionPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="UpdateInterface">
<soap:operation soapAction="urn:soapaction#UpdateInterface" style="rpc"/>
<input><soap:body use="encoded" namespace="urn:soapaction" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace="urn:soapaction" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
</binding>
<service name="SOAPAction">
<port name="SOAPActionPort" binding="tns:SOAPActionBinding">
<soap:address location="http://localhost/soapactnew/newfolder5/soap-action.php"/>
</port>
</service>
</definitions>

I am getting the following data in the SOAP server function as array with numeric key values,

Array
(
[0] => Array
(
[0] => Array
(
[0] => Array
(
[0] => Array
(
[Username] => myusername
[Password] => mypassword
)

                    )

            )

    )

[1] => Array
    (
        [0] => Array
            (
                [0] => Array
                    (
                        [0] => Array
                            (
                                [Name] => Product 1
                                [ShortDescription] => ShortDescription 1
                                [FullDescription] => FullDescription 1
                            )

                        [1] => Array
                            (
                                .......................................
                            )

                        [2] => Array
                            (
                               .......................................
                            )

                    )

            )

        [1] => Array
            (
                [0] => Array
                    (
                        [0] => Array
                            (
                                [Username] => username
                                [OrderId] => 1
                                [OrderStatusId] => 1
                            )

                        [1] => Array
                            (
                                .......................................
                            )

                        [2] => Array
                            (
                                .......................................
                            )

                    )

            )

I am expecting the array to have tag names as the array key. But unfortunately I am getting the array key as numeric values.
Can anybody help me to find a way to generate the array in the server with tagname as key value so that I can identify the data properly.

I am in the middle of a developement process and I am already behind the schedule. So Please help me....