axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vargheese.t.j...@jpmchase.com
Subject User defined Object Array as service output
Date Fri, 21 Sep 2007 16:29:40 GMT
Hi,
I'm having some difficulty in getting an array of user defined objects as 
output from a web service when using Axis. Can you please help ?

Details are as below:

1. I have a web service which returns a user defined object array
        public class EmployeeBean implements java.io.Serializable {
        Employee[] getEmployeeData() { 
        }

2. The Employee Class contains 2 attributes of datatype String
        public class Employee implements java.io.Serializable {
                String empName
                String empId
        }

3. I deployed this service using WSDD 
        <deployment xmlns="http://xml.apache.org/axis/wsdd/"  xmlns:java="
http://xml.apache.org/axis/wsdd/providers/java">

         <service name="urn:EmployeeServices" provider="java:RPC">
             <namespace>http://empservices</namespace>
             <parameter name="className" value="com.sample.EmployeeBean"/>
             <parameter name="allowedMethods" value="getEmployeeData"/>

             <typeMapping
               xmlns:ns="http://empservices"
               qname="ns:aryEmployee"
               type="java:com.sample.Employee[]"
               serializer="
org.apache.axis.encoding.ser.BeanSerializerFactory"
               deserializer="
org.apache.axis.encoding.ser.BeanDeserializerFactory"
               encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
             /> 
           <operation name="getEmployeeData" qname="operNS:getEmployeeData
" returnQName="getEmployeeData" returnType="rtns:aryEmployee" xmlns:rtns="
http://empservices"/>
         </service>
</deployment>

4. When I create a client with the following serializer (Simple 
Employee.class in the class instantiation)
            BeanSerializer beanSerObj = new BeanSerializer();
            smrObj.mapTypes(Constants.NS_URI_SOAP_ENC,  new QName("
http://empservices", "aryEmployee"),
                com.sample.Employee.class, beanSerObj, beanSerObj);

I get the following error------> java.lang.ClassCastException: 
com.sample.Employee

5. When I create a client with the following serializer (Array 
Employee[].class in the class instantiation)
            BeanSerializer beanSerObj = new BeanSerializer();
            smrObj.mapTypes(Constants.NS_URI_SOAP_ENC,  new QName("
http://empservices", "aryEmployee"),
                com.sample.Employee[].class, beanSerObj, beanSerObj);

I get the following error------> SOAPException: faultCode=SOAP-ENV:Client; 
msg=Unable to instantiate 'com.sample.Employee[]

6. When I change the WSDD to return non-array in typeMapping as below
        type="java:com.sample.Employee"
And create Client as follows:
            BeanSerializer beanSerObj = new BeanSerializer();
            smrObj.mapTypes(Constants.NS_URI_SOAP_ENC,  new QName("
http://empservices", "aryEmployee"),
                com.sample.Employee.class, beanSerObj, beanSerObj);

            smrObj.mapTypes(Constants.NS_URI_SOAP_ENC,  new QName("
http://schemas.xmlsoap.org/soap/encoding/",
                    "string"), String.class, null, beanSerObj);  -------> 
When this line is omitted Axis says "Could not find serializer for string 
class"

I get the Employee array in return but the attributes (empName and empId) 
are both empty. However in the server log I can see that the employee 
object  and its attributes are both non-empty.

I tried to search the Axis sample but I could not find a web service 
client example that gets a array of user defined objects. 

Can anyone pls let me know what I'm doing wrong here ?

Thanks In advance
Vargheese Thomas.


-----------------------------------------
This communication is for informational purposes only. It is not
intended as an offer or solicitation for the purchase or sale of
any financial instrument or as an official confirmation of any
transaction. All market prices, data and other information are not
warranted as to completeness or accuracy and are subject to change
without notice. Any comments or statements made herein do not
necessarily reflect those of JPMorgan Chase & Co., its subsidiaries
and affiliates.

This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED. Although this transmission and any
attachments are believed to be free of any virus or other defect
that might affect any computer system into which it is received and
opened, it is the responsibility of the recipient to ensure that it
is virus free and no responsibility is accepted by JPMorgan Chase &
Co., its subsidiaries and affiliates, as applicable, for any loss
or damage arising in any way from its use. If you received this
transmission in error, please immediately contact the sender and
destroy the material in its entirety, whether in electronic or hard
copy format. Thank you.

Please refer to http://www.jpmorgan.com/pages/disclosures for
disclosures relating to UK legal entities.
Mime
View raw message