Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Problem Generating the web service client proxy using WTP+ CXF (The client with WTP + CXF is Buggy)
Problem Generating the web service client proxy using WTP+ CXF [message #641530] Thu, 25 November 2010 21:35 Go to next message
Maatari  is currently offline Maatari
Messages: 4
Registered: November 2010
Junior Member
Dear All,

I wonder if one of you may help with the following problem:

[ I can't generate a client proxy web service using WTP + CXF ]

I have a web service that i generate from a service end point interface. After what I try to generate a client proxy to use my webservice.

When I use the spring approach, everything work. Following the example ins the apeache cxf book, I create a client-beans.xml with the jaxws:client tag etc..


However when i try to leverage the WTP tools for an automatic generation of the client, the generated code bug. More specifically

I get the following error when I try to invoke my service from within the client proxy generated.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Invoking hi...
DefaultValidationEventHandler: [ERROR]: unexpected element (uri:"http://testOfcxf/", local:"return"). Expected elements are <{}return>
Location: line 1
Nov 25, 2010 10:05:00 PM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
WARNING: Interceptor for {http://testOfcxf/}HiserviceImplService#{http://testOfcxf/}H i has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected element (uri:"http://testOfcxf/", local:"return"). Expected elements are <{}return>
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncode rDecoder.java:787)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncode rDecoder.java:628)
at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.ja va:154)
at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMes sage(DocLiteralInInterceptor.java:109)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(Phase InterceptorChain.java:247)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java :733)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStrea m.handleResponseInternal(HTTPConduit.java:2201)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStrea m.handleResponse(HTTPConduit.java:2071)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStrea m.close(HTTPConduit.java:1925)
at org.apache.cxf.transport.AbstractConduit.close(AbstractCondu it.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit. java:662)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageS enderEndingInterceptor.handleMessage(MessageSenderIntercepto r.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(Phase InterceptorChain.java:247)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:51 6)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:31 3)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:26 5)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.j ava:73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProx y.java:124)
at $Proxy28.hi(Unknown Source)
at testofcxf.HiService_HiserviceImplPort_Client.main(HiService_ HiserviceImplPort_Client.java:56)
Caused by: javax.xml.bind.UnmarshalException


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


Meanwhile I have been able to solve the issue using some tricks. And that is where i would need some help.

To understand the trick. It is important first to let you know that my WTP has the following behaviour:

Weather I generate a web service or a clientproxy web service, the generator generate two times several classes that in my opinion shall be generate once for the service and reuse in the client proxy. To be more specific I have the following SEI and its implementation

@WebService(name = "HiService", targetNamespace = "http://testOfcxf/")
public interface HiService {


@WebMethod(operationName = "Hi", action = "urn:Hi")
@RequestWrapper(className = "testOfcxf.jaxws.Hi", localName = "Hi", targetNamespace = "http://testOfcxf/")
@ResponseWrapper(className = "testOfcxf.jaxws.HiResponse", localName = "HiResponse", targetNamespace = "http://testOfcxf/")
public String Hi(@WebParam(name = "arg0") String name);

}

@WebService(targetNamespace = "http://testOfcxf/", endpointInterface = "testOfcxf.HiService", portName = "HiserviceImplPort", serviceName = "HiserviceImplService")
public class HiserviceImpl implements HiService {

@Override
public String Hi(String name) {


return "hello" + name;
}

}

Then from the file Hiservice.java and HiServiceImpl.java when I generate the all web service I obtain among other the annotation as expose above, but also (because of the @wrappers that I don't yet fully understand)
the class Hi.java and HiResponse.java

(Because the trick comes with Hi response I will only expose HiResponse here)

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@XmlRootElement(name = "HiResponse", namespace = "http://testOfcxf/")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "HiResponse", namespace = "http://testOfcxf/")

public class HiResponse {

@XmlElement(name = "return", namespace = "http://testOfcxf/")
private java.lang.String _return;

public java.lang.String getReturn() {
return this._return;
}

public void setReturn(java.lang.String new_return) {
this._return = new_return;
}

}

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


Until here as stated before everything is fine.


When I generate the client, weather I do it in the same source forlder as my service in another package, in the same package or in another project, the framework generate me the following class:

Hi.java, HiResponse.java, Hiservice.java, HiServiceImpl.java (as far as i know this late impl class is never reference in the client code) which are the class of the service generated before but sligthly differently. The other class are "HiService_HiserviceImplPort_Client.java, HiserviceImplService.java and ObjectFactory"


While I understand that if you are in another project regenerating certain class are necessary I don't understand why it does so differently. And apparently this is the source of my problem as my trick as work at this level.

Here is the HiResponse Java file:


>>>>>>>>>>>>>>>>>>>>>>>>>>>
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "HiResponse", propOrder = {
"_return"
})
public class HiResponse {

@XmlElement(name = "return")
protected String _return;

/**
* Gets the value of the return property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getReturn() {
return _return;
}

/**
* Sets the value of the return property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setReturn(String value) {
this._return = value;
}

}



>>>>>>>>>>>>>>>>>>>>>>>>>>


As it can be seen in this case the @XmlRootElement is missing for instance as well as the name space. (For the namespace I'm not sure but I think they are cathed up in the factory)


So to solve my problem my solution has been to replace the classes that are in double. However I have done so only with HiResponse as there were clearly a problem with the return. But maybe I might face other issue. Indeed all the class generated in double are as different to their original from the service as it is illustrated with the Hiresponse class.




Therefore can someone englight me with this. I would like to know if I'm doing the right thing. If the behavior or the WTP is as expected? I have latest version of eclise, java 6 and etc...fully up to date.

Is it possible to have the two process generate the same thing. (client and service generation) or to stop the client from regenerating the server class? I used both Develop and assemble for a test.

Furthermore why renerating HiServiceImpl while it is not the one used ?


Many thanks


Maatari
Re: Problem Generating the web service client proxy using WTP+ CXF [message #641855 is a reply to message #641530] Sun, 28 November 2010 20:16 Go to previous messageGo to next message
Shane Clarke is currently offline Shane Clarke
Messages: 67
Registered: July 2009
Member
Hi Maatari

There was a change in CXF 2.2.11 to do with the response wrapper code generation.

Add

@javax.jws.WebResult(name = "return", targetNamespace="")

to your to SEI method and regenerate your service.

The WTP tools for using the CXF runtime to develop web services are just a frontend to the CXF java2ws and wsdl2java tools.

http://cxf.apache.org/docs/java-to-ws.html
http://cxf.apache.org/docs/wsdl-to-java.html

The wizards take the input that you provide and the options that you select and then delegate to the CXF tools to do the code generation.

When using the WTP Web Services wizard to develop a service and client with the CXF runtime. First java2ws runs with your SEI/Impl. It gets deployed to your web/app server and then wsdl2java runs against the deployed service to generate a client.

You can disable the generation of an implementation class when generating a client by unchecking the "Generate Implementation" preference in the preferences (Web Services > CXF 2.x Preferences > WSDL2Java) before launching the WTP Wizard or uncheck the preference in the wizard page in the "WSDL2Java Generation Options" section.

Thanks,
Shane
Re: Problem Generating the web service client proxy using WTP+ CXF [message #642504 is a reply to message #641530] Wed, 01 December 2010 15:48 Go to previous message
Maatari  is currently offline Maatari
Messages: 4
Registered: November 2010
Junior Member
Many thanks.
Previous Topic:CSS Brace Position
Next Topic:WSDL + SOAP12 and Eclipse WSDL editor problem
Goto Forum:
  


Current Time: Tue Sep 23 14:42:51 GMT 2014

Powered by FUDForum. Page generated in 0.01871 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software