Custom Connector - OData Queries - Make them pretty? - azure-logic-apps

I'm trying to write a custom connector Swagger file for Logic Apps and am having problems. The API I want to connect to only accepts OData queries so all my parameters are asking for $filter and the user has to type in Name eq 'Name' and Id eq 1. Is there a way to make this prettier and just ask them for the parameters directly?
I tried just adding them in (Name, Id, Active) but it puts them in the url like ?Name=. Not in the OData syntax. Is there any way to do what I want to do?

The custom connectors are designed to work as interfaces to existing REST APIs and the UI is more of a 1-1 mapping of their specification.
AFAIK, there is no way to direct customize how the connectors work but you could achieve it by proxy request through your own service.
You simply need a service which accepts requests the way you want and translate them accordingly for the actual service.
Azure API Management is probably the best candidate for this. As a bonus, once you have the APIs you need designed, you get an OpenAPI spec that you could use for the custom connector.
Depending on your expected load, you might have to use its Consumption Tier but do note that its currently in preview.
The alternatives could be having your own API hosted on Azure App Service or Azure Functions instead (or even Functions Proxies), again depending on your expected load.
PS: The downside of doing this is the obvious maintenance that you would have to uptake in case your requirements change and/or the backend API changes.

Related

API Management - Single API for multiple Logic Apps

I have 5+ separate logic Apps that are called via HTTP Receive. Examples are:
GetUsers
GetLocations
GetCalls
etc.
I would like to expose the Logic Apps via API Management as individual operations on one API. Any samples online to show I can do that? Am I right to assume that I'll need a policy (url-rewrite, control flow)?
Any guidance appreciated.
You can add Logic Apps as operations on an existing API by:
Creating a new operation (by default http post for a Logic App)
Defining the request/response that your Logic App will expect you to pass to it
Go to the 'backend' element in the designer and select the 'forms based editor' from the designer.
In the editor, select 'Azure resource' and then browse to the Logic App you wish to use - the is should be an http request/response based Logic App.
Add other Operations and connect them up for each Logic App you want to use.

Where to find the OSB Business service configuration details in the underlying database?

In OSB Layer when the endpoint uri is changed, I need to alert the core group that the endpoint has changed and to review it. I tried SLA Alert rules but it does not have options for it. My question is, the endpoint uri should be saved somewhere in the underlying database. If so what is the schema and the table name to query it.
URI or in fact any other part of OSB artifact is not stored in relational database but rather kept in memory in it's original XML structure. It can be only accessed thru dedicated session management API. Interfaces you will need to use are part o com.bea.wli.sb.management.configuration and com.bea.wli.sb.management.query packages. Unfortunately it is not as straightforward as it sounds, in short, to extract URI information you will need to:
Create session instance(SessionManagementMBean)
Obtain ALSBConfigurationMBean instance that operates on SessionManagementMBean
Create Query object instance(BusinessServiceQuery) an run it on ALSBConfigurationMBean to get ref object to osb artifact of your interest
Invoke getServiceDefinition on your ref object to get XML service
definition
Extract URI from XML service definition with XPath
Downside of this approach is that you are basically pooling configuration each time you want to check if anything has changed.
More information including JAVA/WLST examples can be found in Oracle Fusion Middleware Java API Reference for Oracle Service Bus
There is also a good blog post describing OSB customization with WLST ALSB/OSB customization using WLST
The information about services and all its properties can be obtained via Java API. The API documentation contains sample code, so you can get it up and running quite quickly, see the Querying resources paragraph when following the given link.
We use the API to read the service (both proxy and business) configuration and for simple management.
As long as you only read the properties you do not need to handle management sessions. Once you change the values, you need to start a session and activate it once you are done -- a very similar approach to Service bus console.

MYOB api for custom data addition

I want to know if there is an api for java to integrate the data from the site into the myob database like inventory of a customer
The answer depends on which "MYOB database" you are referring to.
"v19" product range: use a JDBC-ODBC bridge.
"EXO": you can use JDBC SQL-Server driver, or use the REST API documented here.
"AccountRight Live" (desktop or cloud): use the REST API documented here.
"Essentials": use the REST API documented here.
"Advanced": use the REST API documented here.
Note that solutions involving JDBC drivers typically require that your site be deployed on the same network as the target company file. If not, you will need an intermediate stage to synchronise or post data.

Mobile application backend

I'm currently developing a mobile application that will fetch data from server by request (page load) or by notification received (e.g. GCM).
Currently I'm starting to think about how to build the backend for that app.
I thought about using PHP to handle the http requests to my database (mySQL) and to return the response as JSON. As I see it there are many ways to implement such server and would like to hear to hear thoughts about my ideas for implementations:
1. create a single php page that will receive an Enum/Query, execute and send the results.
2. create a php page for every query needs to be made.
Which of my implementations should I use? if none please suggest another. Thank you.
P.S, this server will only use as a fetcher for SQL and push notifications. if you have any suggestion past experience about how to perform it (framework, language, anything that comes to mind) I'd be happy to learn.
You can use PHP REST Data services framework https://github.com/chaturadilan/PHP-Data-Services
I am also looking for information about how to power a web and mobile application that has to get and save data on the server.
I've been working with a PHP framework such as Yii Framework, and I know that this framework, and others, have the possibility to create a API/Web service.
APIS can be SOAP or REST, you should read about the differences of both to see wich is best for mobile. I think the main and most important one is that for SOAP, you need a Soap Client library on the device you are trying to connect, but for REST you just make a http request to the url.
I have built a SOAP API with Yii, is quite easy, and I have use it to communicate between two websites, to get and put data in the same database.
As for your question regarding to use one file or multiple files for every request, in the case of SOAP built on Yii, you have to normally define all the functions available to the API on the server side in only one file(controller) and to connect to that webservice you end up doing:
$client=new SoapClient("url/of/webservice);
$result=$client->methodName($param1, $param2, etc..);
So basically what you get is that from your client, you can run any method defined on the server side with the parameters that you wish.
Assuming that you use to work program php in the "classic way" I suggest you should start learning a framework, there are many reasons to do it but in the end, it is because the code will result more clean and stable, for example:
You shouldn't be writing manual queries (sometimes yes), but you can use the framework's models to handle data validation and storage into the database.
Here are some links:
http://www.larryullman.com/series/learning-the-yii-framework/
http://www.yiiframework.com/doc/guide/1.1/en/topics.webservice
http://www.yiiframework.com/wiki/175/how-to-create-a-rest-api/
As I said, I am also looking to learn how to better power a mobile application, I know this can be achieved with a API, but I don't know if that is the only way.
create a single php page that will receive an Enum/Query, execute and send the results.
I created a single PHP file named api.php that does exactly this, the project is named PHP-CRUD-API. It is quite popular.
It should take care of the boring part of the job and provides a sort of a framework to get started.
Talking about frameworks: you can integrate the script in Laravel, Symfony or SlimPHP to name a few.

UTF-8 For Restful Services

Currently i enable UTF-8 as #Consumes("application/xml;charset=utf-8") in the RESTful Services for the different methods. I am interested to see if we can change this for all REST services with a single configuration change. We are using CXF, maybe there is something it provides?
Thanks
Ravi
The first question is are you sure you want to prevent any of your rest resources from accepting non-UTF-8 entities? Such an across the board proclamation feels like it could cause trouble down the road.
I'll admit that I haven't used CXF so I can't speak to those specifics. But I can think of one option each under the JAX-RS and Servlet APIs which might be along the lines of what you seek to accomplish.
Using the Servlet API: Depending on how you are deploying your application you might be able to create and inject a servlet filter. In the doFilter method, you can check the encoding of the request entity and continue on to the next part of the filter chain (ultimately to the rest application). If an improper entity is sent on the request, you would just set the appropriate HTTP 415 status onto the response and not invoke your rest application.
Using JAX-RS: Depending on how you parse/accept the entity body in your resources, you could create and inject a custom MessageBodyReader implementation. This reader could parse your entity, ensuring that it is UTF-8 only and throw an appropriate exception otherwise.

Resources