Some problem passing complex objects to Jboss Axis Web Servi
harshi2003 Dec 30, 2004 1:57 AMhello
In my application i have objects called Order and Order Package
Following is the source code
Order class
public class Order extends Object implements Serializable{
private Integer id;
private String orderRef;
private Date dateVal;
OrderPackage[] packageArray;
public Date getDateVal() {
return dateVal;
}
public void setDateVal(Date dateVal) {
this.dateVal = dateVal;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getOrderRef() {
return orderRef;
}
public void setOrderRef(String orderRef) {
this.orderRef = orderRef;
}
public void setPackages(OrderPackage[] packObj){
packageArray= packObj;
}
public OrderPackage[] getPackages(){
return packageArray;
}
}
public class OrderPackage implements Serializable {
private Integer sid;
private String description;
private BigDecimal weight;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getSid() {
return sid;
}
public void setSid(Integer sid) {
this.sid = sid;
}
public BigDecimal getWeight() {
return weight;
}
public void setWeight(BigDecimal weight) {
this.weight = weight;
}
}
I have created a Stateless sesion bean and converted that to a web service. I want to pass Order object as a parameter to this web service.
According to the example given in http://www.jboss.org/wiki/Wiki.jsp?page=WSTypeMapping
I have created following webservice. xml and ws4ee-deployment.xml following what i created
webservice.xml
---------------------
<?xml version="1.0" encoding="UTF-8"?>
<!-- -->
<!-- This JBoss.Net Web Service Descriptor has been generated by XDoclet -->
<!-- and is brought to you by F. M. Brier, C. G. Jung and J. Essington -->
<!-- -->
<deployment name="testService"
xmlns="http://xml.apache.org/axis/wsdd/"
targetNamespace="http://localhost:8080/testService"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
xmlns:soap="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!-- The following are declarations of service endpoints targetted to
session beans -->
<!-- Operation mapping results -->
<parameter name="orderobj" qname="ns1:orderobj" mode="IN"
type="ns1:orderobj" xmlns:ns1="http://localhost:8080/testService"/>
<typeMapping qname="ns1:orderObj" xmlns:ns1="http://localhost:8080/testService"
type="java:com.test.obj.Order"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
<!-- The following are typemappings for entity beans for implementing
the implicit web-service value-object pattern -->
<!-- The following are typemappings for bean-type value-objects -->
<!-- There follow merged custom web service descriptions -->
ws4ee-deployment.xml
------------------------------
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java" xmlns:soap="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<typeMapping qname="ns1:orderObj" xmlns:ns1="http://localhost:8080/testService"
type="java:com.test.obj.Order"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
<typeMapping qname="ns1:OrderPackage" xmlns:ns1="http://localhost:8080/testService"
type="java:com.test.obj.OrderPackage"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
using above i created a wsr file and the wsr deployes without errors. but when i run the client program with following statments
Service service = new Service();
Call call = (Call) service.createCall();
QName qn = new QName( "http://192.168.1.197:8080/jboss-net/services/testService", "com.test.obj.Order" );
call.registerTypeMapping(Order.class, qn,
new org.apache.axis.encoding.ser.BeanSerializerFactory(Order.class, qn),
new org.apache.axis.encoding.ser.BeanDeserializerFactory(Order.class, qn));
QName qn1 = new QName( "http://192.168.1.197:8080/jboss-net/services/testService", "com.test.obj.OrderPackage" );
call.registerTypeMapping(OrderPackage.class, qn1,
new org.apache.axis.encoding.ser.BeanSerializerFactory(OrderPackage.class, qn1),
new org.apache.axis.encoding.ser.BeanDeserializerFactory(OrderPackage.class, qn1));
call.setTargetEndpointAddress(new java.net.URL("http://192.168.1.197:8080/jboss-net/services/testService"));
call.setOperationName("addOrder");
call.addParameter("param", qn,ParameterMode.IN);
//call.addParameter("param", org.apache.axis.Constants.XSD_STRING,
// ParameterMode.IN);
call.setReturnType(org.apache.axis.Constants.XSD_STRING);
//String orderStr = "new order";
String retValue = ( (String) call.invoke(new Object[] {orderObj}));
I get following error
xisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXException: Deserializing parameter 'addOrder': could not find deserializer for type {http://localhost:8080/testService}orderobj
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace: AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXException: Deserializing parameter &apos;addOrder&apos;: could not find deserializer for type {http://localhost:8080/testService}orderobj
faultActor:
faultNode:
faultDetail:
org.xml.sax.SAXException: Deserializing parameter 'addOrder': could not find deserializer for type {http://localhost:8080/testService}orderobj
could you please tell me how can i solve this problem. i am new to web services. Please help.
Thank you in advance