12

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?

dur
  • 15,689
  • 25
  • 79
  • 125
dev
  • 175
  • 1
  • 1
  • 9

2 Answers2

8

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.

walter
  • 196
  • 1
  • 4
0

Try using Wiremock. However you will be needing to create and structure json/xml files according to your need.
This will give you an better idea. Using WireMock with SOAP Web Services in Java

Community
  • 1
  • 1
Raveen Athapaththu
  • 190
  • 1
  • 1
  • 13