Thanks Alberto and Amila.
It worked!

/Pär

Date: Fri, 11 Sep 2009 09:54:15 +0530
Subject: Re: problem with returning array of objects
From: [email protected]
To: [email protected]

change the element into a complex type.


                <complexType  name="Atc">
                    <sequence>
                        <element name="atcCode" type="xsd:string"/>

                        <element name="lev" type="xsd:int"/>
                        <element name="textSv" type="xsd:string"/>
                        <element name="MAX_LEN_atcCode" type="xsd:string"/>

                        <element name="MAX_LEN_textSv" type="xsd:string"/>
                    </sequence>
                </complexType>

thanks,
Amila.
           


On Thu, Sep 10, 2009 at 6:15 PM, Pär Malmqvist <[email protected]> 
wrote:






Hello!

Thanks Amila för your reply.
I changed the row <element maxOccurs="unbounded" minOccurs="0" name="return" 
type="tns:Atc"/>
into <complexType maxOccurs="unbounded" minOccurs="0" name="return" 
type="tns:Atc"/>

as you suggested.

When I check the generated file GetAtcsByAtcCodeResponse.java this time I see 
no field at all that could hold the array value.

What could be the problem? 

/Pär Malmqvist











Date: Wed, 9 Sep 2009 19:18:28 +0530
Subject: Re: problem with returning array of objects
From: [email protected]

To: [email protected]



On Wed, Sep 9, 2009 at 6:48 PM, Pär Malmqvist <[email protected]> wrote:







Hello!

I have problem with generating server side code from my wsdl file.
The wsdl file contains a service, getAtcsByAtcCode, that should return an array 
of Atc-objects.
But my generated code returns OMElement[] instead. 



I use this wsdl file:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://main.sol";
    xmlns:apachesoap="http://xml.apache.org/xml-soap"; 


        xmlns:tns="http://main.sol";
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";


    xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/";
    xmlns:xsd="http://www.w3.org/2001/XMLSchema";>


    <wsdl:types>
        <schema elementFormDefault="qualified" targetNamespace="http://main.sol";
            xmlns="http://www.w3.org/2001/XMLSchema";


            xmlns:apachesoap="http://xml.apache.org/xml-soap";
            xmlns:tns="http://main.sol"; xmlns:intf="http://main.sol";


            xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";>
            
                        <element name="Atc">
                <complexType>


                    <sequence>
                        <element name="atcCode" type="xsd:string"/>
                        <element name="lev" type="xsd:int"/>


                        <element name="textSv" type="xsd:string"/>
                        <element name="MAX_LEN_atcCode" type="xsd:string"/>
                        <element name="MAX_LEN_textSv" type="xsd:string"/>


                    </sequence>
                </complexType>
            </element>


            <element name="getAtcsByAtcCode">
                <complexType>


                    <sequence>
                        <element name="atcCode" type="xsd:string"/>
                    </sequence>
                </complexType>
            </element>


            
            <element name="getAtcsByAtcCodeResponse">
                <complexType>
                    <sequence>
                        <element maxOccurs="unbounded" minOccurs="0" 
name="return" type="tns:Atc"/>



this type should be a complex type. not an element.

thanks,
Amila.


                    </sequence>
                </complexType>
            </element>
            
            <element name="SolException">
                <complexType>


                    <sequence>
                        <element name="errorCode" type="xsd:int"/>
                        <element name="errorMsg" type="xsd:string"/>


                    </sequence>
                </complexType>
            </element>
            
        </schema>
    </wsdl:types>
    
    <wsdl:message name="getAtcsByAtcCodeRequest">


        <wsdl:part element="tns:getAtcsByAtcCode" name="parameters"/>
    </wsdl:message>
    
    <wsdl:message name="getAtcsByAtcCodeResponse">
        <wsdl:part element="tns:getAtcsByAtcCodeResponse" name="return"/>


    </wsdl:message>
    
    <wsdl:message name="SolExceptionMessage">
        <wsdl:part element="tns:SolException" name="fault"/>
    </wsdl:message>


    
    <wsdl:portType name="SolDB2">
        <wsdl:operation name="getAtcsByAtcCode">
            <wsdl:input message="tns:getAtcsByAtcCodeRequest" 
name="getAtcsByAtcCodeRequest"/>


            <wsdl:output message="tns:getAtcsByAtcCodeResponse" 
name="getAtcsByAtcCodeResponse"/>
            <wsdl:fault message="tns:SolExceptionMessage" 
name="SolExceptionFault"/>


        </wsdl:operation>
    </wsdl:portType>
    
    <wsdl:binding name="SolDB2SoapBinding" type="tns:SolDB2">
        <wsdlsoap:binding style="document" 
transport="http://schemas.xmlsoap.org/soap/http"/>


        <wsdl:operation name="getAtcsByAtcCode">
            <wsdlsoap:operation soapAction=""/>
            <wsdl:input name="getAtcsByAtcCodeRequest">
                <wsdlsoap:body use="literal"/>


            </wsdl:input>
            <wsdl:output name="getAtcsByAtcCodeResponse">
                <wsdlsoap:body use="literal"/>
            </wsdl:output>
            <wsdl:fault name="SolExceptionFault">


                <wsdlsoap:fault name="SolExceptionFault" use="literal"/>
            </wsdl:fault>
        </wsdl:operation>
    </wsdl:binding>
    
    <wsdl:service name="SolDB2">


        <wsdl:port binding="tns:SolDB2SoapBinding" name="SolDB2">
            <wsdlsoap:address 
location="http://localhost:8080/axis2/services/SolDB2"/>


        </wsdl:port>
    </wsdl:service>
    
</wsdl:definitions>



I generate my service with the following ant task:

(lib directory contains all Axis2 jars) 


<target name="gen.sol.src.service">



            <delete dir="soltarget"/>
            <mkdir dir="soltarget"/>
            <mkdir dir="soltarget/classes"/>

            <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true">


                <arg line="-uri SolDB2.wsdl"/>
                <arg line="-d adb"/>
                <arg line="-ss"/>
                <arg line="-sd"/>


                <arg line="-o soltarget"/>
                <classpath>
                    <fileset dir=".\lib">
                          <include name="*.jar"/>


                    </fileset>
                </classpath>
            </java>
</target>



When I check the generated file GetAtcsByAtcCodeResponse.java I see that the 
object contains an


array of org.apache.axiom.om.OMElement[] instead of sol.main.Atc[].


Is there something wrong with my wsdl file?
Or is this the way to do when returning array of objects at the service side?

Regards



Pär Malmqvist



Share your memories online with anyone you want anyone you want.




-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/

With Windows Live, you can organize, edit, and  share your photos.



-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/

_________________________________________________________________
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx

Reply via email to