I am new to WSO2 and don't know how to use the declaritive programming widgets to create the REST contract. My use case; I have a backend SOAP 1.2 Web Service that I want to wrap with a REST API in WSO2. I don't know what media to use to define the JSON data contract so it is avalable in the sequence flow. I want to be able to visually map from the JSON payload to the SOAP payload. I really wanted to have two declaritive objects that I drag onto the sequence pallet so I can map from the JSON to the SOAP XML.
Thanks much
You can use a XSLT mediator (Sample 440) or Script mediator (Sample 441) to do the JSON to SOAP mapping. But you will have to type in the XSLT template or the script content manually after adding the mediators through Developer Studio. I don't think you can visually map elements from JSON payload to SOAP.
Go through above samples or this webinar to learn how do the transformations.
Related
I can't seem to find a way to combine two api json response by using wso developer studio. I'm still reading their documentation and i found that there is a mediator called aggregate mediator but i can't seem cant to find a way to combine the api calls and map it all while using the wso developer studio. So for example Google Contacts and Fullcontact api combines the response
In aggregate mediator, you can not aggregate responses coming from different services. When you are using aggregate mediator you have to use it with clone/iterate mediators. Those mediators will send identical clones/ chunks of message to different endpoints. Those responses will be gathered by aggregate mediator.
In your scenario, you have to use Service Chaining pattern in ESB. Please refer WSO2 documentation [1] and this blog post series [2] will help you to implement your scenario.
You can implement this pattern using developer studio. Just identify what are the components (Ex: Proxy) you need and implement them through Dev Studio.
[1] https://docs.wso2.com/display/ESB490/Service+Chaining+Example
[2] http://dakshithar.blogspot.com/2012/06/routing-and-service-chaining-with-wso2.html
It is difficult to recommend the mediators that you should use, without knowing exact use case. Scatter-Gather pattern with clone and aggregate mediators would be fine if your services are independent(one does not require other's output as input).
If they are dependent, invoke the first one using mediator and you may use a property mediator to remember the output. After the second call, you can combine them using a Payload Factory mediator or, if it is a complex integration, you may use XSLT mediator.
Apologies as I am new to the webservice space. I would like to ask some guidance on how to create a webservice that will receive data from a mobile app (XML or JSON). It will just be a simple call and Inwould need the data to be inserted to our database. I can manage to deal with the DB and the actual flow and my issue is more on how to create the actual webservice from Mule. and thought examples and comment will be appreciated.
Thanks Again
Creating web-services in Mule is pretty easy to implement and start consuming.
You can go through these links to give you a good headstart:
https://docs.mulesoft.com/mule-user-guide/v/3.7/building-web-services-with-cxf
And you can play with this project:
https://github.com/marcotello/MuleESB/tree/master/simplecxfservice
However, as you mention you know something about the mule components and flows, you'll have to do transformation of your XML/JSON input received from the mobile App to be able to be saved in Database properly.
To accept requests from mobile applications - create light weight rest APIs that consume JSON payload over the http protocol.
There are various frameworks to create rest APIs. To develop rest APIs using mule follow:
https://docs.mulesoft.com/mule-user-guide/v/3.7/rest-api-examples
Once you create a rest API, use a JSON-Object transformer with a return type of java.util.map to access each of the fields in the JSON payload.
Check out the available transformers at the below mentioned link.
https://docs.mulesoft.com/mule-user-guide/v/3.7/transformers
Tech Stack: Java 1.6, JPA (Hibernate 3), Spring 3, Oracle 11g
Hello,
In one of my projects, we have to create a number of web services.
These web services are like 'create application' and 'udpate application'.
For creating an application, the input data (request XML) is around 90-100 lines.
In my view I should be using SOAP\XML webservice (Spring), but my company has decided to go forward with REST (JAX-RS).
I think it will be difficult for client to create such request without any formal contract.
Or do you think REST will serve the purpose?
Thanks,
Adi
REST is much more flexible then SOAP. with REST service you can return responses as XML/JSON/HTML while in SOAP its usually just XML.
REST also uses plain HTTP unlike SOAP which extends HTTP.
So your company did the right choice. Regarding the format of the answer, if it's JSON, you can use libraries like Gson to convert messages. You'll need to write a document describing the different links and their input/output (look here for example)
If it's XML, all you need is an XSD for the request/response and again use a FW like XmlBeans to Marshal/Unmarshal the request/response. In that case, just give the client the XSD's and the above mentioned document.
Situation:
We are planning to build a set of new services a long side a set of old SOAP (Spring, apache CXF) web services. Our customers are used to being able to use ?wsdl to get a wsdl describing a service and the content it will accept/return.
I'm looking at providing the new services via spring controllers and RESTful urls. However not all of a request can be handled via a RESTful url, so we still need to have a payload request and responses. I'm looking at use #RequestBody and #ResponseBody and spring's Message Converters to auto(magically) handle both XML and JSON content. The idea being to let spring do as much of the heaving lifting as possible.
The problem:
I'm trying to figure out if it's possible given the REST/Message converter concept, to be able to provide a description of a service and it's request/response data in a similar fashion to the ?wsdl request. I understand that there are WADL documents that can be generated by some systems, but they appear to be a proposel and not fully accepted yet.
Does anyone know if spring can generate WADLs or something else that I can use to allow clients to query the RESTful services data structures?
SpringMVC doesn't support WADL auto generation, mostly because it doesn't use the JSR-311 standard REST API.
I have create a blog entry with a simple WADL generation Controller in java :
Tuxgalaxy Blog Entry.
But Tomasz Nurkiewicz also provide a WADL generation Controller in scala :
nurkiewicz Blog Entry.
You could use CXF JAX-RS for your REST services since you're already using it for SOAP (you can even expose the same service as SOAP and REST with CXF), and CXF gives you the WADL that you want by adding ?_wadl&_type=xml
The following code will work with Spring REST 4x and its based on the suggested code by tuxgalaxy provided on below https://jira.spring.io/browse/SPR-8705
http://javattitude.com/2014/05/26/wadl-generator-for-spring-rest/
I'm using Axis2 1.4.1 to expose RESTful web services. I need to return xml structure (or any other for example ATOM xml or RSS xml or JSON structure) of my choosing. Axis2 out of the box returns it's own default xml structure (which is SOAP like). The question is what is the right way to customize this.
Is it via Handlers? Is it via Data Binding? Is it via custom MessageFormatter? What is the way and how?
Thanks