Handle Path Parameters from API call in WSO2 EI/ESB Integration Studio - wso2

I'm developing an API using WSO2 Integration Studio ESB Solution Project.
I'm calling this API from postman like "https://localhost:port/context/3542" where '3542' is the value of the path parameter being sent (let's say employeeId).
Further, I want to use this value (3542) in the http endpoint implemented in the same API to make a back-end call.
I'm not able to handle that path parameter. I tried using property mediator, didn't work.
Didn't find anything in the official documentation either.
Help appreciated. Thanks already.

You can use REST_URL_POSTFIX property in order to use the value in the implementation. An example code segment is given below.
<property expression="$axis2:REST_URL_POSTFIX" name="Path"/>

Related

Does WSO2 change my WSDL file?

i've just installed the WSo2 service bus to make my own Service Oriented Architecture (SOA).
I'm trying to connect a Ignition (MES/SCADA) system, to a webservice on another (embedded)computer.
I've made the service in the management console, when i use the tryit function, i can fill in the form, but when i send the message i get the following error:
"The endpoint reference (EPR) for the Operation not found is /services/CalculatorWS.CalculatorWSHttpSoap12Endpoint and the WSA Action = null. If this EPR was previously reachable, please contact the server administrator."
When i try to do the same within my Ignition program, i get the following error: unknown url type:"calculatorws"?xsd=http.
I think this has to do with the SOAP message, because i compared the one from my webservice, with the one WSO2 generated.
WSO2 missgenerates the following line within the WSDL:
schemaLocation="CalculatorWS?xsd=http://169.254.166.123:8080/CalculatorApp/CalculatorWSService?xsd=1"
i think this should be:
schemaLocation="http://169.254.166.123:8080/CalculatorApp/CalculatorWSService?xsd=1"
is this the right conclusion? if yes, how can i adjust it?
besides this, when i use the SOAP Messagetracer from WSO2, i do get the answer i want back! how is this possible?
I'd like to hear from you,
Thanks in advance,
T Dantuma
According to your configuration, it looks like you are going to implement WSDL-based proxy. Then you no need to give published WSDL URL. Try to remove above line from proxy as you mentioned:
<xsd:import namespace="http://calculator.me.org/" schemaLocation="CalculatorWS?xsd=http://169.254.166.123:8080/CalculatorApp/Calcu‌​latorWSService?xsd=1"/>
ESB will be adding xsd with relevant namespace
when you define external namespace for given property
you adding external namespace for service within your service and ESB cannot identify your component. Then it will be use given namespace to solve confusions.
Try above methods. If you cannot identify exact error, please add whole configuration in your question (Edit and put the configuration).
If you still get the error:
Please log in to WSDL and check whether it can be accessible
http://169.254.166.123:8080/CalculatorApp/CalculatorWSService?wsdl
Check your invocation method. Becuase "POST" or "GET" request may need special invocations. (Ex: any parameters required for invocation or correct URL may different with exact method)
[1] https://docs.wso2.com/display/ESB490/WSDL+Based+Proxy+Template

URI templates in WSO2 API Publisher

Is it possible to register endpoints with URI templates in the API Publisher that ships with WSO2 API Manager version 1.4.0? For example, I would like to register an endpoint such as:
/jobs/{jobid}/pems
After saving an API, I can see this bit in the API config file:
<resource methods="GET" url-mapping="/jobs/{jobid}/pems">
I have tried manually changing the XML file from url-mapping to uri-template, i.e., to:
<resource methods="GET" uri-template="/jobs/{jobid}/pems">
but I still get "No matching resource found in the API for the given request". In any case, this is not a good work around since we need developers to be able to register these endpoints from the publisher application. Whenever changes are saved to an API from within the API Publisher interface, 'uri-template' gets reverted back to 'url-mapping'.
Thanks in advance.
This is due to APIPublisher app only supports URL-Mappings when defining API resources.
If you want to define a uri-template ,instead of a url-mapping,you can achieve this from changing the api xml manually.
But before that make sure,when creating the API,you have define the API with a valid url-mapping.So in your trying API,first please edit the API from APIPublisher as keeping a valid url-mapping pattern for API resources and then change its xml to match with your mentioned uri-template pattern.
Thanks;
we don't currently support uri-template patterns. We support only url-mappings.
Even , if you edit the backend API configuration (that is, api configuration file ) to url-mappings, it wont work, because we validate request before the request get hits the mediation engine.
You can use ESB RESTApi as your backend service endpoint.That is, define the RESTAPI in wso2esb, with uri-templates(it is supported out of the in ESB) and point that API as the service endpoint from wso2APIManager with url-mappings pattern.
I would like to add some more points.As I mentioned earlier,WSO2 APIManager supports uri-templates.Only api-publisher app UI is not allowing to add uri-templates.
When creating the API from the Publisher UI, you have to give the resource mapping as /* or valid url-mapping. Then when the synapse api is created, you have to change that xml file to uri-template and then change the /* to the uri-template pattern.
Hope above will help you to resolve your issue.
Thanks;

WSO2-ESB: SOAP Mediator from wsdl

I have seen some of the SOAP- Example- Mediators. I have not found a transformation based on the endpoint-WSDL.
I want to send some nested named array in json or POX and that data should go into a complete namespaced headered (username, password) SOAP-Request based on the names.
All the examples I have found had either a very simple wsdl or the namespaces were static in the XSL-Transformation.
It should be possible to do that, as I see in for example php-NuSOAP. You feed it with a wsdl-endpoint, the operation you want to execute and the parameter-array, and it calls the Webservice.
I am looking for a solution which is not too much hardcoded for every single service, so the proxy still works when the wsdl changes and Server Clients get changed.
As far as I understand the payload factory mediator in (https://stackoverflow.com/a/12969814/2277620) you would have to hardcode the soap-format in the mediator.
If WSO2 is the wrong tool for that I'd like to have a hint which tool could help.
Thanks in advance!
Marco.
For my understanding, you want to have a proxy, but it's backend service/wsdl may vary..
What , you can do is, you can save the wsdl (dynamic wsdl)in registry and point that in your proxy. whenever you edit the wsdl, proxy will automatically adopt to that..But the request, which you send to your backend should follow the wsdl definitions..It is totally client side responsibility..

Getting WSO2 ESB endpoint meta data programmatically

I am trying to programmatically retrieve the meta data of the end points configured to WSO2 ESB (Eg: ServiceName, WebMethods, Input/Output Parameters with Return types etc). Can someone direct me to some way/docs which could help me fetch this data.
Unfortunately it's not really clear what you want to do. Here some examples how to access properties (Meta-Data?)
inside a proxy/sequence access properties:
<property name="some name" expression="get-property('registry','conf:resource/path')"/>
<property name="some name" expression="get-property('registry',gov:resource/path')"/>
<property name="some name" expression="get-property('registry','resourceName')"/>
Or inside a Custom Mediator:
String property = (String)messageContext.getProperty("nameOfThePropery");
Or inside a Custom Mediator (getting the filename from the Transport Layer):
org.apache.axis2.context.MessageContext axis2messageContext = ((Axis2MessageContext) messageContext).getAxis2MessageContext();
// print the filename of the current transport
myLog.info("FileName: " + axis2messageContext.getTransportIn().getName());
Hope this helps you a little bit further, otherwise improve you question.
To further improve on Abdul's question, we are developing a web-service gateway between a legacy client on side and on the other side are external web-services. We have created a template/sequences in WSo2 where we trap the legacy client request and redirect it to the correct web-service based on a internal protocol.
The external web services are registered in WSo2 as endpoints. So far we have been configuring these endpoints manually using the admin console. We are looking at automating this step so that our gateway will hit WSo2 and provide the WSDL URL. A class mediator would then invoke the WSo2 / Synapse APIs to save this endpoint in the Synapse configuration. We have not been successful in this.
We have also read the docs which say that changing synapse config thru mediator is not recommended, hence would like to see if there are other options that would do this job for us.
One workaround would be to create those endpoints from the client side itself. This can be done by calling the AdminService APIs exposed by the carbon framework. In carbon, a front end of any carbon component talks to its back end through Admin Services. For example, if we take endpoints related functionalities, when you use the management console to create/delete or to do any functionalities, it would in turn call the respective back end via the "EndPointAdmin" admin service. Therefore I believe, if you want to programmatically create those endpoints, you can call the EndPointAdmin backend admin service (via EndPointAdminStub - it is the client stub corresponding to the aforesaid back end service) directly from your client side and get your requirement fulfilled.
Regards,
Prabath

Consuming SOAP web services without the add reference approach

I am looking to make a service agent in C# from scratch. If the contracts/XSD are shareable via WSDL or dll. How do I go about writing a light weight service agent that can be configured to make calls to the SOAP webservice. When you do an add reference I feel too much code is generated behind my back.
You can post data to a webservice using the following url structure:
http://mydomain.com/mywebservicedirectory/mywebservice.asmx/mywebservicemethod
Simply use an HTTP POST to pass data(typically xml/json) to the service and process the response.
I use a bassic soap template and XSLT to render it out for what I want. It isn't that fun if you need to call multiple methods. I'm simply calling the same method over and over so it's no big deal. Simple HTTP POST will do it, that's all WCF/ASMX does.
You can get the WSDL and use XSD.exe to generate the object classes for you.