Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CXF and Maven

 
Dibyendu Sarkar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This is how had done it


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


 
Dibyendu Sarkar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Sangram... I will give this a try...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic