简体   繁体   English

基于WSDL的Groovy / Grails模拟Web服务

[英]Groovy/Grails mock web service based on WSDL

I've inherited a Grails app which makes calls out to a web service, using javax.xml.ws* classes and I'm trying to find a way to mock the web service based on the WSDL for the integration tests. 我继承了一个Grails应用程序,该应用程序使用javax.xml.ws *类对Web服务进行了调用,并且我试图找到一种基于WSDL进行集成测试的模拟Web服务的方法。 I realize that I can use one of the java soap implementations to build this, but I'd rather stay in groovy. 我意识到我可以使用Java Soap实现之一来构建它,但是我宁愿呆在常规中。

So my question is, is there an idiomatic groovy way to build a web service based on a WSDL? 所以我的问题是,是否有一种惯用的常规方法来构建基于WSDL的Web服务?

One approach that is pretty straightforward is to use Jetty to create a mock. 一种非常简单的方法是使用Jetty创建一个模拟。 It´s easy to create a mock that looks at the request and generates a response, especially if you´re using Groovy. 创建一个可以查看请求并生成响应的模拟很容易,尤其是在使用Groovy的情况下。 For instance, create a template response file and use the XmlSlurper to fill in values. 例如,创建模板响应文件并使用XmlSlurper填写值。 Then you can either start the mock in your tests or run it independently. 然后,您可以在测试中启动模拟,也可以独立运行。

I found the following blog that roughly explains the basic concept: 我发现以下博客大致解释了基本概念:

http://olafsblog.sysbsb.de/lightweight-testing-of-webservice-http-clients-with-junit-and-jetty/ http://olafsblog.sysbsb.de/lightweight-testing-of-webservice-http-clients-with-junit-and-jetty/

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

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