How to invoke the url or link of an adapter

2019-09-11 05:01发布

问题:

I need know how to invoke the adapter from the development server in the cloud. In the local environment we have the option in eclipse but in the development server in the cloud, I can´t see the option for invoking.

I use MobileFirst 7.0


Update - The notification based in tags does not arrive to my device.

The problem is that in the console the notification is success, but these never arrive to my device. This is the message in my log.

[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]

In my nativeApp the connection to the server is correct and this is a part of the Output:

 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.

When I suscribe to specific tag, this is the log in my console of 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":[]}*/

回答1:

To invoke the adapter through their endpoint simply make a request to the following url:

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

For example:

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

In the previous example, my MobileFirst server is running on localhost at port 10080, I have a project called MyProject and adapter MyHttpAdapter with a function myRssFeed

In IBM MobileFirst Platform V7.0 security is based on the OAuth model so you are going to need an authorization token to invoke adapters if they are protected.

For DEVELOPMENT ENVIRONMENT ONLY you can get a test authorization token at:

http(s)://<server>:<port>/<project-name>/authorization/v1/testtoken

To learn more about invoking adapters visit: http://www-01.ibm.com/support/knowledgecenter/SSHSCD_7.0.0/com.ibm.worklight.dev.doc/devref/c_adapters_endpoint.html?lang=en

To learn more about the OAuth test token visit: 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



回答2:

I found the problem, finally!

I had that change the JDK 6 to 7 in the server because in the log of server appeared a Error Message when I invoked my adapter 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

And this is the link for replace here!

Regards