简体   繁体   English

FitNesse:启用 FitNesse Fixture 在服务器端调用方法

[英]FitNesse: Enabling a FitNesse Fixture to call a method on the Server Side

I have implemented a Web Service with certain methods using Eclipse.我已经使用 Eclipse 通过某些方法实现了一个 Web 服务。

Then I exported it to a WAR file, which is to be to be used with Tomcat.然后我将它导出到一个 WAR 文件,该文件将与 Tomcat 一起使用。

Then I used wsimport to create 'stubs' for my web service.然后我使用wsimport为我的 Web 服务创建“存根”。

The 'stubs' are just interfaces. “存根”只是接口。

Now I want to know how to call the web service through my FitNesse fixture I'll be writing.现在我想知道如何通过我将要编写的FitNesse装置调用 Web 服务。

I'm coding in JAVA .我正在用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?有没有什么方法可以让我从我的FitNesse装置调用 Web 服务方法,记住为 Web 服务生成的“存根”?

There are many ways to do what you describe.有很多方法可以执行您所描述的操作。 You could, for instance, create your own fixture (ie class containing test code) in Java that uses the stubs you generated to call your service.例如,您可以在 Java 中创建您自己的装置(即包含测试代码的类),使用您生成的存根来调用您的服务。 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.或者(我更喜欢)是直接使用 HTTP 帖子调用服务,在 wiki 中配置,并执行 XPath 查询,通过编写 Java 代码或在 wiki 上配置 XPath,根据您收到的响应来检查您的服务实现。

The latter approach is supported by fixtures (and ready to run FitNesse installation) I put on GitHub ( https://github.com/fhoeben/hsac-fitnesse-fixtures ).后一种方法得到了我放在 GitHub 上的装置(并准备运行 FitNesse 安装)的支持( https://github.com/fhoeben/hsac-fitnesse-fixtures )。 For specific information on how to call a web service see https://github.com/fhoeben/hsac-fitnesse-fixtures/wiki/4.-XmlHttpTest-Examples and https://github.com/fhoeben/hsac-fitnesse-fixtures/wiki/6.-SoapCallMapColumnFixture-Examples depending on whether you want to use Slim or Fit.有关如何调用 Web 服务的具体信息,请参阅https://github.com/fhoeben/hsac-fitnesse-fixtures/wiki/4.-XmlHttpTest-Exampleshttps://github.com/fhoeben/hsac-fitnesse- fixtures/wiki/6.-SoapCallMapColumnFixture-Examples取决于您是要使用 Slim 还是 Fit。

Sample for Slim: 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="http://schemas.xmlsoap.org/soap/envelope/">
  <s11:Body>
    <ns1:GetCityWeatherByZIP xmlns:ns1="http://ws.cdyne.com/WeatherWS/">
      <ns1:ZIP>@{zip}</ns1:ZIP>
    </ns1:GetCityWeatherByZIP>
  </s11:Body>
 </s11:Envelope>
}}} }

 |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             |http://ws.cdyne.com/WeatherWS/|
 |check          |xPath          |//weather:City/text()|@{City}                       |
*!

 |send request       |
 |zip  |City         |
 |10007|New York     |
 |94102|San Francisco|

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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