我有一个简单的REST HTTPS GET,它的uri是这样的:
https://mytest.test:443/nccpointshop/REST/giftcard/giftcards/list/currency/SEK
完美适用于在浏览器,Postman等中运行。使用Mule 3.8 HTTP我从RAML生成的规范中选择uri,设置uri-param并且我仍然得到例外:
DEBUG 2016-06-28 16:38:35,321 [[svc0014_loyalty].http.requester.ODP_Request_Configuration(1) SelectorRunner] com.ning.http.client.providers.grizzly.AsyncHttpClientFilter: REQUEST: HttpRequestPacket (
method=GET
url=/nccpointshop/REST/giftcard/giftcards/list/currency/SEK
query=null
protocol=HTTP/1.1
content-length=-1
headers=[
Host=correct.host:443
User-Agent=AHC/1.0
Connection=keep-alive
Accept=*/*]
)
DEBUG 2016-06-28 16:38:35,322 [[svc0014_loyalty].http.requester.ODP_Request_Configuration(1) SelectorRunner] org.mule.module.http.internal.HttpMessageLogger: REQUESTER
GET /nccpointshop/REST/giftcard/giftcards/list/currency/SEK HTTP/1.1
Host: correct.host:443
User-Agent: AHC/1.0
Connection: keep-alive
Accept: */*
DEBUG 2016-06-28 16:38:35,498 [[svc0014_loyalty].http.requester.ODP_Request_Configuration.worker(8)] com.ning.http.client.AsyncCompletionHandlerBase: Remotely closed
java.io.IOException: Remotely closed
DEBUG 2016-06-28 16:38:35,520 [[svc0014_loyalty].svc0014_loyalty-httpListenerConfig.worker.02] com.mulesoft.mule.debugger.server.DebuggerMuleNotificationHandlerImpl: MESSAGE_PROCESSOR_POST_INVOKE -> Path /get:\/giftcards:svc0014_loyalty-config/processors/2
DEBUG 2016-06-28 16:38:37,327 [[svc0014_loyalty].Mule.01] com.mulesoft.mule.debugger.server.DebuggerMuleNotificationHandlerImpl: Notification 2001 was received ef4625b0-3d3d-11e6-998f-448500a727fa
ERROR 2016-06-28 16:38:37,329 [[svc0014_loyalty].svc0014_loyalty-httpListenerConfig.worker.02] org.mule.module.apikit.MappingExceptionListener:
********************************************************************************
Message : Error sending HTTP request. Message payload is of type: NullPayload
Type : org.mule.api.MessagingException
Code : MULE_ERROR-29999
Payload : {NullPayload}
JavaDoc : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html
********************************************************************************
Exception stack is:
1. Remotely closed (java.io.IOException)
2. java.io.IOException: Remotely closed (java.util.concurrent.ExecutionException)
org.glassfish.grizzly.impl.SafeFutureImpl$Sync:349 (null)
3. java.util.concurrent.ExecutionException: java.io.IOException: Remotely closed (java.io.IOException)
org.mule.module.http.internal.request.grizzly.GrizzlyHttpClient:245 (null)
4. Error sending HTTP request. Message payload is of type: NullPayload (org.mule.api.MessagingException)
org.mule.module.http.internal.request.DefaultHttpRequester:287 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
********************************************************************************
Root Exception stack trace:
java.io.IOException: Remotely closed
********************************************************************************
我附上了我的配置如何的图片
答案 0 :(得分:2)
使用Mule HTTP连接器的事情是,它始终将关联配置中的主机和端口添加为标头: 标题= [ 主机= correct.host:443
有些系统不允许这样做,他们不接受添加端口(在我们的例子中,端口是在后端系统中动态分配的)。 因此,此请求:https://correct.host:443/nccpointshop/REST/giftcard/giftcards/list/currency/SEK
无效,但这个有效: https://correct.host/nccpointshop/REST/giftcard/giftcards/list/currency/SEK
这很难被注意到,因为Postman和Chrome都会发送正确的请求。我建议使用一些其他工具,如SoapUI(我注意到它)。 但是,有一种方法可以覆盖" Host"在这样的标题中:
<http:request config-ref="HTTP_Request_Configuration1" path="/nccpointshop/REST/giftcard/giftcards/list/currency/SEK" method="GET" doc:name="Copy_of_HTTP">
<http:request-builder>
<http:header headerName="Host" value="correct.host"/>
</http:request-builder>
</http:request>