2

I use CXF 2.7.5 to call Web services. I generated the client classes with wsdl2java program (in command line MSDOS and in maven). I must use xmlbeans databinding because with jaxb (default databinding) I have some errors, and I can't modify the server side. So with xmlbeans databinding parameter the generation is OK.

I call the web methods with the following method :

WcfDemandService service = new WcfDemandService();
IWcfDemandService client = service.getBasicHttpBindingIWcfDemandService();
TODemand ticketToSubmit = TODemand.Factory.newInstance();

...

boolean ret = client.submit(ticketToSubmit);

When I call webmethods, it works perfectly on simple java program, but in portlet liferay context that doesn't work : I have this error (in english, the translation is org.tempuri.CheckConsistencyDocumen is an interface and jaxb can't handle interfaces) :

09:48:33,899 ERROR [http-bio-8080-exec-4][PortletServlet:115] javax.portlet.PortletException: com.sun.xml.ws.spi.db.DatabindingException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 149 counts of IllegalAnnotationExceptions org.tempuri.CheckConsistencyDocument est une interface et JAXB ne peut pas gérer les interfaces. this problem is related to the following location: at org.tempuri.CheckConsistencyDocument org.tempuri.CheckConsistencyDocument$CheckConsistency est une interface et JAXB ne peut pas gérer les interfaces. this problem is related to the following location: at org.tempuri.CheckConsistencyDocument$CheckConsistency at public abstract org.tempuri.CheckConsistencyDocument$CheckConsistency org.tempuri.CheckConsistencyDocument.getCheckConsistency() at org.tempuri.CheckConsistencyDocument org.datacontract.schemas.x2004.x07..TODemand est une interface et JAXB ne peut pas gérer les interfaces. this problem is related to the following location: at org.datacontract.schemas.x2004.x07..TODemand at public abstract org.datacontract.schemas.x2004.x07.*.TODemand org.tempuri.CheckConsistencyDocument$CheckConsistency.getEntity() at org.tempuri.CheckConsistencyDocument$CheckConsistency at public abstract org.tempuri.CheckConsistencyDocument$CheckConsistency org.tempuri.CheckConsistencyDocument.getCheckConsistency() at org.tempuri.CheckConsistencyDocument

This error is repeated for a lot of interfaces.

Do you know why this code doesn't work in liferay context?

ronnyfm
  • 1,973
  • 25
  • 31
clement M.
  • 141
  • 2
  • 9
  • Your model was generated using XMLBeans and that model based on the exception is being interpreted by a JAXB implementation? What was the original problem you hit with JAXB? – bdoughan May 23 '13 at 10:18
  • Yes, I generated with XML beans and I have a jaxb error(but in simple java program, it works). – clement M. May 23 '13 at 10:23
  • The original error I had when I generated the wsdl with jaxb is : The id property is already defined. use to resolve this conflict. The following location matches the above error : http://*****/WcfDemandService.svc?xsd=xsd2 [0,0]: – clement M. May 23 '13 at 10:27
  • I can help you with that issue if you are interested. – bdoughan May 23 '13 at 10:32
  • Yes i am. Have you got this problem (on liferay context)? – clement M. May 23 '13 at 10:34
  • No, but I'm the EclipseLink JAXB (MOXy) lead. – bdoughan May 23 '13 at 10:42
  • Ok. I created a specific question about the problem with wsdl2java which generates JAXB error : http://stackoverflow.com/questions/16714465/cxf-wsdl2java-the-xx-property-is-already-defined – clement M. May 23 '13 at 12:53
  • 1
    The problem was due to one endorsed directory which contained lot of library ; when I deleted it, the error was removed – clement M. May 24 '13 at 14:07

3 Answers3

1

You aren't using CXF in this case. The stack trace (com.sun.xml.ws.spi....) shows you are using Metro, not CXF. Check your classpath and such to make sure you really are using CXF. CXF should be able to use XMLBeans if you want to stick with that. (although using a JAXB based solution from Blaise is likely better anyway)

Daniel Kulp
  • 14,447
  • 4
  • 45
  • 37
1

The problem was due to one endorsed directory which contained lot of library ; when I deleted it, the error was removed

clement M.
  • 141
  • 2
  • 9
0

If the classes were generated using XmlBeans, then, you may use JaxWsProxyFactoryBean and explicitly configure to use XmlBeansDataBinding since CXF use JAXB default for all its operations.

JaxWsProxyFactoryBean factory = new org.apache.cxf.jaxws.JaxWsProxyFactoryBean();
factory.setServiceClass(YourServiceInterface.class);
factory.setDataBinding(new XmlBeansDataBinding()); 
factory.setAddress(endPoint);
factory.getInInterceptors().add(new org.apache.cxf.interceptor.LoggingInInterceptor());
factory.getOutInterceptors().add(new org.apache.cxf.interceptor.LoggingOutInterceptor());
ronnyfm
  • 1,973
  • 25
  • 31