我已经使用 Eclipse 使用某些方法实现了 Web 服务。
然后我把它导出到一个WAR文件,这个文件是要和Tomcat一起使用的。
然后我使用 wsimport
为我的网络服务创建“ stub ”。
“ stub ”只是接口(interface)。
现在我想知道如何通过我将要编写的 FitNesse 装置调用 Web 服务。
我正在用 JAVA 编写代码。
是否有任何方法可以让我从我的 FitNesse 装置调用网络服务方法,同时记住为网络服务生成的“ stub ”?
最佳答案
有很多方法可以完成您描述的操作。 例如,您可以在 Java 中创建自己的夹具(即包含测试代码的类),它使用您生成的 stub 来调用您的服务。或者(我更喜欢)是直接使用在 wiki 中配置的 HTTP posts 调用服务,并执行 XPath 查询,通过编写 Java 代码或在 wiki 上配置 XPaths,根据您收到的响应来检查您的服务实现。
后一种方法由我放在 GitHub (https://github.com/fhoeben/hsac-fitnesse-fixtures) 上的固定装置支持(并准备运行 FitNesse 安装)。有关如何调用 Web 服务的具体信息,请参阅 https://github.com/fhoeben/hsac-fitnesse-fixtures/wiki/4.-XmlHttpTest-Examples和 https://github.com/fhoeben/hsac-fitnesse-fixtures/wiki/6.-SoapCallMapColumnFixture-Examples取决于您是想使用 Slim 还是 Fit。
修身示例:
!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|
关于java - FitNesse:启用 FitNesse Fixture 以在服务器端调用方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28229071/