How to invoke Java adapter from HTTP adapter?

980 views Asked by At

Is there any API to invoke a Java adapter from a HTTP adapter in IBM MobileFirst Platform Foundation 7.0?

I have tried with WL.Server.invokeHttp(input), but received a 404 response. What should be the value for 'path' in the input?

1

There are 1 answers

2
Idan Adar On

It is currently not possible to directly call a Java adapter from a JavaScript adapter.
You are encouraged to submit a feature request: https://developer.ibm.com/mobilefirstplatform/help

Alternatives:

  1. Implement a JavaScript adapter that invokes Java code. See the tutorial Using Java in JavaScript adapters
  2. Use another JavaScript adater - set the Java adapter as the backend it connects to and call it from the requesting JavaScript adapter

    Rough steps to follow:

    • You have JavaScript adapter A
    • This adapter calls a procedure in another JavaScript adapter, adapter B (adapter mashup)
    • JavaScript adapter B will set in its XML the Java adapter properties as the backend (localhost, MFP server port)
    • Requests from this adapter should then be sent to /the-server-context-root/adapters/the-java-adapter/*
    • The Java adapter should have its security disabled, otherwise an access token would need to be forwarded in an header from the client in the request

As you can see the second option is less trivial to implement, and is less supported. I would investigate option 1...