Less than 42 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Jax-Ws web service with cxf and aegis - Unmarshalling Error  RSS feed

 
francis varkey
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
We have a web service with JAX-WS ,CXF and Aegis . The return type of one operation in this service is a List of custom user defined (say List<Student>) objects. ,But while calling this operation from a camel route ,getting Unmarshalling Error:


at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:881)[129rg.apache.cxf.cxf-rt-databinding-jaxb:2.7.10]
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:702)[129rg.apache.cxf.cxf-rt-databinding-jaxb:2.7.10]
at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:160)[129rg.apache.cxf.cxf-rt-databinding-jaxb:2.7.10]
at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:107)[128rg.apache.cxf.cxf-api:2.7.10]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)[128rg.apache.cxf.cxf-api:2.7.10]
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:817)[128rg.apache.cxf.cxf-api:2.7.10]
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1614)[137rg.apache.cxf.cxf-rt-transports-http:2.7.10]
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1129)[137rg.apache.cxf.cxf-rt-transports-http:2.7.10]
at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:428)[128rg.apache.cxf.cxf-api:2.7.10]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_11]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6.0_11]
at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:353)[128rg.apache.cxf.cxf-api:2.7.10]
at java.lang.Thread.run(Thread.java:619)[:1.6.0_11]
Caused by: javax.xml.bind.UnmarshalException
- with linked exception:

Thanks for your help
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post the entire exception stacktrace and when you do so, please enclose it in a code block so that it's better formatted.
 
francis varkey
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a cxf based jax ws code first web service deployed in Tomcat server . The return type of one of the operation in this service is List of a custom value object . We have created a proxy web service in jboss fuse and camel route with this proxy web service and real web service . Then we have created a client artifact using the proxy web service and trying to invoke the real web service through proxy web service . All the operation working fine except the one which is returning List of complex objects . In this case getting some Unmarshalling Error



javax.xml.ws.soap.SOAPFaultException: Unmarshalling Error: unexpected element (uri:"http://vo.sample.com", local:"employeeVo"). Expected elements are <{http://vo.sample.com}empName>,<{http://http://vo.sample.com}salary>



Development environment



A ) Real web service



Tomcat 7 , cxf 2.6 ,Aegis, Java 6 ,Windows

B) Jboss Fuse



Fuse IDE 6.0.0 , Maven 3.05 , Java 6 , Windows



C) Web service Client



Artifact generated using java wsimport command





Code Snippets .



1)Real Web service interface

@WebService(targetNamespace = "http://service.sample.com", portName = "EmployeeServicePort", serviceName = "EmployeeServiceService")

@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)

public interface EmployeeService {



@WebResult(name = "retrieveEmployeeDetailsResponse", targetNamespace = "http://service.sample.com")

@WebMethod(action = "retrieveEmployeeDetails", operationName = "retrieveEmployeeDetails")

EmployeeVos retrieveEmployeeDetails(@WebParam(name = "employeeVo", targetNamespace = "http://service.sample.com")

EmployeeVo employeeVo)

;

}



2) Value object - Simple



@XmlRootElement(name="employeeVo",namespace = "http://vo.sample.com")

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name = "EmployeeVo",propOrder={

"empName",

"salary"



},namespace = "http://vo.sample.com")

public class EmployeeVo {



public EmployeeVo(){



}





@XmlElement(name="empName",nillable=false,required=true,namespace = "http://vo.sample.com")

private String empName;





@XmlElement(name="salary",nillable=false,required=true,namespace = "http://vo.sample.com")

private Double salary;



// getters & setters



}



3) Value object - Complex





@XmlRootElement(name="emplooyeVos",namespace = "http://vo.sample.com")

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name = "EmployeeVos",propOrder={"employeeVo"},namespace = "http://vo.sample.com")

public class EmployeeVos {





@XmlElement(name = "employeeVo", namespace = "http://vo.sample.com", required = true)

private List<EmployeeVo> employeeVo;



public EmployeeVos(){}

public EmployeeVos(List<EmployeeVo> employeeVo){

this.employeeVo =employeeVo;

}



public List<EmployyeVo> getEmployeeVo() {

return employeeVo;

}

public void setEmployeeVo(

List<EmployeeVo> employeeVo) {

this.employeeVo = employeeVo;

}



4) Camel route





<route >

<from uri="cxf:http://localhost:9080/employeeProxy?serviceClass=com.sample.service.EmployeeService"/>









<to uri="cxf:http://localhost:8080/MyTest/services/employeeService?serviceClass=com.sample.service.EmployeeService"/>



</route>



5) Invoking service ( Artifact is generated from http://localhost:9080/employeeProxy?wsdl)



Getting error





javax.xml.ws.soap.SOAPFaultException: Unmarshalling Error: unexpected element (uri:"http://vo.sample.com", local:"employeeVo"). Expected elements are <{http://vo.sample.com}empName>,<{http://http://vo.sample.com}salary>
 
francis varkey
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Issue is solved with JAXB data binding
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!