Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate mock web service using WSDL in Java?

I have WSDL file and for local testing I need to generate mock web service.

Please do not recommend SoapUI.

Can anybody please help how to generate mock web service in Java using WSDL?

like image 495
dev Avatar asked May 09 '17 09:05

dev


1 Answers

One option is to create a Web Services project using an IDE. This will allow you to create a mock service and also implement your business logic.

As an example, using Eclipse:

Before starting, ensure that:

  • Eclipse has a server installed (Apache Tomcat)
  • Your WSDL file have a .wsdl extension (if not, rename as .wsdl)

Now, start Eclipse:

  1. Create a new java "Dynamic Web Project"
  2. Create a folder WebContent\wsdl and copy your WSDL file
  3. Right-click on project > select new "Web Service"
  4. Select:

    • Web Service type: "Top down Java bean Web Service"

    • Service definition: browser your WSDL file

    • Select "Start Service"

    • Select "Java Proxy / Start Client"

    • Select both option at the bottom of the form (publish/monitor)

  5. Click next to complete process

At the end, your server should be started and WS deployed - check that your WSDL is available.

Now, you can:

  • call your WS using Eclipse Web Services Explorer see explorer
  • implement your WS mockup business logic see method implementation
  • or use a working java client to call your WS programmatically

Hope this help.

like image 154
walter Avatar answered Sep 22 '22 14:09

walter