Mocking SOAP JAX-WS web services

4,160 views
Skip to first unread message

Stephen Kurlow

unread,
May 28, 2015, 5:23:27 AM5/28/15
to moc...@googlegroups.com
Hello,

I've been using mockito for mocking Java classes and I am very happy with the experience and outcome.

I am developing a software system A that interacts with a client's software system B. The system B exposes a SOAP webservice endpoint and obviously I can get the WSDL file for it. Can I write a JUnit style test that has mockito like syntax where I can create a fake SOAP webservice perhaps using some open-source tool where the tool can be instructed from my junit test to launch a web server that imports the WSDL thereby exposing what appears to be a real endpoint but with no implementation, effectively stubbed. Can I then in my junit test tell the mocked web service how to respond given a certain input? Can I also verify if the mocked web service was invoked and how many times? All similar functional concepts present in mockito but for mocking of SOAP web services rather than Java classes.

Please point me to a working example! :)

BTW, I've had a peek at mockable.io but couldn't find a working example. :( If there is one but obviously I couldn't find it please let me know too.

Thanks,
Stephen

Malte Finsterwalder

unread,
May 28, 2015, 7:14:14 AM5/28/15
to mockito
I can't offer you a direct solution to your question.
But maybe a design idea, which prevents you from needing such a thing.
How about if you create a small wrapper class, which does the SOAP-Magic inside and exposes a normal Java Interface to call.
Then you could easily mock this wrapper class and you would only miss a small part in your test.
The real call to the real web-service would have to be tested in integration tests.

Greetings,
   Malte

--
You received this message because you are subscribed to the Google Groups "mockito" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mockito+u...@googlegroups.com.
To post to this group, send email to moc...@googlegroups.com.
Visit this group at http://groups.google.com/group/mockito.
To view this discussion on the web visit https://groups.google.com/d/msgid/mockito/29d9166f-9ab5-4315-8076-12ba73bb4987%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

KARR, DAVID

unread,
May 28, 2015, 12:19:14 PM5/28/15
to moc...@googlegroups.com

You might consider using SoapUI (either Free or Pro).  With this, you can create a mock server that you could even deploy to a WAR server.  You handle requests with Groovy scripts that can produce mock responses.  You would then have to configure a client with the address of your mock server.

 

--

Thomas Skjølberg

unread,
Nov 8, 2016, 7:07:58 AM11/8/16
to mockito
Hi,

if you are using CXF, I've wrapped SOAP endpoint mocking in a JUnit rule with Mockito:


Best regards,
Thomas
Reply all
Reply to author
Forward
0 new messages