How to invoke MobileFirst adapters with curl and SOAP? - ibm-mobilefirst

Good day,
We have the requirement to call a MobileFirst Adapter via curl and SOAP, ommiting authentication.
An example how to do it with curl and application/x-www-form-urlencoded looks like this, but we also require to invoke the adapter using SOAP.
curl -XPOST -d 'adapter=PushAdapter&procedure=sendNotifications&parameters=["[\"UserA\",\"UserB\"]", "Pushed.you"]' http://localhost:10080/application/invoke
The reason is, we want to trigger sending PushNotifications through a network zone that only allows SOAP.
We are open to different suggestions, like implementing a new JavaAdapter (not JS), implementing an extra WebService, or anything that pops up which could fulfil the requirement in an acceptable way.
I hope someone can come up with an idea how to call Adapters via SOAP, ommiting authentication.
Thank you,
gizmore
---- Edit ---
I added a new Java Adapter, like the video from Hasan suggests.
Thank you very much for that hint :)
There i added a WebService like this:
#WebService
#Path("/soap")
#OAuthSecurity(enabled=false) // Disable the imfAuthentication :)
public class ExternalPushService {
#POST
#Path("/push")
#WebMethod(action="push")
public String push(#WebParam(name="name") String name) {
return name + "ABC";
}
}
I can now do HTTP POST Requests to the http://localhost:10080/app/adapters/PushBridge/soap/push Endpoint, but the SOAP is not parsed.
Instead i get the complete Envelope in the "name" parameter.
If i do a SOAP call to PushBridge/soap, i get 405 Method not allowed.
Does someone have an idea, how i can get SOAP working out of the box there?

Answer is: NO
when you adding #WebService in your java adapter this the warring facing:
Problem description:This annotation requires a web service project. Convert the Java project to a web project targeting the specified runtime environment
SOAP base service are based on the JAX-WS specification.
but
Java adapters are based on the JAX-RS specification.
https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-0/server-side-development/java-adapter/

Related

Request not hitting spring boot embeded server through tomcat and browser

Am trying to hit my rest API in spring boot with the embeded server configured through browser and postman, but the request doesn't hit the server and am getting 404-not found am pretty new to springboot , please help me in this as in what to check further so that i can test my rest API
This could be due to couple of reasons
Try the following
Ensure the port you are specifying is correct
Ensure the end point you are specifying exist
Ensure the request you are sending is of correct REST action type (GET,POST etc)
Ensure your controller class is available in the same package in which Application class (with #SpringBootAnnotation) exists, else you will have to use #ComponentScan to make sure your controller class is scanned and endpoints available to receive traffic
Most likely, above should help :) If not, you'll need to describe what is done in the application so far

Dynamically controlled swagger / openapi mock server for testing purposes

I'm looking for a project/tool that is able to get swagger / openapi specifications file as a parameter and generate a mock server that can be controlled programmatically via a REST API interface.
For example - if my API contains the following endpoint: "POST /v1/create"
and I have a swagger specs that describe that API, I would like my mock server to be executed in a way similar to:
mock-server -f swagger.yaml -p 8080
While the server runs, It will be possible to interact with it's own REST API (on some control interface via a different port) and change the behavior of the running swagger mock server - i.e: change response code, set response content etc'
I would like to use such mock-server as part of my system-tests suite to better verify my service behavior when interacting with other services - without the need to run those 'real' services.
I'm looking for something similar in spirit to Shopyify's ToxiProxy (https://github.com/Shopify/toxiproxy) but with the above capabilities.
Thanks!
Eldad
I know I'm a bit late to the party on this one, but for future searchers, MockLab now supports auto-generation of mock APIs from an imported Swagger definition and Swaggerhub webhooks.
More details here:
https://www.mocklab.io/blog/mocklab-now-supports-swagger-and-swaggerhub/
I believe Specmatic should help you with this.
mock-server -f swagger.yaml -p 8080
Specmatic works exactly this way. To start a mock server with an OpenAPI specification file we can run below command.
specmatic stub service.yaml --port 8080
Here is the documentation.
While the server runs, It will be possible to interact with it's own REST API (on some control interface via a different port) and change the behaviour of the running swagger mock server - i.e: change response code, set response content etc'
This is also supported. Specmatic has a http interface to which you can post the request and response mappings / expectations. We call this dynamic mocks. Here is the documentation.
Here is a video on this.
Disclosure: I am lead dev and CTO at Specmatic

ONOS Rest API Configuration

I am working on ONOS Virtual Box instance version 3.0.3. I am unable to configure the Swagger auto generated API documentation using the standard uri http://>/v1/docs. I have been able to install POSTER extension and can do GET / HEADER method call using the REST API but getting an 405 method not allowed on PUT/ DELETE. Can anyone please help me enable DELETE/PUT methods in the ONOS instance.
ONOS supports those methods. if you get any faults it might be your client's fault.
besides you get 4xx http error and these kind of errors show that the problem is in the client side.
watch this picture:
enter image description here

Invoking wso2greg Artifcat Rest API via wso2api manager is not working - any ideas to fix

UPDATED QUESTION to clarify more.
I have two servers : wso2greg containing custom artefacts and wso2am (api manager).
The gouvernance register is intended to be used internally (intranet) and some of it's feature are intended to be exposed externally and acceded via it's rest API.
In order to manage wso2greg API accesss, we used an wso2am (api manager) server, where we did define an API that act as a proxy for the wso2greg API.
In our experiments, we found the strange behaviour described below :
Successfully direct calling wso2greg artefact rest api (the exact url is
https://localhost:9443/resource/1.0.0/artifact/_system/governance/myartifact/art1 and i'm following the documentation of this REST API from here https://docs.wso2.com/display/Governance520/Resources+with+REST+API ) using postman. The API reacts as described in the documentation.
Error 500, reported on wso2greg server, when calling the same REST API, but via API manager (using publisher application).
So as a summary :
Directly calling wso2greg rest API woks fine and a got results back
Adding this working API, in wso2am and than calling it gives always error 500.
As extra information:
Tested with other wso2greg REST API , such as "rating" or "comments" and I was able to call it successfully either directly or throw Api manager.
Tried to get information related to default wso2greg artifacts such as restservice, but i got exactly the same pb when (error 500) interagting with API manager.
Working with the last version of both products : wso2greg version 5.2.0 and wso2am version 1.10.0
Please advice, or clarify how could i debug this internal error in wso2greg.
Regards,
I hope your not using G-Reg + APIM feature installed version. I presume your using separate G-reg 5.2.0 and APIM x.x.x. Since your using the second option you can't use G-Reg REST API with APIM, therefore you have to use APIM REST API instead.
Get an API
Description: Get details of a specific API.
URI: http://localhost:9763/publisher/site/blocks/listing/ajax/item-list.jag
URI Parameters: action=getAPI&name=xxx&version=xxx&provider=xxx
HTTP Methods: POST
Example:
curl -X POST -b cookies http://localhost:9763/publisher/site/blocks/listing/ajax/item-list.jag -d "action=getAPI&name=PhoneVerification&version=1.0.0&provider=admin"
Please follow this link to see all the api usage.
Thanks #thusharaK for providing help.
The solution was to add Message Mediation Policies which forces json header on output.
Now i got my correct response from API manager (in fact, i got a binary response in test console and a json response in postman) .

WSO2 API Manager is not responding to a request that returns zip file (application/octet-stream)

Using WSO2 API Manager 1.3.1. Trying to use the API Manager to proxy to a REST service. I have set up the service in API Mgr and can successfully post and get responses, typically json, though some are text.
However, when I try to GET a resource that returns binary content (a zip "file", content-type:application/octet-stream), the API Manager does not seem to respond and I can see an error in the console window (i'm running wso2server.bat in console):
[2013-07-03 11:52:05,048] WARN - SourceHandler Connection time out
while writing the response: 173.21.1.22:1268->173.21.1.22:8280
I have an HTTPModule on my internal service and it seems to be responding with the appropriate content (I can see the GET and response data logged). I can also call to the internal service directly and get a response, so that end of things seems OK. But going through the API Manager seems to fail.
I found information on enabling other content-types:
WSO2 API Manager - Publishing API with non-XML response
http://wso2.com/library/articles/binary-relay-efficient-way-pass-both-xml-non-xml-content-through-apache-synapse
Using that information I tried to enable the application/octet-stream for messageFormatter and messageBuilder using the binary relay and it did not help (or seem to make a difference). I have even disabled all other content-types and use the binary relay for all content-types and it does not help.
Currently, I'm running with just the following in both axis2.xml and axis2_client.xml (in their appropriate sections):
<messageBuilder contentType=".*" class="org.wso2.carbon.relay.BinaryRelayBuilder"/
<messageFormatter contentType=".*" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>
I still get my json and text responses, but WSO2 times out getting the zip content. I saw the JIRA referenced in axis2.xml about enabling the ".*" relay, but as the other requests seem to work, I'm not sure it's an issue for me. I did try adding
'format="rest"' to the API definition, but it seemed to break all operations even the ones that worked prior so I've pulled it back out.
Any ideas on what is happening or how to dig in and debug this will help. Thanks!
After working with this for much too long, it turns out that my WSO2 configuration was correct, using the Message Relay and BinaryRelayBuilder, etc. While my REST service could reply immediately, I was setting a HTTP header that I assume WSO2 does not like, because when i removed it WSO2 would reply at an expected rate (instantly).
I was setting the header:
Transfer-Encoding: binary
When I removed that header from my service reply, then WSO2 operated as expected. I don't know if that's a "bug" in WSO2 or if I was implementing incorrectly, but I do have what seems like a "workaround" by omitting that header from my service response.