File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes CXF and Maven Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "CXF and Maven" Watch "CXF and Maven" New topic
Author

CXF and Maven

Dibyendu Sarkar
Greenhorn

Joined: Jan 12, 2009
Posts: 25
I'm totally new to CXF (and web services for that matter) and this is what I'm trying to figure out. My maven creates the classes for me. But how do I determine which class is the one I really need to use? My understanding is the one extending Service? Is that right?

Now if that's the case, the class I see after generating the code though CXF and Maven, i do not see how to implement this class in my code to make use of the service. While, when I tried to use xFire, it created a client class for me for the same WSDL and I just had to start from there and it was easy...

CXF is supposed to be easier than xFire I am told. Please help me to see that argument clearly...
sangram mhatre
Greenhorn

Joined: Apr 02, 2005
Posts: 15
You can do something like this ,

//Look-up the client (it is the one which will have @Webservice annotation
//If not using spring just create the instance
IMyService client = (IMyService) context.getBean("client");
.........

Then call the ws .

// Invoke the Service
logger.info("Client invoking WS:");
ObjectFactory factory = new ObjectFactory();
NameDataContract name = factory.createNameDataContract();
name.setFirstName( factory.createNameDataContractFirstName("Java"));
name.setLastName(factory.createNameDataContractLastName("Client"));
String response = client.sayHello(name);
logger.info("Response: " + response);

Cheers,
Sangram M
Dibyendu Sarkar
Greenhorn

Joined: Jan 12, 2009
Posts: 25
Thank you. I was able to get this to run. Although in a slightly different way. Now I'm facing another problem. The end-point for the service I'm writing the client for is supposed to be different for the dev/testing and the production environment.

I'm using Maven. It is looking for the WSDL in the path mentioned in the POM.


Now when this migrates to the testing region, I'd need it to use a different end-point. But since it will still have the same WSDL pointed to via the POM, it'll pick up the end-point for the dev environment.

What is the best way to handle this?
sangram mhatre
Greenhorn

Joined: Apr 02, 2005
Posts: 15

This is how had done it


But i have used simple bean , not the generated code by java2wsdl .


Dibyendu Sarkar
Greenhorn

Joined: Jan 12, 2009
Posts: 25
Thank you Sangram... I will give this a try...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: CXF and Maven