mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
WireMock.net record or stub support SOAP? #319
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ibmer921150 on GitHub (Dec 8, 2020).
Hi there,
May I know if Wiremock.net record support SOAP as endpoint? Also does the stub mode support SOAP response?
If it supports, would you please share examples?
I tried wiremock.net record mode for SOAP as endpoint, but got below errors:
{"The remote server returned an unexpected response: (405) Method Not Allowed."}
Thanks
Yu
@StefH commented on GitHub (Dec 8, 2020):
Recording SOAP is not different as other services. It should work.
Can you provide more details on the (error) message in the console-logging?
@ibmer921150 commented on GitHub (Dec 9, 2020):
Hi @StefH , it looks the wiremock.net record in the mappings, but return 405 as response code. Below is the error log I copied from wiremock mappings
@StefH commented on GitHub (Dec 9, 2020):
@ibmer921150 commented on GitHub (Dec 10, 2020):
Hi @StefH, for further investigation, it looks my urls configuration is wrong. After updated the url configuration, I got the wiremock proxy protentional working, which can route the soap request to the real soap endpoint, however failed with authentication issue
SOAP client returns below error:
Message "The HTTP request is unauthorized with client authentication scheme 'Basic'. The authentication header received from the server was 'Negotiate, NTLM, Basic realm=\"xxx\"'." stringWiremock proxy returns below error
If I try to send soap request to real endpoint without wiremock proxy, it works fine.
Do you have any advice how the wiremock proxy handling the authentication? Or how can we config authentication in wiremock settings properly?
Thanks
Yu
@StefH commented on GitHub (Dec 10, 2020):
Can you please show the complete soap-request you are sending?
@ibmer921150 commented on GitHub (Dec 14, 2020):
Hi @StefH, below is the soap request and response in wiremock.net mappings, hidden a few real data for security. FYI.
@StefH commented on GitHub (Dec 14, 2020):
At first look it seems that the authentication header is not send by you, or that this header is not recorded?
Can you also post here the complete original soap request ?
@ibmer921150 commented on GitHub (Dec 15, 2020):
hi @StefH,
When I monitor the soap transactions sending out from wiremock via fiddler or wireshark. I can see the auth header (Basic xxxxx) has been removed. When the soap transaction sending to endpoint directly, the auth (Basic xxxx) existed in the http header via fiddler or wireshark. I guess the wiremock may do some strange thing for the auth header?
Thanks
Yu
@ibmer921150 commented on GitHub (Dec 15, 2020):
Sorry @StefH I can not provide the complete original soap request as it is confidential.
@StefH commented on GitHub (Dec 15, 2020):
No problem. I'll investigate the code on the basic authentication header.
BTW what framework do you use?
@StefH commented on GitHub (Dec 15, 2020):
https://github.com/WireMock-Net/WireMock.Net/pull/555
@StefH commented on GitHub (Dec 15, 2020):
@ibmer921150 I'm not able to reproduce this problem with a UnitTest, so if you please can post the complete SOAP HTTP request (without confidential data) that would help me a lot.
@ibmer921150 commented on GitHub (Dec 15, 2020):
Thanks @StefH. Please review the two SOAP HTTP requests between wiremock and direct endpoint, captured via Wireshark, included header and request.
Wiremock

Direct endpoint

@StefH commented on GitHub (Dec 15, 2020):
@ibmer921150
How do you configure the proxying?
.WithProxy(...)@StefH commented on GitHub (Dec 15, 2020):
If I use this code:
And send a post request with Authorization to WireMock.Net , the response from postman echo does contain the header:

@ibmer921150 commented on GitHub (Dec 15, 2020):
@StefH here is my configuration, similar like yours. BTW, your example is API JSON request which is not exactly the same as SOAP header, such as content-type should be text/xml, including soapactions and etc. The c# source code setup the header and auth would be different. I am not expert of c#, I will join our dev to look into the source code of wiremock.net. Cheers.
@ibmer921150 commented on GitHub (Dec 16, 2020):
@StefH For further investigation today, I constructed the soap request via Postman and sent soap request to wiremock proxy. It can record the request mappings and response mappings successfully. Now the problem is more like our application is doing some strange things which can not be compatible with the wiremock proxy. I will do some further investigations and provide the PR if required. Thanks for your time on the question.
BTW, do we have any examples how to playback the exited mappings(JSON files) in stub mode? I assume it might be like wiremock.org that “Playback” doesn’t require any explicit action. But actually it is not for wiremock.net. Sorry I didn't find the related information in the wiki page, maybe I missed it...
@ibmer921150 commented on GitHub (Dec 16, 2020):
Above issue seems to be fixed after adding below:
AllowPartialMapping = true
@StefH commented on GitHub (Dec 16, 2020):
Please note that
AllowPartialMapping = trueis more of a last resort option. You can look at the logging to see which matchers do map or don't map 100% and fix the matching so that they do match.(Else you can run into problems in the future when you have a lot of mappings added and maybe the wrong partial matches.)
See this link for details https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching-Tips
Playing back is simple, just start WireMock.Net without any proxy settings and make sure
ReadStaticMappings = true,Now all the .json mapping files generated in the __/admin folder will be read and used.
(Maybe I forgot to add a Wiki page on this?)
@ibmer921150 commented on GitHub (Dec 16, 2020):
Very useful tips, thanks a lot.