久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Java 中將 WireMock 與 SOAP Web 服務一起使用

Using WireMock with SOAP Web Services in Java(在 Java 中將 WireMock 與 SOAP Web 服務一起使用)
本文介紹了在 Java 中將 WireMock 與 SOAP Web 服務一起使用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我對 WireMock 完全陌生.

到目前為止,我一直在使用 SOAPUI 模擬響應.我的用例很簡單:

Until now, I have been using mock responses using SOAPUI. My use case is simple:

只需將 SOAP XML 請求發送到不同的端點 (http://localhost:9001/endpoint1) 并獲得罐頭返回 XML 響應.但是 MockWrire 必須作為獨立服務部署到專用服務器上,該服務器將充當提供模擬響應的中心位置.

Just firing SOAP XML requests to different endpoints (http://localhost:9001/endpoint1) and getting canned XML response back. But MockWrire has to be deployed as a standalone service onto a dedicated server which will act a central location from where mock responses will be served.

只是想要一些開始的建議.正如我所見,WireMock 更適合 REST Web 服務.所以我的疑問是:

Just wanted some starting suggestions. As I can see WireMock is more suitable towards REST web services. So my doubts are:

1) 我是否需要將其部署到 Java Web 服務器或容器以充當始終運行的獨立服務.我讀到你可以通過使用來分拆

1) Do I need to deploy it to a java web server or container to act as always running standalone service. I read that you can just spin off by using

java -jar mockwire.jar --port [port_number]

2) 我需要使用 MockWire API 嗎?我需要為我的用例制作課程嗎?就我而言,請求將通過 JUnit 測試用例觸發以進行模擬.

2) Do I need to use MockWire APIs? Do I need to make classes for my use case? In my case, requests will be triggered via JUnit test cases for mocking.

3) 如何實現簡單的 URL 模式匹配?如上所述,我只需要簡單的模擬,即在向 http://localhost:9001/endpoint1

3) How do I achieve simple URL pattern matching? As stated above, I just need simple mocking i.e get response when request is made to http://localhost:9001/endpoint1

4) 我的用例是否有更好/更簡單的框架?我讀過 Mockable,但它對 3 名團隊成員和免費層的演示域有限制.

4) Is there a better/easier framework for my usecase? I read about Mockable but it has restrictions for 3 team members and demo domain in free tier.

推薦答案

我是 WireMock 的創造者.

I'm WireMock's creator.

我最近使用 WireMock 在客戶端項目上模擬了一組 SOAP 接口,因此我可以證明這是可能的.至于它是否比 SOAP UI 更好或更差,我想說有一些明確的好處,但也有一些權衡.一個主要的好處是相對易于部署和編程訪問/配置,以及對 HTTPS 和低級故障注入等內容的支持.但是,您需要做更多的工作來解析和生成 SOAP 有效負載 - 它不會像 SOAP UI 那樣從 WSDL 生成代碼/存根.

I've used WireMock to mock a collection of SOAP interfaces on a client project quite recently, so I can attest that it's possible. As for whether it's better or worse than SOAP UI, I'd say there are some definite upsides, but with some tradeoffs. A major benefit is the relative ease of deployment and programmatic access/configuration, and support for things like HTTPS and low-level fault injection. However, you need to do a bit more work to parse and generate SOAP payloads - it won't do code/stub generation from WSDL like SOAP UI will.

我的經驗是,像 SOAP UI 這樣的工具可以讓您更快地開始,但從長遠來看,當您的測試套件變得非?,嵥闀r,往往會導致更高的維護成本.

My experience is that tools like SOAP UI will get you started faster, but tend to result in higher maintenance costs in the long run when your test suite grows beyond trivial.

依次解決您的觀點:1)如果您希望您的模擬在某處的服務器上運行,最簡單的方法是運行您所描述的獨立 JAR.我建議不要嘗試將其部署到容器中 - 此選項僅在別無選擇時才存在.

To address your points in turn: 1) If you want your mocks to run on a server somewhere, the easiest way to do this is to run the standalone JAR as you've described. I'd advise against trying to deploy it to a container - this option really only exists for when there's no alternative.

但是,如果您只想運行集成測試或完全獨立的功能測試,我建議您使用 JUnit 規則.我想說在專用進程中運行它只是一個好主意,如果 a) 您將其他已部署的系統插入其中,或者 b) 您從非 JVM 語言中使用它.

However, if you just want to run integration tests or totally self-contained functional tests, I'd suggest using the JUnit rule. I'd say it's only a good idea to run it in a dedicated process if either a) you're plugging other deployed systems into it, or b) you're using it from a non-JVM language.

2) 您需要以 3 種方式之一對其進行配置:1) Java API,2) 基于 HTTP 的 JSON,或 3) JSON 文件.3) 可能最接近您使用 SOAP UI 的習慣.

2) You'd need to configure it in one of 3 ways 1) the Java API, 2) JSON over HTTP, or 3) JSON files. 3) is probably closest to what you're used to with SOAP UI.

3) 查看 http://wiremock.org/stubbing.html 了解大量使用JSON 和 Java.由于 SOAP 傾向于綁定到固定的端點 URL,您可能需要 urlEqualTo(...).當我過去使用 SOAP 存根時,我傾向于在整個請求正文上進行 XML 匹配(請參閱 http://wiremock.org/stubbing.html#xml-body-matching).我建議投資編寫一些 Java 構建器來發出您需要的請求和響應正文 XML.

3) See http://wiremock.org/stubbing.html for lots of stubbing examples using both JSON and Java. Since SOAP tends to bind to fixed endpoint URLs, you probably want urlEqualTo(...). When I've stubbed SOAP in the past I've tended to XML match on the entire request body (see http://wiremock.org/stubbing.html#xml-body-matching). I'd suggest investing in writing a few Java builders to emit the request and response body XML you need.

4) 模擬服務器 和 Betamax 都是 WireMock 的成熟替代品,但 AFAIK 它們不提供任何更明確的 SOAP 支持.

4) Mock Server and Betamax are both mature alternatives to WireMock, but AFAIK they don't offer any more explicit SOAP support.

這篇關于在 Java 中將 WireMock 與 SOAP Web 服務一起使用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to mock super reference (on super class)?(如何模擬超級參考(在超級類上)?)
Java mock database connection(Java 模擬數據庫連接)
Mockito ClassCastException - A mock cannot be cast(Mockito ClassCastException - 無法投射模擬)
Set value to mocked object but get null(將值設置為模擬對象但獲取 null)
How to mock DriverManager.getConnection(...)?(如何模擬 DriverManager.getConnection(...)?)
Mockito; verify method was called with list, ignore order of elements in list(模擬;使用列表調用驗證方法,忽略列表中元素的順序)
主站蜘蛛池模板: 亚洲精品欧美 | 一区二区三区小视频 | 巨大黑人极品videos精品 | 国产三区四区 | 日韩成人一区 | 日韩色视频| 日韩成人av在线 | 成人精品在线观看 | 国产一区| 久久av资源网 | 久久这里有精品 | 99视频免费在线观看 | 国产精品久久久久久 | 精品国产18久久久久久二百 | 九九九国产 | 国产精品中文字幕在线 | 天堂色综合 | 在线成人免费av | 久久久久久高清 | 色悠悠久 | 中文字幕97 | 国产伦精品一区二区三区四区视频 | 国产精品夜夜春夜夜爽久久电影 | 国产一区二区三区在线免费观看 | 北条麻妃av一区二区三区 | 欧美一级二级视频 | 欧美午夜在线 | 久久久99精品免费观看 | 男插女下体视频 | 欧美一区二区三区视频在线 | 欧美aⅴ在线观看 | 国产大片一区 | pacopacomama在线 | a欧美| 欧美日韩一区二区三区在线观看 | 日韩无 | 午夜av电影 | 产真a观专区| 啪一啪在线视频 | 国产精品美女久久久久aⅴ国产馆 | 欧美性影院 |