如何调用适配器的URL或链接

时间:2015-03-30 17:11:23

标签: ibm-mobilefirst mobilefirst-adapters

我需要知道如何从云中的开发服务器调用适配器。在本地环境中,我们可以在eclipse中选择,但在云中的开发服务器中,我看不到调用的选项。

我使用MobileFirst 7.0


更新 - 基于标签的通知未到达我的设备。

问题是在控制台中通知成功,但这些从未到达我的设备。这是我日志中的消息。

[4/1/15 19:39:03:451 CDT] 00000081 ht.integration.js.JavaScriptIntegrationLibraryImplementation I Notificacion enviada exitosamente {"message":{"alert":"nacion"},"target":{"tagNames":["nacion"]},"settings":{"apns":{"sound":"57_dog-barking.mp3","payload":{"url":"nacion"}}}} [project ElUniversal]
[4/1/15 19:41:14:328 CDT] 0000013f ht.integration.js.JavaScriptIntegrationLibraryImplementation I Notificacion enviada exitosamente {"message":{"alert":"nacion"},"target":{"tagNames":["nacion"]},"settings":{"apns":{"sound":"57_dog-barking.mp3","payload":{"url":"nacion.com"}}}} [project ElUniversal]
[4/1/15 19:42:26:417 CDT] 000000cb ht.integration.js.JavaScriptIntegrationLibraryImplementation I Notificacion enviada exitosamente {"message":{"alert":"metropolitest"},"target":{"tagNames":["metropoli"]},"settings":{"apns":{"sound":"57_dog-barking.mp3","payload":{"url":"metropoliurl"}}}} [project ElUniversal]
[4/1/15 19:42:36:649 CDT] 00000118 ht.integration.js.JavaScriptIntegrationLibraryImplementation I Notificacion enviada exitosamente {"message":{"alert":"metropolitest"},"target":{"tagNames":["metropoli"]},"settings":{"apns":{"sound":"57_dog-barking.mp3","payload":{"url":"metropoliurl"}}}} [project ElUniversal]
[4/1/15 19:44:15:229 CDT] 000000d1 com.worklight.common.util.jmx.LibertyRuntimeMBeanHandler     I Establishing REST connection to service:jmx:rest://localhost:9443/IBMJMXConnectorREST
[4/1/15 19:45:03:448 CDT] 000001d7 ht.integration.js.JavaScriptIntegrationLibraryImplementation I Notificacion enviada exitosamente {"message":{"alert":"metropolitest"},"target":{"tagNames":["metropoli"]},"settings":{"apns":{"sound":"57_dog-barking.mp3","payload":{"url":"metropoliurl"}}}} [project ElUniversal]
[4/1/15 19:45:23:708 CDT] 00000036 ht.integration.js.JavaScriptIntegrationLibraryImplementation I Notificacion enviada exitosamente {"message":{"alert":"metropolitest"},"target":{"tagNames":["metropoli"]},"settings":{"apns":{"sound":"57_dog-barking.mp3","payload":{"url":"metropoliurl"}}}} [project ElUniversal]
[4/1/15 19:46:29:882 CDT] 000001e8 ht.integration.js.JavaScriptIntegrationLibraryImplementation I Notificacion enviada exitosamente {"message":{"alert":"deportestest"},"target":{"tagNames":["deportes"]},"settings":{"apns":{"sound":"57_dog-barking.mp3","payload":{"url":"deportesurl"}}}} [project ElUniversal]

在我的nativeApp中,与服务器的连接是正确的,这是输出的一部分:

 2015-04-01 19:09:34.041 El_Universal_Demo[211:9844] [DEBUG] [WL_REQUEST] -[WLRequest sendRequest:path:withOptions:] in WLRequest.m:220 :: Sending request (http://198.11.212.196:9080/ElUniversal/apps/services/loguploader) with headers: 
{
"Accept-Language" = es;
"Content-Encoding" = gzip;
"Content-Type" = "application/json";
"User-Agent" = "El_Universal_Demo/1 (iPhone; iOS 8.1.2; Scale/2.00)/WLNativeAPI/7.0.0.0";
"X-Requested-With" = XMLHttpRequest;
"x-wl-app-version" = "1.0";
"x-wl-clientlog-appname" = "El_Universal_Demo";
"x-wl-clientlog-appversion" = "1.0";
"x-wl-clientlog-deviceId" = "A6042553-8580-4365-A69C-6731388D6A56";
"x-wl-clientlog-env" = iOSnative;
"x-wl-clientlog-model" = "iPhone6,1";
"x-wl-clientlog-osversion" = "8.1.2";
"x-wl-compressed" = true;
"x-wl-device-id" = "A6042553-8580-4365-A69C-6731388D6A56";
"x-wl-platform-version" = "7.0.0.0";
}
 You can see the request body in the Analytics platform logs.
 2015-04-01 19:09:34.081 El_Universal_Demo[211:9844] [DEBUG]    [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper start] in  WLAFHTTPClientWrapper.m:297 :: Starting the request with URL   http://198.11.212.196:9080/ElUniversal/apps/services/loguploader
 2015-04-01 19:09:34.085 El_Universal_Demo[211:9844] [DEBUG] [WL_REQUEST] __42-[WLRequest sendRequest:path:withOptions:]_block_invoke in WLRequest.m:230 :: waiting for response... (Thread=<NSThread: 0x170260f40>{number = 1, name = main})
 2015-04-01 19:09:34.187 El_Universal_Demo[211:9844] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper requestFinished:] in WLAFHTTPClientWrapper.m:310 :: Request Success
 2015-04-01 19:09:34.193 El_Universal_Demo[211:9844] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper requestFinished:] in WLAFHTTPClientWrapper.m:311 :: Response Status Code : 201
2015-04-01 19:09:34.199 El_Universal_Demo[211:9844] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper requestFinished:] in WLAFHTTPClientWrapper.m:312 :: Response Content : 
2015-04-01 19:09:34.210 El_Universal_Demo[211:9844] [DEBUG] [WL_REQUEST] -[WLRequest requestFinished:] in WLRequest.m:361 :: Response Header: {
"Content-Language" = "en-US";
"Content-Length" = 0;
Date = "Thu, 02 Apr 2015 01:10:30 GMT";
P3P = "policyref=\"/w3c/p3p.xml\", CP=\"CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE\"";
"X-Powered-By" = "Servlet/3.0";
 }
 Response Data: 
  Status code=201
  2015-04-01 19:09:34.214 El_Universal_Demo[211:9844] [DEBUG] [WL_REQUEST] -[WLRequest requestFinished:] in WLRequest.m:404 :: NSS object is null
 2015-04-01 19:09:34.217 El_Universal_Demo[211:9844] [DEBUG] [OCLogger] Client Logs successfully sent to server.
 2015-04-01 19:09:34.269 El_Universal_Demo[211:9844] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper requestFinished:] in WLAFHTTPClientWrapper.m:310 :: Request Success
2015-04-01 19:09:34.274 El_Universal_Demo[211:9844] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper requestFinished:] in WLAFHTTPClientWrapper.m:311 :: Response Status Code : 201
  2015-04-01 19:09:34.279 El_Universal_Demo[211:9844] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper requestFinished:] in WLAFHTTPClientWrapper.m:312 :: Response Content : 
 2015-04-01 19:09:34.290 El_Universal_Demo[211:9844] [DEBUG] [WL_REQUEST] -[WLRequest requestFinished:] in WLRequest.m:361 :: Response Header: {
"Content-Language" = "en-US";
"Content-Length" = 0;
Date = "Thu, 02 Apr 2015 01:10:30 GMT";
P3P = "policyref=\"/w3c/p3p.xml\", CP=\"CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE\"";
"X-Powered-By" = "Servlet/3.0";
}
Response Data: 
Status code=201
 2015-04-01 19:09:34.298 El_Universal_Demo[211:9844] [DEBUG] [WL_REQUEST] -[WLRequest requestFinished:] in WLRequest.m:404 :: NSS object is null
2015-04-01 19:09:34.304 El_Universal_Demo[211:9844] [DEBUG] [OCLogger] Analytics data successfully sent to server.

当我怀疑特定标签时,这是我的Xcode控制台中的日志。

2015-04-01 19:25:36.579 El_Universal_Demo[242:14249] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] +[WLAFHTTPClientWrapper requestWithURL:] in WLAFHTTPClientWrapper.m:46 :: Request url is http://198.11.212.196:9080/ElUniversal/apps/services/api/El_Universal_Demo/iOSnative/notifications
2015-04-01 19:25:36.586 El_Universal_Demo[242:14249] [DEBUG] [WL_REQUEST] -[WLRequest sendRequest:path:withOptions:] in WLRequest.m:141 :: Request timeout is 10.000000
2015-04-01 19:25:36.589 El_Universal_Demo[242:14249] [DEBUG] [WL_REQUEST] -[WLRequest sendRequest:path:withOptions:] in WLRequest.m:220 :: Sending request (http://198.11.212.196:9080/ElUniversal/apps/services/api/El_Universal_Demo/iOSnative/notifications) with headers: 
 {
"Accept-Language" = es;
"User-Agent" = "El_Universal_Demo/1 (iPhone; iOS 8.1.2; Scale/2.00)/WLNativeAPI/7.0.0.0";
"X-Requested-With" = XMLHttpRequest;
"x-wl-app-version" = "1.0";
"x-wl-device-id" = "A6042553-8580-4365-A69C-6731388D6A56";
"x-wl-platform-version" = "7.0.0.0";
}
 You can see the request body in the Analytics platform logs.
2015-04-01 19:25:36.596 El_Universal_Demo[242:14249] [DEBUG]  [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper start] in  WLAFHTTPClientWrapper.m:297 :: Starting the request with URL   http://198.11.212.196:9080/ElUniversal/apps/services/api/El_Universal_Demo/iOSnative/notifications
 2015-04-01 19:25:36.601 El_Universal_Demo[242:14249] [DEBUG] [WL_REQUEST] __42-[WLRequest sendRequest:path:withOptions:]_block_invoke in WLRequest.m:230 :: waiting for response... (Thread=<NSThread: 0x170064f00>{number = 1, name = main})
 2015-04-01 19:25:36.876 El_Universal_Demo[242:14249] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper requestFinished:] in WLAFHTTPClientWrapper.m:310 :: Request Success
2015-04-01 19:25:36.881 El_Universal_Demo[242:14249] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper requestFinished:] in WLAFHTTPClientWrapper.m:311 :: Response Status Code : 200
2015-04-01 19:25:36.886 El_Universal_Demo[242:14249] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper requestFinished:] in WLAFHTTPClientWrapper.m:312 :: Response Content : /*-secure-
{"errors":[],"isSuccessful":true,"warnings":[],"info":[]}*/
2015-04-01 19:25:36.893 El_Universal_Demo[242:14249] [DEBUG] [WL_REQUEST] -[WLRequest requestFinished:] in WLRequest.m:361 :: Response Header: {
"Cache-Control" = "no-cache, no-store, must-revalidate";
"Content-Length" = 70;
"Content-Type" = "application/json; charset=UTF-8";
Date = "Thu, 02 Apr 2015 01:26:33 GMT";
Expires = "Thu, 01 Jan 1970 00:00:00 GMT";
P3P = "policyref=\"/w3c/p3p.xml\", CP=\"CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE\"";
Pragma = "no-cache";
"X-Powered-By" = "Servlet/3.0";
}
Response Data: /*-secure-
{"errors":[],"isSuccessful":true,"warnings":[],"info":[]}*/
Status code=200
2015-04-01 19:25:36.897 El_Universal_Demo[242:14249] [DEBUG] [WL_REQUEST] -[WLRequest requestFinished:] in WLRequest.m:404 :: NSS object is null
2015-04-01 19:25:36.899 El_Universal_Demo[242:14249] [DEBUG] [WL_PUSH] -[TagSubscribeRequestDelegate onSuccessWithResponse:userInfo:] in WLPush.m:132 ::    Successfully subscribed to tag tucartera
2015-04-01 19:25:36.904 El_Universal_Demo[242:14249] on Success Status: 0
InvocationResult: (null)
InvocationContext: (null)
Response text: /*-secure-
{"errors":[],"isSuccessful":true,"warnings":[],"info":[]}*/

2 个答案:

答案 0 :(得分:1)

要通过其终端调用适配器,只需向以下网址发出请求:

http(s)://<server>:<port>/<project-name>/adapters/<adapter-name>/<procedure-name>

例如:

http://localhost:10080/MyProject/adapters/MyHttpAdapter/myRssFeed

在上一个示例中,我的MobileFirst服务器在端口localhost的{​​{1}}上运行,我有一个名为10080的项目和一个函数{{1}的适配器MyProject }}

在IBM MobileFirst Platform V7.0中,安全性基于OAuth模型,因此如果适配器受到保护,您将需要一个授权令牌来调用适配器。

仅限开发环境,您可以在以下位置获取测试授权令牌:

MyHttpAdapter

要了解有关调用适配器的更多信息,请访问: http://www-01.ibm.com/support/knowledgecenter/SSHSCD_7.0.0/com.ibm.worklight.dev.doc/devref/c_adapters_endpoint.html?lang=en

要详细了解OAuth测试令牌,请访问: http://www-01.ibm.com/support/knowledgecenter/SSHSCD_7.0.0/com.ibm.worklight.dev.doc/devref/c_oauth_test_token_endpoint.html?lang=en

答案 1 :(得分:0)

我终于找到了问题!

我在服务器中将JDK 6更改为7,因为在调用我的适配器时,服务器日志中出现了错误消息http://###.##.###.###:9080/ElUniversal/adapters/DemoAdapter/sendNotification?params=[%27nacion%27,%27testNacion%27,%27nacion%27]

javax.net.ssl.SSLHandshakeException:
com.ibm.jsse2.util.j: End user tried to act as a CA

这是替换here的链接!

此致