Worklight 6.1 HTTPS适配器:带有GET的HttpHostConnectException但带有POST的成功

时间:2014-03-25 20:54:29

标签: ibm-mobilefirst worklight-adapters

Worklight Developer Edition 6.1。

我们使用以下代码调用返回重定向的简单HTTPS服务。在Chrome浏览器中,可以使用GET和POST成功调用该服务。

使用Chrome Dev HTTP客户端以及curl,通话工作正常:

curl -I https://XXX.ca/mobile
HTTP/1.1 302 Found
Date: Tue, 25 Mar 2014 20:50:21 GMT
Server: IBM_HTTP_Server
P3P: CP="NON UNI DEM IVAa IVDa STA PRE"
Location: https://XXX.ca/auth/Login?GAREASONCODE=-1&GARESOURCEID=sbip19&GAURI=https://XXX.ca/mobile&Reason=-1&APPID=sbip19&URI=https://XXX.ca/
mobile
Content-Type: text/html; charset=iso-8859-1

在具有GET的适配器中,我们收到HttpHostConnectException:

function testFlow() {
    var input = {
        path: 'mobile',
        method : 'get',
        returnedContentType : 'plain'
    };

    return WL.Server.invokeHttp(input);
}

################################## Response ####################################

{
   "errors": [
      "Runtime: Http request failed: org.apache.http.conn.HttpHostConnectException: Connection to https:\/\/XXX.ca refused"
   ],
   "info": [
   ],
   "isSuccessful": false,
   "warnings": [
   ]
}

################################### Exception ##################################

[ERROR   ] FWLSE0099E: An error occurred while invoking procedure  [project LinkMobileWave0]authenticate/HttpRequestFWLSE0100E:  parameters: [project LinkMobileWave0]
Http request failed: org.apache.http.conn.HttpHostConnectException: Connection to https://XXX.ca refused
FWLSE0101E: Caused by:  [project LinkMobileWave0]org.apache.http.conn.HttpHostConnectException: Connection to https://XXX.ca refusedjava.lang.RuntimeException: Http request failed: org.apache.http.conn.HttpHostConnectException: Connection to https://XXX.ca refused
    at com.worklight.adapters.http.HTTPConnectionManager.execute(HTTPConnectionManager.java:241)
    at com.worklight.adapters.http.HttpClientContext.doExecute(HttpClientContext.java:176)
    at com.worklight.adapters.http.HttpClientContext.execute(HttpClientContext.java:160)
    at com.worklight.adapters.http.HTTP.execRequest(HTTP.java:144)
    at com.worklight.adapters.http.HTTP.invoke(HTTP.java:133)
    at com.worklight.integration.model.ProcedureInvoker.invokeProcedure(ProcedureInvoker.java:57)
    at com.worklight.integration.model.Procedure.invoke(Procedure.java:166)
    at com.worklight.integration.model.InvocationContext.call(InvocationContext.java:169)
    at com.worklight.integration.model.InvocationContext.call(InvocationContext.java:38)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at com.worklight.integration.model.InvocationContext$DirectExecutorService.execute(InvocationContext.java:284)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:132)
    at com.worklight.integration.model.InvocationContext.submit(InvocationContext.java:138)
    at com.worklight.integration.model.InvocationContextManager.submitInvocation(InvocationContextManager.java:58)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.callProcedure(DataAccessServiceImpl.java:497)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.access$100(DataAccessServiceImpl.java:56)
    at com.worklight.integration.services.impl.DataAccessServiceImpl$4.execute(DataAccessServiceImpl.java:392)
    at com.worklight.core.auth.impl.AuthenticationServiceBean.accessResource(AuthenticationServiceBean.java:76)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.invokeProcedureInternal(DataAccessServiceImpl.java:389)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.invokeDynamicProcedure(DataAccessServiceImpl.java:456)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.invokeDynamicProcedureWithEnclosingProcedureProperties(DataAccessServiceImpl.java:440)
    at com.worklight.integration.js.JavaScriptIntegrationLibraryImplementation.invokeDynamicProcedureWithEnclosingProcedureProperties(JavaScriptIntegrationLibraryImplementation.java:136)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
    at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:225)
    at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:52)
    at org.mozilla.javascript.gen._integration_js_1._c_anonymous_10(/integration.js:95)
    at org.mozilla.javascript.gen._integration_js_1.call(/integration.js)
    at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
    at org.mozilla.javascript.gen._5C_5Cvmware_host_5CShared_Folders_5CDocuments_5Cwin_workspace_5CLinkMobileWave0_5Cadapters_5Cauthenticate_authenticate_impl_js_4._c_testFlow_5(%5C%5Cvmware-host%5CShared+Folders%5CDocuments%5Cwin_workspace%5CLinkMobileWave0%5Cadapters%5Cauthenticate/authenticate-impl.js:281)
    at org.mozilla.javascript.gen._5C_5Cvmware_host_5CShared_Folders_5CDocuments_5Cwin_workspace_5CLinkMobileWave0_5Cadapters_5Cauthenticate_authenticate_impl_js_4.call(%5C%5Cvmware-host%5CShared+Folders%5CDocuments%5Cwin_workspace%5CLinkMobileWave0%5Cadapters%5Cauthenticate/authenticate-impl.js)
    at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
    at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
    at org.mozilla.javascript.gen._5C_5Cvmware_host_5CShared_Folders_5CDocuments_5Cwin_workspace_5CLinkMobileWave0_5Cadapters_5Cauthenticate_authenticate_impl_js_4.call(%5C%5Cvmware-host%5CShared+Folders%5CDocuments%5Cwin_workspace%5CLinkMobileWave0%5Cadapters%5Cauthenticate/authenticate-impl.js)
    at com.worklight.integration.js.JavaScriptManager.callFunction(JavaScriptManager.java:240)
    at com.worklight.integration.js.JavaScriptManager.invokeFunction(JavaScriptManager.java:214)
    at com.worklight.integration.js.JavaScriptManager.invokeFunction(JavaScriptManager.java:194)
    at com.worklight.integration.services.impl.AdapterManagerImpl.invokeFunction(AdapterManagerImpl.java:104)
    at com.worklight.integration.js.JavaScriptProcedureInvoker.invoke(JavaScriptProcedureInvoker.java:42)
    at com.worklight.integration.model.ProcedureInvoker.invokeProcedure(ProcedureInvoker.java:57)
    at com.worklight.integration.model.Procedure.invoke(Procedure.java:166)
    at com.worklight.integration.model.InvocationContext.call(InvocationContext.java:169)
    at com.worklight.integration.model.InvocationContext.call(InvocationContext.java:38)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at com.worklight.server.util.ProjectLocal$1RunnableWrapper.run(ProjectLocal.java:267)
    at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.http.conn.HttpHostConnectException: Connection to https://XXX.ca refused
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:158)
    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:573)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
    at com.worklight.adapters.http.HTTPConnectionManager.execute(HTTPConnectionManager.java:239)
    ... 50 more
Caused by: java.net.ConnectException: Connection timed out: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:579)
    at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:618)
    at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:375)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
    ... 56 more

通过POST,我们取得了成功:

##################################### POST #####################################

function testFlow() {
    var input = {
        path: 'mobile',
        method : 'post',
        returnedContentType : 'plain'
    };

    return WL.Server.invokeHttp(input);
}

################################### Response ###################################

{
   "errors": [
   ],
   "info": [
   ],
   "isSuccessful": true,
   "responseHeaders": {
      "Connection": "Keep-Alive",
      "Content-Length": "459",
      "Content-Type": "text\/html; charset=iso-8859-1",
      "Date": "Tue, 25 Mar 2014 19:11:11 GMT",
      "Keep-Alive": "timeout=10, max=100",
      "Location": "https:\/\/XXX.ca\/auth\/Login?GAREASONCODE=-1&GARESOURCEID=sbip19&GAURI=https:\/\/XXX.ca:443\/mobile&Reason=-1&APPID=sbip19&URI=https:\/\/XXX.ca:443\/mobile",
      "P3P": "CP=\"NON UNI DEM IVAa IVDa STA PRE\"",
      "Server": "IBM_HTTP_Server"
   },
   "responseTime": 733,
   "statusCode": 302,
   "statusReason": "Found",
   "text": "<!DOCTYPE HTML PUBLIC \"-\/\/IETF\/\/DTD HTML 2.0\/\/EN\">\n<html><head>\n<title>302 Found<\/title>\n<\/head><body>\n<h1>Found<\/h1>\n<p>The document has moved <a href=\"https:\/\/XXX.ca\/auth\/Login?GAREASONCODE=-1&GARESOURCEID=sbip19&GAURI=https:\/\/XXX.ca:443\/mobile&Reason=-1&APPID=sbip19&URI=https:\/\/XXX.ca:443\/mobile\">here<\/a>.<\/p>\n<hr>\n<address>IBM_HTTP_Server at XXX.ca Port 443<\/address>\n<\/body><\/html>",
   "totalTime": 733,
   "warnings": [
   ]
}

4 个答案:

答案 0 :(得分:4)

这最终成为Worklight问题。 [APAR PI14842: HTTPS GET PROBLEM WHEN USING WL.SERVER.INVOKEHTTP](http://www.ibm.com/support/docview.wss?uid=swg1PI14842

HTTPS GET请求导致HTTP 302重定向响应时,invokeHttp方法将停止,直到超时,然后以

结束
Runtime: Http request failed:
org.apache.http.conn.HttpHostConnectException: Connection to https:\/\/XXX.ca refused

您可以观看APAR PI14842,了解修补程序何时可用。

答案 1 :(得分:0)

Worklight开发团队目前正在调查此问题,以确定这是否是一个错误;如果是,将发布修复程序。

答案 2 :(得分:-1)

也许你没有像“post方法”那样实现“get方法”。你可以检查或粘贴适配器试图调用的代码

答案 3 :(得分:-1)

查看WL.Server.invokeHttp的API文档,它似乎不会将'path'列为它接受的值。

从你得到的错误来看,它似乎也没有在GET上使用它。 该连接可能被拒绝,因为它尝试连接到https://XXX.ca而不是https://XXX.ca/mobile