Hi I may be missing some concepts with WSO2 DSS REST resources.
How can I create a resource that supports CRUD operations (same resource name but different verbs)?
For example, if I have DSS resource '/services/samples/RDBMSSample/employees' I would like to be able to make GET, POST, PUT, DELETE to 'employees' resource, but DSS doesn't allow me to do it - it replaces the resource with whatever the last one is defined.
When using JSON to make post to a resource it requires to wrap data in element with the name of operation
'{"employeesbynumber":{"employeenumber":{"$":"1002"}}}'
I suspect that it is because you are doing internal mapping to SOAP in DSS. Is there a way around it?
What is the correct way to use endpoint. In TryIt tool there are several available endpoint for SOAP1.1, SOAP1.2. HttpEndpoint. As well as there is endpoint without suffix. What is the right approach to reference them from clients?
Thank you!
You can refer http://docs.wso2.org/display/DSS310/Exposing+Data+as+REST-Style+Resources to achieve the REST CRUD operations on your data.
Also you can try out your endpoint in any of the available endpoints in the tryit tool.
Thanks
Manisha
Related
I want to create a microservice for "orders". The service will have typical actions like "get orders" or "create an order".
I would like to expose this service in two ways:
User frontend: If you call /orders, you will see your orders
Support frontend: if you call /orders, you will see all the orders of all the users
I would like to deploy one API (orders) that can be called from 2 API gateways (user and support). But, I don't know how to do it without duplicating code.
Is this the right approach?
I'm using AWS Apigateway + Lambda + Serverless.
In some way you're being able to differentiate the user that is making the request inside your lambda function, because you need to get only its orders. Based on that I'm considering that you're receiving some kind of token in your lambda where you can extract the correct user.
Considering that scenario, one standard solution to your problem is add something to your token that differentiate if the user is from the support group or not. Normally you add a claim to the token informing that he/she is part of the support group. Then inside your lambda you check this token and give a different answer based on your requirements. But for that solution, you'll need to have means to add new claims/manage your identity provider data (user information inside your service that provides user tokens).
But with that solution you will find a small problem: if a support user must get all the orders and in another moment only its orders you won't find an easy way to implement this. If your requirements demand that you provide both use cases for support users you will need another solution.
In that case another solution would be to provide two different endpoints (API Gateway API's) touching the same backend lambda. In the normal endpoint you forward the request to the backend and the lambda gets all the orders for the user. In the support endpoint you add something else to the request (can be a query parameter or a http header).
For a more secure solution, your support endpoint must not allow requests from people outside the support group. And if you go for a query parameter alternative, you must block this exact query param in the normal endpoint. Someone can abuse the normal api sending the query param for it and get all the orders if you just forward the query params downstream.
You will do all this different configuration in the integration request of AWS API Gateway. You can find how it works here.
I need to manage a Registry Resource deployed into the Enterprise Integrator.
Using the REST API like this:
https://localhost:9443/registry/resource/_system/governance/EstrattoContoEnti/xml/EstrattoContoEntiConf.xml
I can GET the resource, but...how can I modify this or create a new one?
Calling a PUT o POST I get Error 405 - Method Not Allowed.
Is there any API to manage the registry entries on the WSO2 EI?
Or may I need to use something else?
This is not possible out of the box via a REST API.
There is a AdminService for Registry and you may access that AdminService and get the related functionality via SOAP.
But in your case, since you are expecting a REST API, you can create a web-app client which will use this Admin-service, so that you have a REST API to the registry via this client.
There is already such a client written. Have a look at the steps on how to get this and configured from the following blog.
http://abeykoon.blogspot.com/2015/04/wso2-gov-registry-using-registry-api.html
Cheers.
How to redirect an API Call received by WSO2 API Manager to another API also running in the same server?
Maybe I do not understand well your problem.
Why not, simply, in the new API declare the endpoints pointing old one?
If you want a more performant solution, create a custom sequence in the new one, with a call to the old.
As #Sourcerer has mentioned you can add mediation extension using custom mediation sequences. Have a look at https://docs.wso2.com/display/AM220/Adding+Mediation+Extensions
How to chain multiple APIs on the same URL using Azure API management?
I have two APIs the user store and that user recources api.
I want to build rest api so resources will related to user.
Mycompany/users/dani#gmail.com/resources.
User store api is mycompany/users
Resources api is mycompany/resources.
I dont want to build additional service that will consolidate this two apis.
Thanks
Additionally you can use 'send-request' policy, that will call another API endpoint and store the result in declared variable. This is what worked for me.
In my case I had hit another URL after getting response of first APIs. Same can be done in inbound policy also before getting response and similarly you can hit multiple APIs.
Policy snippet.
You can create a single API in API Management that points to multiple different backendĀ APIs. Use the set-backend-service policy to change the backendĀ API for certain operations.
I followed steps provided in this https://www.c-sharpcorner.com/blogs/api-aggregation-using-azure-apim link and able to combine two API responses within one API call.
It tells how to aggregate or chain more than one API responses in API management
Can I add multiple endpoints to 1 API in WSO2 Api Manager?
As far as I know I have to create a context and a version. The background is that I just want to make a request like https://api.manager.com/rest/1.0/userList or https://api.manager.com/rest/1.0/tasks.
The userList REST-Controller is implemented on backend A and tasks REST-Controller is implemented in backend B. (A and B are separate web applications)
As far as I know I have to create in my API Manager two APIs with different context values.
The API Manager application would simply subscribe both APIs.
But this would mean that I have to change my requests on the javascript side. This is in my opinion not good because I dont want my javascript application to care about the context. I want that the API Manager delegates to the correct backend automatically. Is this possible? What is best practise?
You can have multiple endpoints per API using Dynamic Endpoint Feature. When creating the API you need to set the Endpoint Type as "Dynamic Endpoint" and upload a mediation in-sequence that sets the "To" header. Within the sequence you can specify your logic to route to the correct endpoint (setting the correct "To" header) according to the request path. Please read [1] for more information.
[1] http://blog.lakmali.com/2016/08/dynamic-endpoints-in-wso2-api-manager.html