facebook

webservice retuning list of objects

  1. MyEclipse Archived
  2.  > 
  3. Web Services
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #272291 Reply

    patel_123
    Member

    hi

    i am trying to return list of objects from my web sevice.I am using myeclipse 5.5M2 IDE.
    This is my webservice code:
    @WebMethod()
    public List<CustomerInfo> getAccountList()
    {
    Query query=em.createQuery(“from CustomerInfo c”);
    List<CustomerInfo>list=query.getResultList();

    return list;
    }

    But the problem is at the client side.My eclipse provides wizard to create client automatically.

    when i tried to access the above web method the return type is marked as void at the EndpointInterface.But actually it is retuning List..

    could anybody tell me where i went wrong?

    #272292 Reply

    patel_123
    Member

    well this is generated WSDL file,

    <definitions name=”CustomerRegisteration” targetNamespace=”http://wb1-329:8080&#8243; xmlns=”http://schemas.xmlsoap.org/wsdl/&#8221; xmlns:ns1=”http://customer/jaws&#8221; xmlns:soap=”http://schemas.xmlsoap.org/wsdl/soap/&#8221; xmlns:tns=”http://wb1-329:8080&#8243; xmlns:xsd=”http://www.w3.org/2001/XMLSchema”&gt;
    – <types>
    – <schema elementFormDefault=”qualified” targetNamespace=”http://wb1-329:8080&#8243; xmlns=”http://www.w3.org/2001/XMLSchema&#8221; xmlns:ns2=”http://customer/jaws&#8221; xmlns:soap11-enc=”http://schemas.xmlsoap.org/soap/encoding/&#8221; xmlns:tns=”http://wb1-329:8080&#8243; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”&gt;
    <import namespace=”http://customer/jaws&#8221; />
    – <complexType name=”check”>
    <sequence />
    </complexType>
    – <complexType name=”checkResponse”>
    <sequence />
    </complexType>
    – <complexType name=”getAccountInfo”>
    – <sequence>
    <element name=”int_1″ type=”int” />
    </sequence>
    </complexType>
    – <complexType name=”getAccountInfoResponse”>
    – <sequence>
    <element name=”result” nillable=”true” type=”ns2:customerBean” />
    </sequence>
    </complexType>
    – <complexType name=”getAccountList”>
    <sequence />
    </complexType>
    – <complexType name=”getAccountListResponse”>
    <sequence />
    </complexType>
    <element name=”check” type=”tns:check” />
    <element name=”checkResponse” type=”tns:checkResponse” />
    <element name=”getAccountInfo” type=”tns:getAccountInfo” />
    <element name=”getAccountInfoResponse” type=”tns:getAccountInfoResponse” />
    <element name=”getAccountList” type=”tns:getAccountList” />
    <element name=”getAccountListResponse” type=”tns:getAccountListResponse” />
    </schema>
    – <schema elementFormDefault=”qualified” targetNamespace=”http://customer/jaws&#8221; xmlns=”http://www.w3.org/2001/XMLSchema&#8221; xmlns:ns1=”http://wb1-329:8080&#8243; xmlns:soap11-enc=”http://schemas.xmlsoap.org/soap/encoding/&#8221; xmlns:tns=”http://customer/jaws&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”&gt;
    <import namespace=”http://wb1-329:8080&#8243; />
    – <complexType name=”customerBean”>
    – <sequence>
    <element name=”accountId” nillable=”true” type=”int” />
    <element name=”activeDate” nillable=”true” type=”string” />
    <element name=”address” nillable=”true” type=”string” />
    <element name=”age” nillable=”true” type=”int” />
    <element name=”annualIncome” nillable=”true” type=”int” />
    <element name=”city” nillable=”true” type=”string” />
    <element name=”createdDate” nillable=”true” type=”string” />
    <element name=”emailId” nillable=”true” type=”string” />
    <element name=”firstname” nillable=”true” type=”string” />
    <element name=”greencardHolder” nillable=”true” type=”short” />
    <element name=”lastname” nillable=”true” type=”string” />
    <element name=”occupation” nillable=”true” type=”string” />
    <element name=”phoneNumber” nillable=”true” type=”string” />
    <element name=”state” nillable=”true” type=”string” />
    <element name=”status” nillable=”true” type=”string” />
    <element name=”zip” nillable=”true” type=”int” />
    </sequence>
    </complexType>
    </schema>
    </types>
    – <message name=”EndpointInterface_getAccountList”>
    <part element=”tns:getAccountList” name=”parameters” />
    </message>
    – <message name=”EndpointInterface_getAccountInfo”>
    <part element=”tns:getAccountInfo” name=”parameters” />
    </message>
    – <message name=”EndpointInterface_check”>
    <part element=”tns:check” name=”parameters” />
    </message>
    – <message name=”EndpointInterface_checkResponse”>
    <part element=”tns:checkResponse” name=”result” />
    </message>
    – <message name=”EndpointInterface_getAccountListResponse”>
    <part element=”tns:getAccountListResponse” name=”result” />
    </message>
    – <message name=”EndpointInterface_getAccountInfoResponse”>
    <part element=”tns:getAccountInfoResponse” name=”result” />
    </message>
    – <portType name=”EndpointInterface”>
    – <operation name=”check”>
    <input message=”tns:EndpointInterface_check” />
    <output message=”tns:EndpointInterface_checkResponse” />
    </operation>
    – <operation name=”getAccountInfo”>
    <input message=”tns:EndpointInterface_getAccountInfo” />
    <output message=”tns:EndpointInterface_getAccountInfoResponse” />
    </operation>
    – <operation name=”getAccountList”>
    <input message=”tns:EndpointInterface_getAccountList” />
    <output message=”tns:EndpointInterface_getAccountListResponse” />
    </operation>
    </portType>
    – <binding name=”EndpointInterfaceBinding” type=”tns:EndpointInterface”>
    <soap:binding style=”document” transport=”http://schemas.xmlsoap.org/soap/http&#8221; />
    – <operation name=”check”>
    <soap:operation soapAction=”” />
    – <input>
    <soap:body use=”literal” />
    </input>
    – <output>
    <soap:body use=”literal” />
    </output>
    </operation>
    – <operation name=”getAccountInfo”>
    <soap:operation soapAction=”” />
    – <input>
    <soap:body use=”literal” />
    </input>
    – <output>
    <soap:body use=”literal” />
    </output>
    </operation>
    – <operation name=”getAccountList”>
    <soap:operation soapAction=”” />
    – <input>
    <soap:body use=”literal” />
    </input>
    – <output>
    <soap:body use=”literal” />
    </output>
    </operation>
    </binding>
    – <service name=”CustomerRegisteration”>
    – <port binding=”tns:EndpointInterfaceBinding” name=”EndpointInterfacePort”>
    <soap:address location=”http://wb1-329:8080/CustomerRegistrationEJB&#8221; />
    </port>
    </service>
    </definitions>

    #272386 Reply

    rkm258
    Member

    If u sees the <sequence> for the type of getAccountListResponse in <types> it is empty that’a the reason the client side will not understand what type of result is this.

    Have u used the class as a setter and getter with properties then ur result will be like

    <xsd:element name=”getExtendedSearchResponse”>
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element maxOccurs=”1″ minOccurs=”1″ name=”OfficeTypeList” nillable=”true” type=”tns:ArrayOfSearchByOffcType”/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>

    where array is another type with it’s own type. In this case it is returning a list with objects of type SearchByOffcType.

    reply for any concerns

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: webservice retuning list of objects

You must be logged in to post in the forum log in