Proxy request to "real" webservice

677 views
Skip to first unread message

Roy de Kleijn

unread,
Aug 28, 2015, 3:50:08 AM8/28/15
to wiremock-user
Hello,

I see the following error occurring in my application:

Caused by: org.apache.cxf.transport.http.HTTPException: HTTP response '403: Forbidden' when communicating with http://localhost:9991/path


My configuration is as follows:

{
  "priority": 3,
  "request": {
    "method": "POST",
    "urlPattern": "/path"
  },
  "response": {
    "headers": {
      "Connection": "Keep-Alive",
      "Content-Type": "text/xml;charset=UTF-8",
      "Keep-Alive": "timeout=10, max=100",
      "Server": "Apache-Coyote/1.1"
    },
    "proxyBaseUrl": "https://realService.com"
  }
}

I see this in the console output from wiremock:

After request is coming in:
2015-08-28 09:44:49.593 Proxying: POST https://realService.com/path


What did I do wrong? how can we debug this?


Thanks,
Roy




Tom Akehurst

unread,
Aug 28, 2015, 3:35:45 PM8/28/15
to wiremock-user
Can you post the request you're making to WireMock?

I suspect it's the service you're proxying to that's returning the 403. I can't think of any circumstance in which WireMock would do that unless you explicitly configure a stub that way.

Roy de Kleijn

unread,
Aug 28, 2015, 3:51:06 PM8/28/15
to wiremock-user
The "real" service is responding without using wiremock. (with the same request)

Do we have to set additional headers? like referer?


Below is the request. It's confidential information, so I can't share the exact content.

POST /path HTTP/1.1
Content-Type: text/xml; charset=UTF-8
Accept: */*
SOAPAction: "urn:confidentialAction"
User-Agent: Apache CXF 2.4.8-patch-01
Cache-Control: no-cache
Pragma: no-cache
Host: localhost:9991
Connection: keep-alive
Content-Length: 1173

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><confidential body></soap:Body></soap:Envelope>
2015-08-28 21:47:01.836 Proxying: POST https://realService.com/path

Tom Akehurst

unread,
Aug 28, 2015, 6:09:21 PM8/28/15
to wiremock-user
Without knowing more about the target system, it's hard to say.

One thing I'd suggest doing is getting logging configured and turning org.apache.http.* up to DEBUG so that you get all the HTTP traffic from WireMock's proxy logged out.

Roy de Kleijn

unread,
Aug 30, 2015, 2:34:52 PM8/30/15
to wiremock-user
Will try that, but which file do I have to add to the class path?

Roy de Kleijn

unread,
Aug 30, 2015, 3:50:43 PM8/30/15
to wiremock-user
One more thing: this is about forward proxying HTTPS requests..

Tom Akehurst

unread,
Sep 1, 2015, 4:05:10 PM9/1/15
to wiremock-user
You can't forward proxy HTTPS, at all. Some proxies will let you work around that by turning into a TCP proxy via the CONNECT method, but that would be no use to WireMock as it needs to see the (unencrypted) contents of the request to be able to do anything useful.
Reply all
Reply to author
Forward
0 new messages