francis varkey

Ranch Hand
+ Follow
since Sep 13, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by francis varkey

Issue is solved with JAXB data binding
10 years ago
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>
10 years ago
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)[129:org.apache.cxf.cxf-rt-databinding-jaxb:2.7.10]
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:702)[129:org.apache.cxf.cxf-rt-databinding-jaxb:2.7.10]
at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:160)[129:org.apache.cxf.cxf-rt-databinding-jaxb:2.7.10]
at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:107)[128:org.apache.cxf.cxf-api:2.7.10]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)[128:org.apache.cxf.cxf-api:2.7.10]
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:817)[128:org.apache.cxf.cxf-api:2.7.10]
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1614)[137:org.apache.cxf.cxf-rt-transports-http:2.7.10]
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1129)[137:org.apache.cxf.cxf-rt-transports-http:2.7.10]
at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:428)[128:org.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)[128:org.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
10 years ago
Dear All,
My web service is enabled with https. Now I am trying to generate client for this secured service using wsimport . I have generate keys for both server and client. I am not able to generate client using wsimport for htttps wsdl . Where I have to mention the client key while generating client stub?

Can you please tell the complete step for mutual authentication ?


Thanks
10 years ago
Thank you for reply .
As per the documentation http://docs.oracle.com/cd/E17904_01/web.1111/e15184/interop.htm ,
not good to use array wrapper elements using the convention ArrayOfXXX. Then how can be send list of objects . I was thinking to use array of value object (java bean).

eg :MyVo[] myvo
11 years ago
Hi Surendra,
This also not working for me. Is it working for you ? . I am using bottom up approach . Any specific schema validation limitation in code- first approach ?

Thanks
11 years ago
I am having the same issue in JAX-WS and apache cxf bottom-up web service . Any suggestions will be a big help.
11 years ago
Can some one provide solutions ?
11 years ago
I mean no change in the generated wsdl.


- <xsd:complexType name="MyVo">
- <xsd:sequence>
<xsd:element minOccurs="0" name="name" nillable="true" type="xsd:string" />

</xsd:sequence>
</xsd:complexType>


I am using jdk1.6.0_11.
11 years ago
I tried this also ,but nothing happening.
11 years ago
Hi All,
I am developing web services using jax-ws and apache cxf with code first approach . I want to enable schema validation in my service . For this I have configured the cxf configuration file as follows

<jaxws:endpoint id="testService"
implementorClass="com.test.impl.TestServiceImpl"
implementor="#testServiceImpl"
address="/testService">
<jaxws:serviceFactory>
<ref bean="jaxws-and-aegis-service-factory"/>
</jaxws:serviceFactory>
<jaxws:properties>
<entry key="schema-validation-enabled" value="true"/>
</jaxws:properties>
</jaxws:endpoint>

Service,

@WebService
@SOAPBinding(style=SOAPBinding.Style.DOCUMENT,use=SOAPBinding.Use.LITERAL)

public interface TestService {



@WebMethod
String test(MyVo myVo) ;

}

MyVo,


@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MyVo")
public class MyVo {

@XmlElement(name = "name", required = true)
private String name;

............. // getter and setter

}

.

But after deploying the service wsdl looks like


- <xsd:complexType name="MyVo">
- <xsd:sequence>
<xsd:element minOccurs="0" name="name" nillable="true" type="xsd:string" />

</xsd:sequence>
</xsd:complexType>


As per documentation minOccurs should be 1 (because of required=true ) .

Also I am able to call service without setting name attribute in MyVo object . No error is coming from server.


Please advice .


Thanks in advance




11 years ago
Hi ,
I am trying to develop some web services using jax-ws and apace cxf. I need to invoke these services from different languages like JAVA/PHP/.Net etc. I am having some doubts regarding parameters inside in the operations. I tried different approaches .

1) Passing a value object in operation as a parameter
2)Using HashMap as a parameter
3)Using ArrayList as a parameter.
4)Passing required number of string arguments (in this case 7 String parameters and one byte array ) .

I have developed one Java client using wsimport command. By using this client the fourth option is working . In the second and third options the client is generating some type like String2AnyElement for HashMap and ArrayList. How I can I put values in these types of data structure ? While trying first option there was some compilation problem also.

I went through jax-ws tutorial also, there I could see some limited data types support only

Can some one suggest best approach for designing my operations . It should be access from different platforms and different client generations tools like CXF,AXIS etc.


Thanks

11 years ago
Hi ,
Thanks . I went to this url . I am using code first approach . Will it work in this scenario also ?

Thank You
11 years ago
Hi All,
We are using JAX-WS and apache CXF for developing web service. Our application is spring based web application and deployed in tomcat server. Now we have to encrypt our web services . What are different ways to achieve this ?

Thank You
11 years ago
Hi ,
I am trying to implement a scheduler using quartz in spring3. The requirement is need to take value of cron expression should read from database. While trying this I am getting following exception.

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cronTrigger' defined in class path resource [Spring-Quartz.xml]: Cannot resolve reference to bean 'constructCronExpression' while setting bean property 'cronExpression'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'constructCronExpression' is defined
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)


Code.

1) Spring-Quartz.xml

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<bean id="runMeTask" class="test.RunMeTask" />
<!-- <bean id="constructCronExpression" class="test.CustomCronExpression" /> -->

<!-- Spring Quartz -->
<bean name="runMeJob" class="org.springframework.scheduling.quartz.JobDetailBean">

<property name="jobClass" value="test.RunMeJob" />

<property name="jobDataAsMap">
<map>
<entry key="runMeTask" value-ref="runMeTask" />
</map>
</property>

</bean>

<!--
<bean id="runMeJob"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="runMeTask" />
<property name="targetMethod" value="printMe" />
</bean>
-->

<!-- Simple Trigger, run every 5 seconds -->
<bean id="simpleTrigger"
class="org.springframework.scheduling.quartz.SimpleTriggerBean">

<property name="jobDetail" ref="runMeJob" />
<property name="repeatInterval" value="5000" />
<property name="startDelay" value="1000" />

</bean>

<!-- Cron Trigger, run every 5 seconds -->
<bean id="cronTrigger"
class="org.springframework.scheduling.quartz.CronTriggerBean">

<property name="jobDetail" ref="runMeJob" />
<!-- <property name="cronExpression" value="0/5 * * * * ?" /> -->
<property name="cronExpression" ref="constructCronExpression"/>

</bean>

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="jobDetails">
<list>
<ref bean="runMeJob" />
</list>
</property>

<property name="triggers">
<list>
<ref bean="simpleTrigger" />
</list>
</property>
</bean>

</beans>

2)RunMeTask.java
package test;

public class RunMeTask {
public void printMe() {
System.out.println("Spring 3 + Quartz 1.8.6 ~");
}
}

3)RunMeJob.java
package test;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

public class RunMeJob extends QuartzJobBean {
private RunMeTask runMeTask;

public void setRunMeTask(RunMeTask runMeTask) {
this.runMeTask = runMeTask;
}

protected void executeInternal(JobExecutionContext context)
throws JobExecutionException {

runMeTask.printMe();

}
}

4)App.java
package test;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App
{
public static void main( String[] args ) throws Exception
{
new ClassPathXmlApplicationContext("Spring-Quartz.xml");
}
}

5)CustomCronExpression.java
package test;
import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;

@Configuration
public class CustomCronExpression{

@Bean
public String constructCronExpression() {
String cronExpression = "0/5 * * * * ?"; //Contruct Cron Expression from the request
return cronExpression ;
}

}





Thank You



11 years ago