Wiremock: Record multiple external services

Created on 3 Sep 2015  路  5Comments  路  Source: tomakehurst/wiremock

Hi,

First of all congratulations for this great library. Its simple to use, good documentation and more importantly: it works! :)

My issue is related with the fact that I need to record not one external service but many of them. It seems that the wiremock-standalone just has the option to setup one proxy using the --proxy-all switch. Is it possible to record with my own defined stubs? If no, is there any other to achieve this?

Thanks a lot!
Leo

Most helpful comment

Thanks!

Yes, it is possible to record against multiple targets by configuring a proxy stub mapping against each of them via the API rather than via the --proxy-all param (which actually just creates a single proxy mapping internally).

All 5 comments

Thanks!

Yes, it is possible to record against multiple targets by configuring a proxy stub mapping against each of them via the API rather than via the --proxy-all param (which actually just creates a single proxy mapping internally).

hi @tomakehurst . I am also attempting to record against multiple services. However it is not clear to me how to do it. The only way I can record is against one service via --proxyAll. Could you give me an example on how to do the above please?

hi @tomakehurst My API has multiple exernal API calls and i need to mock that by recording them. I am getting unauthorised error. However if i make calls to the external apis directly i am able to record them could you please help.

Hi; I just used wiremock to do some load testing in docker and it worked great; FWIW being able to record multiple urls at once would be nice, e.g. in docker-compose I had a single wiremock instance, and then gave my app both SERVICE_A_URL=http://wiremock/ and SERVICE_B_URL=http://wiremock as environment variables, but it meant I had to stop/start wiremock a few times to change the proxy-all from service a, record a request, shut it down, change proxy-all to service b, record a request, shut it down.

Doing something like --proxy-host=servicea:http://service-a.company.com --proxy-host=serviceb:http://service-b.company.com and then using host headers (e.g. SERVICE_A_URL=http://servicea/ within docker-compose) would be spiffy (specifically for recording requests that touch multiple services).

Great tool; thanks!

How to record against multiple targets by configuring a proxy stub mapping against each of them:

  1. Create a stub template and put it into mappings folder, example:
    { "mappings": [ { "request": { "method": "ANY", "urlPattern": "/api/.*" }, "response": { "proxyBaseUrl" : "http://example1.com" } }, { "request": { "method": "ANY", "urlPattern": "/content" }, "response": { "proxyBaseUrl" : "http://example2.com" } } ] }
  2. To record run: java -jar wiremock-standalone-2.25.1.jar --https-port 443 --https-keystore wiremock.jks --record-mappings --verbose
Was this page helpful?
0 / 5 - 0 ratings

Related issues

natros picture natros  路  5Comments

flyinfish picture flyinfish  路  3Comments

wujimin picture wujimin  路  4Comments

rpax picture rpax  路  3Comments

davidnewcomb picture davidnewcomb  路  5Comments