MobileFirst adapter endpoint not visible - ibm-mobilefirst

I have a MobileFirst adapter with multiple GET and POST-methods/endpoints, they are located in the AdapternameResource.java file and they follow the standard of:
#GET
#PATH("/name")
#Produces("application/json")
public Response method()
{
}
They are all visible when i view the adapter in MobileFirst Console.
Now i added a new get method that just returns a hello world-object, however this method is not visible in the MobileFirst Console and i cannot call it.
I added the method to the resource file, do i need to do something more??

As Vivin mentioned, it does sound like you forgot to build and/or deploy the adapter after adding this fifth endpoint.
mfpdev adapter build
mfpdev adapter deploy

Related

IBM MobileFirst Platform - How to Call resource WS (JAX-RS) in navigator?

I'm trying to make a simple example of a connection to a WS (JAX-RS), when I call from the browser, I should return a string but I get the following error message:
missing_authorization, this is the URL to access the resource (REST):
http://localhost:10080/PruebaWSProject/adapters/MyAdapter/users/pramirez
When I test it directly from MobileFirst Studio using "Call MobileFirst Adapter", it works perfectly.
It seems to be a problem with HTTP authentication, apparently I have to set something in the XML file server: authenticationConfig.xml, but I do not know what I have to put and I read the following in a web:
Disabling the authentication requirement for a specific procedure.
You can do so by adding the securityTest="wl_unprotected" property to the element in the adapter XML file.
I do not know how to turn off the security to call the resource to obtain the chain. The name of the classes generated by the Java adapter are: MyAdapterResource and MyAdapterApplication.
Java Adapters are protected by default.
When you use "Call MobileFirst Adapter", a test token is automatically added to help you preview.
If you want to test your adapter outside of the wizard, you have 2 main options:
Disable security by adding #OAuthSecurity(enabled=false) before your procedure code (in MyAdapterResource). Keep in mind that your procedure will no longer be protected. See Protecting Adapters.
Generate a test token manually. You can request a test token which you will add to your HTTP headers. See In Postman
The instructions you saw regarding securityTest="wl_unprotected" are for JavaScript adapters, not Java.

How do I capture the Worklight defaultOptions:onFailure event?

I have a Worklight 6.1.0.1 hybrid app that I'm running on iOS. The app uses adapter-based authentication. The app prepares the invocation data makes the following call when the Login button is clicked:
singleStepAuthRealmChallengeHandler.submitAdapterAuthentication(invocationData, {});
If the WL service is down, or if the mobile device has no network access, the invocation will timeout. I see the following in the Xcode console:
defaultOptions:onFailure Request timed out for http://myipaddress:10080/myapp/apps/services/../../invoke. Make sure the host address is available to the application (especially relevant for Android and iPhone apps).
How can I capture this timeout event, so that I can update the UI with a proper message?
Update May 23rd based on comments:
What is your exact flow?
You should first use WL.Client.connect({onSuccess: ..., onFailure:...});
If connection to the server is successful, you will enter the challenge handler. Otherwise, you will enter onFailure and there you can create the custom error handling.
Previous answer attempt:
The below is when trying to connect() to the Worklight Server.
If you want custom handling for when the client fails connecting to the server I believe you need to enable and use the option onConnectionFailure in initOptions.js:
var wlInitOptions =
// # The callback function to invoke in case application fails to connect to Worklight Server
//onConnectionFailure: function (){},
}
Otherwise, Worklight's default dialog will be displayed.

integration test of IBM worklight adapters with security test

I'm developing a POC for integration testing of IBM worklight adapters. In doing so I'm using RESTAssured framework. I have an adapter having security test applied to it.
XML Snippet:
<procedure name="getCatalog"
securityTest="SingleStepAuthAdapter-securityTest" />
For authentication I have another adapter:
<procedure name="submitAuthentication" />
In my test I'm calling SubmitAuthentication adapter and then I'm calling getCatalog adapter. This is returning me following error response:
Runtime: The resource 'proc:SampleHttpAdapter.getCatalog' should only
be accessed when authenticated in realm 'SingleStepAuthRealm'.
Below is the test case i'm executing:
public void testGetCatalog() {
Response response = RestAssured.given().get(BASE_URL.concat("SampleHttpAdapter&
procedure=submitAuthentication&parameters=[\"worklight\",\"worklight\"]"));
String sessionid = response.getSessionId();
Cookie cookie1 = new Cookie.Builder("JSESSIONID", sessionid).build();
System.out.println("cookie value" + cookie1.getValue());
RequestSpecification spec_two = new RequestSpecBuilder().addCookie(cookie1)
.setSessionId(sessionid).build();
Response catalog_response = RestAssured.given()
.spec(spec_two)
.get(BASE_URL.concat("SampleHttpAdapter&procedure=getCatalog&parameters=[]"));
String catalog_json = catalog_response.asString();
System.out.println(catalog_json);
}
As per the response it seems like the authentication is not persisting in my request of getCatalog. How can i do so ?
Without knowing how your adapter procedures are written it is difficult to investigate the issue above. Can you please include the adapter procedures of submitAuthentication as well as getCatalog?
I can include to you a sample and tutorial Worklight proivides on adapter based authentication that will describe in great detail how the authentication process works. You can even use this project as a basis, since it accomplishes single step adapter authentication. Use the mechanisms it provides with authentication and add in your getCatalog method for testing.
Adapter Based Authentication Presentation:
http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/08_03_Adapter_based_authentication.pdf
Adapter Based Authentication Project:
http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/AdapterBasedAuthenticationProject.zip

Can no longer access the list of API descriptors after installing Glimpse

We would like to use Glimpse in our ASP.net MVC project but are running into a problem when accessing the list of Web API descriptors.
We have installed Glimpse.Mvc4 1.2.2 using the Nuget Package Manager.
The following snippet gets all API descriptors and it works fine before we install Glimpse. After installing we do only get an empty list.
IEnumerable<ApiDescription> apiDescriptors = System.Web.Http.GlobalConfiguration
.Configuration
.Services
.GetApiExplorer()
.ApiDescriptions
Does anyone know why this call does not work when Glimpse is installed?
The problem is that the Glimpse ASP.NET module wraps all routes in its own objects. So API Explorer ignores them (thinks that they are not Web API routes).
To work around this issue, you must initialize a fresh copy of System.Web.Http.HttpConfiguration instead of using GlobalConfiguration.Configuration.
// need to create a custom configuration instance because the default one can be
// processed by Glimpse and be thus full of wrapped routesthat the ApiExplorer
// does not recognize.
var config = new System.Web.Http.HttpConfiguration();
WebApiConfig.Register(config);
// these line is useful if you use WebAPI Help page package
HelpPageConfig.Register(config);
Controllers.HelpController.Configuration = config;
// otherwise just get the `IApiExplorer` interface from the fresh configuration:
var apis = config.Services.GetApiExplorer().ApiDescriptions;

Consuming web service from console app

We have a web app that contains web methods. I want to invoke one of those methods from a console app. I am new at this but I wrote a console app, added a service reference and tried to code invoking it.
If my web method is called "Transmit", I expected to see Transmit in the namespace I specified but instead I see "TransmitRequest", "TranmsitRequestBody", "TransmitResponse" and "TransmitResponseBody".
What are these things?
Have I done something wrong?
How do I invoke the web method in the web app from the console app?
Thank you for all help to this newbie. I am using VB.net 2008.
If you expand the ServiceReference Folder in solutionExplorer, double click on your service and it should open the object explorer. Now you will see the class (the one without the I infront). In your code you will then instantiate a new variable with the [ServiceReferenceName].[ClassName] i.e.
Dim svc as new ServiceReference1.MyWebService();
svc.Transmit();