简体   繁体   中英

Testing Web Service WSDL without SoapUI

I have a WSDL that has a handful of methods that I want to test. I was wondering if there is a way to write service requests and send them directly to the WSDL through Java? I could then parse the response to validate the success of the tests. I know that you can do this through soap UI but the problem I have with this is that I want multiple people who use this service to be able to run these tests and not everyone is using the same version of Soap UI. They are also going to be data driven tests so I want to be able to handle large data sets in cvs/xls files through java automatically instead of manually.

Any advice on where to begin?

Thanks

1.) Generate your webservices stub classes from your WSDL with the tool of your joice (for example wsimport). In the simplest way this looks like this:

wsimport.exe -d <Path2StoreGeneratedStubs> -s <Path2StoreSourceFiles> -keep <Path2YourWsdl> 

2.) Use those classes from within your JUnit tests to directly talk with your webservice.

So for your JUnit youre basicially on the client-side of your webservice. You want to generate stub classes to allow you to talk to your webservice but instead of writing a nice client application you are just using those Stubs for TestCases (just pseudo...) like this:

 @Test
 public void testPingMethod(){
       MyService service = new MyServiceImpl();
       MyPingResponse res = service.ping();
       Assert.assertNotNull(res);
 }

So MyService/ MyPingResonse in this example would be generated from the WSDL while the (also just an example) of the Assert would verify your Webservice sends back a response fo this request.

If you never had to write client code i recomend you do a 5min. Tutorial on the topic since its pretty easy to use an existing webservice :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM