4 Replies Latest reply on Aug 8, 2014 3:11 AM by Joby kj

    Jax WS complex web serivice is not working in camel route

    Joby kj Newbie

      Hi All,

                      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 , 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>