使用HTTP上的REST服务时出错

时间:2016-10-12 05:38:10

标签: rest http https mule connector

我有一个简单的REST HTTPS POST,它的uri是这样的:https://paymentservicestest.informa.com/mcas_services.asp

完美适用于在浏览器,Postman等中运行。使用Mule 3.8 HTTP我从RAML生成规范中选择uri,设置uri-param并且我仍然得到例外和下面的代码。



 ERROR 2016-10-11 16:16:52,944 [[tstconnection].HTTP_Listener_Configuration.worker.01] org.mule.module.http.internal.request.DefaultHttpRequester: Remote host closed connection. Possible SSL/TLS handshake issue. Check protocols, cipher suites and certificate set up. Use -Djavax.net.debug=handshake for further debugging.
 ERROR 2016-10-11 16:16:53,025 [[tstconnection].HTTP_Listener_Configuration.worker.01] org.mule.exception.DefaultMessagingExceptionStrategy: 
 ********************************************************************************
 Message               : Error sending HTTP request.
 Payload               : {NullPayload}
 Payload Type          : org.mule.transport.NullPayload
 Element               : /tstconnectionFlow/processors/1 @ tstconnection:tstconnection.xml:14 (HTTP)
 Element XML           : <http:request config-ref="HTTP_Request_Configuration" path="/mcas_services.asp" method="POST" doc:name="HTTP">
                         <http:request-builder>
                         <http:query-param paramName="username" value="XXXXX"></http:query-param>
                         <http:query-param paramName="password" value="XXXXX"></http:query-param>
                         <http:query-param paramName="method" value="XXXXX"></http:query-param>
                         <http:query-param paramName="source" value="XXXXX"></http:query-param>
                         <http:query-param paramName="cardtype" value="XXXXX"></http:query-param>
                         <http:query-param paramName="currency" value="XXXXX"></http:query-param>
                         </http:request-builder>
                         </http:request>
 --------------------------------------------------------------------------------
 Root Exception stack trace:
 java.io.IOException: Remotely closed
My sample Code is :

 <?xml version="1.0" encoding="UTF-8"?>
 
 <mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
     xmlns:spring="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
 http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
 http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
     <http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="2020" doc:name="HTTP Listener Configuration"/>
     <http:request-config name="HTTP_Request_Configuration" protocol="HTTPS" host="paymentservice.informa.com" port="443" connectionIdleTimeout="300000" responseTimeout="300000" doc:name="HTTP Request Configuration" />
     <flow name="tstconnectionFlow">
         <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
         <logger message="sampleTest" level="INFO" doc:name="Logger"/>
     <http:request config-ref="HTTP_Request_Configuration" path="/mcas_services.asp" method="GET" doc:name="HTTP">
            <!--  <http:request-builder>
                 <http:query-param paramName="qParams1" value="#[flowVars.qParams]"/>
             </http:request-builder> -->
                <http:request-builder>
                 <http:query-param paramName="username" value="XXXXXX"/>
                 <http:query-param paramName="password" value="XXXXXX"/>
                 <http:query-param paramName="method" value="XXXXXXX"/>
                 <http:query-param paramName="source" value="XXXXX"/>
                 <http:query-param paramName="cardtype" value="XXXX"/>
                 <http:query-param paramName="currency" value="XXX"/>
 
             </http:request-builder> 
         </http:request>
         <logger level="INFO" doc:name="blankResponse"/>
         <logger message="Reponse: #[payload]" level="INFO" doc:name="Logger"/>
     </flow>
 </mule>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

您的URI中似乎有拼写错误

我可以从你的帖子中看到实际的URI应该是:

https://paymentservices.informa.com/

在您的配置中,您正在调用以下URI:

https://paymentservice.informa.com/

确保在“服务”中包含“s”,这至少应该向正确的服务器发出成功请求。

将您的HTTP_Request_Configuration更改为:

<?xml version="1.0" encoding="UTF-8"?>
 
 <mule
...

<http:request-config name="HTTP_Request_Configuration" protocol="HTTPS" host="paymentservices.informa.com" port="443" connectionIdleTimeout="300000" responseTimeout="300000" doc:name="HTTP Request Configuration" />
...

 </mule>