Iceman Iceman - 2 years ago 140
Java Question

FitNesse Fixtures - Enabling a FitNesse Fixture to call a method on the Server Side

I'm new to FitNesse. I would like to know certain things.
Firstly, I have implemented a Web Service with certain methods using Eclipse.
Then, I exported it to a WAR file, which is to be to be used with Tomcat.
Then I used wsimport to create 'stubs' for my web service. The 'stubs' are just the interfaces.
Now I want to know how to call the web service through my FitNesse fixture I'll be writing. I'm coding in JAVA. Is there any method through which I can call the web service method from my FitNesse fixture, keeping in mind the 'stubs' generated for the web service?

I'm totally new to this. Help will be appreciated. Thanks!

Answer Source

There are many ways to do what you describe. You could, for instance, create your own fixture (i.e. class containing test code) in Java that uses the stubs you generated to call your service. Or (what I prefer) is to call the services directly using HTTP posts, configured in the wiki, and execute XPath queries, configuring the XPaths either by writing Java code or on the wiki, on the responses you receive to check you service implementation.

The latter approach is supported by fixtures (and ready to run FitNesse installation) I put on GitHub ( For specific information on how to call a web service see and depending on whether you want to use Slim or Fit.

Sample for Slim:

!2 Body via scenario

Using a scenario allows us to generate multiple request, only changing certain values.

!*> Scenario definition
!define POST_BODY_2 { {{{
<s11:Envelope xmlns:s11="">
    <ns1:GetCityWeatherByZIP xmlns:ns1="">
}}} }

 |script|xml http test|

 |table template |send request                                                            |
 |post           |${POST_BODY_2} |to                   |${URL}                            |
 |check          |response status|200                                                      |
 |show           |response                                                                 |
 |register prefix|weather        |for namespace             ||
 |check          |xPath          |//weather:City/text()|@{City}                       |

 |send request       |
 |zip  |City         |
 |10007|New York     |
 |94102|San Francisco|
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download