5

How can I create an Endpoint for a web service? I am a beginner to the web services world.

I have got the WSDL and I would like to create a web service based on that WSDL. I have used Apache CXF to generate client stubs. What would be the next steps to test it as a service?

How can I create EndPoints?

How can I mimic the WSDL soapbind address locally and test it?


Let me clarify the Question. Looks like there is confusion. Thanks @Buhake Sindi for point it out.

I have got the WSDL and generated the Client stubs by using Apache CXF Framework in Eclipse. I need to test the WebService client code whether its working or not. How to test this approach now? My WSDL URL is not working at this moment.

How to test my client stub(from generated Impl Class)?

Do I need to create any Endpoints to mimic the WSDL URL(which is not running now)?

Hope the Question is clear now...

casperOne
  • 73,706
  • 19
  • 184
  • 253
Sriks
  • 658
  • 4
  • 9
  • 18
  • Wait, so you want to create another WSDL for yourself? – Buhake Sindi Jan 16 '13 at 15:27
  • This would be easy to do following a web tutorial: [Eclipse Web Service Client](http://px.pats.no/px/Eclipse_tutorial.html) and [Creating a Simple Web Service and Client with JAX-WS using NetBeans](http://docs.oracle.com/javaee/5/tutorial/doc/bnayn.html). Note that both tutorials use a console application to handle this, if you could do it there you can do it in any kind of application. – Luiggi Mendoza Jan 16 '13 at 15:27
  • @Luiggi Mendoza: I wouldn't use these tutorials. The first one is too wizard driven, the second one too bloated (why would you use ant for a simple JAX-WS tutorial?). For starters, I would suggest [JAX-WS Hello World Example](http://www.mkyong.com/webservices/jax-ws/jax-ws-hello-world-example/). – joergl Jan 16 '13 at 15:46
  • @Shriks: A very very simple example for deployment is also found in [this answer](http://stackoverflow.com/a/11932308/1127892) – joergl Jan 16 '13 at 15:50

2 Answers2

1

You can test client code even without creating web service implementation also. Are you aware of SoapUI tool? Use that to import the wsdl to create a project.

It gives you the option to create a mock service also along with the request. You can run that mock service and test your client against that service without writing any service code. I use it for testing all the time. Also you can create Success, Failure, and Fault response to test different scenarios. Mock service will also show you the request received by the service. This feature works like a charm. Let me know if you need help in setting up mock service in SoapUI.

You may follow this link to get started: http://www.soapui.org/Getting-Started/mock-services.html

Charu Khurana
  • 4,511
  • 8
  • 47
  • 81
  • Thank you very much @Learner. Right now Webservice is down and couldn't able to test. However we need to develop the client to use WebServices. Right now we want to mimic Endpoints locally. I have the problem now how to mimic the Endpoint in Java code. – Sriks Jan 17 '13 at 03:44
  • I've edited the post and added SoapUI link for project setup. Please elaborate what do you mean by mimic endpoint in java code – Charu Khurana Jan 17 '13 at 13:47
  • I have got the valid WSDL and looks good. But endpoint in WSDL - URL is not up and running(means service is not up and running). Ex: So I would like to create that Endpoint from Code as if I am calling and using the Webservice in real time. Thats what mimic endpoint means in my words. Hope that is clear. – Sriks Jan 17 '13 at 14:05
  • You can import the wsdl and run mock service as pointed in the link. For that you won't need to have the service up at client side – Charu Khurana Jan 17 '13 at 14:07
  • Sure. I didn't try to mock it thru SoapUI. That would be good one to test whether WSDL is good or not. Thanks @Learner again. – Sriks Jan 17 '13 at 23:36
0

You run wsdl2java from CXF to generate server-side stubs. Then you fill in the code in the stubs. Then you set up a service to deploy.

There is no mechanism I know if that will create mock services. What would you expect them to do?

See the samples from the CXF distribution, particularly the wsdl-first samples.

A better approach would be to use JMock to mock the client side SEI, and not try to come up with a dummy service.

bmargulies
  • 97,814
  • 39
  • 186
  • 310