Expose Rest API as SOAP in WSO2 ESB - rest

I have a Rest Api (Python/flask) that send response in json.
I need to POST a request with 3 parameters (body) using Soap, but I don't know about Soap and I don't understand the samples.
Can I just use a mediator to "translate" my Rest Api into a Soap Api ?
How can I test the Post request with SoapUi ? Do I need to use a wsdl file ?
I just need entry point documentation.
thanks.

You will need a WSDL to define your operation/web-service i.e SOAP Request incl 3 parameters. I use eclipse with the Web Tools plug in to create WSDLS. Then you'll need to get SOAP --> New Soap Project, and include the wsdl. LEt me know when you get there , and we can continue!

You will need to define your operations of the SOAP web service in a WSDL. Then you can create a new project in SOAPUI with this WSDL. Follow http://www.soapui.org/soap-and-wsdl/operations-and-requests.html on how to create a request for a particular operation.
In ESB you can create an API for your REST service (https://docs.wso2.com/display/ESB481/Creating+APIs). Now you need to use a payloadfactor mediator in your API in sequence to transform your SOAP(XML) request to JSON (https://docs.wso2.com/display/ESB481/PayloadFactory+Mediator). Then, this JSON request will be sent to the REST backend. If you again need to transfer the JSON response from the backend to SOAP, include another payload factory mediator to transform.

Related

Is it possible to send a SOAP request to a REST endpoint?

I'm working with an old ERP system that is capable of sending SOAP requests.
Unfortunately the endpoints I would like to send my requests to uses REST.
Is it possible to send a SOAP request to a REST endpoint?
BR Kresten
You can send whatever you want to a REST endpoint.
You could have a "gatekeeper" REST endpoint that accepted SOAP in a POST payload and converted it to whatever representation the other endpoints required and returned that representation. e.g. JSON. So in effect it becomes a SOAP to JSON converter.
If you can only send SOAP direct from an ERP system to your endpoint, your endpoint could accept the SOAP in a POST request and do whatever it wanted with it. SOAP is just XML, so the endpoint could just parse it to get the info it would "normally" get via "traditional" REST such as JSON.
You could combine the two approaches. Your ERP system could send SOAP to the "gatekeeper" endpoint which converts the SOAP to JSON and sends the converted content to the intended endpoint.

Should I be using REST or SOAP UI for testing?

I am testing a new webservice that is receiving messages from an application and responding with messages with specific information. The webservice then uses this information to create new messages for downstream systems. I need to know the best way I can test this using the Ready API tool, we just got a pro license. Is it SOAP or REST I need to use. Ideally I want to simply copy my application messages in to the tool, call the webservice and get the response, which I can then check is the correct response for the test
To find your web-service is SOAP or REST.
Please check whether your web service has WSDL to verify it has SOAP web-service, you can get your web-service's WSDL by post-fixing WSDL with your web service url.
Eg: http://{yourservice-url/path1}?WSDL
If your service don't provide WSDL from the above URL, then your web-service is REST.

How to make a REST API call from SOAP

I would like to know the best practices of calling a REST API from SOAP.
Requirement:
We have a SOAP-based web service that is already consuming by many applications. we would like to rewrite the SOAP API with Rest(basically a Spring boot application), but we want to call the rest from SOAP to support the existing applications.
The one way I know is we can call the Rest Api from the SOAP server implementation class
EX: Consider EmployeeService;java is a SOAP implementation class
EmployeeService.java
getEmployee(){
Calling new Rest Api
}
Existing app1 ---->SOAP --> REST API
Existing app2 ---->SOAP --> REST API
new app1 --> REST API.
Please let me know is there any best way\alternate way to handle it.
You can use boomerang soap client.
Detail here

Azure Logic App Custom Connector - SOAP to REST - Pass HTTP header from REST to SOAP request

In Azure I am able to create a Logic App Custom Connector to a SOAP API endpoint using Call Mode: SOAP to REST.
This SOAP Web Service needs an HTTP Header named Cookie with the value LoginCert=.
When modifying the Request of this connector I cannot find a way to add the Cookie HTTP header in the REST request and have that same Cookie be added to the SOAP request. Does anyone know how or if it is even possible to have HTTP headers from the REST request forwarded to the SOAP request made by the custom connector?
PS: This is possible in Azure via the API Management tool's REST to SOAP using the same WSDL, and then using the newly created REST endpoints inside of a Logic App Flow but this is not the solution.
TLDR: How can one add a HTTP header in an SOAP to REST Azure Logic App Custom Connector so the header is forwarded to the SOAP endpoint?
This is not currently supported by the SOAP to REST WSDL generated custom connectors for SOAP. You need indeed to either escape to APIM or you need to form the request payloads via LIQUID action then use the HTTP request action's advanced option to specify the cookie.

How to build soap to rest gateway

How would you build a soap to rest gateway with the least amount of work? I provide a REST API on my Rails 3.2 server. My customer requires me to provide a SOAP API. I don't want to use Rails for providing the SOAP API since that would probably take much more work than building a SOAP to REST gateway using a framework that fully supports SOAP.
I just noticed that Rails 3.2 parses SOAP requests automatically into the params hash (ActionDispatch::ParamsParser Rack middleware). So, I decided to implement the gateway in Rails. Since I don't really care to implement a full featured SOAP Server--all I want is to make it work for my customer's current SOAP client--I will just read the data that I need from the params hash and build the xml response using Builder and publish a static wsdl file if they need it. It will be less than 20 lines of code.
config/routes.rb
Gateway::Application.routes.draw do
match "/clientx/echo" => "clientx#echo"
end
app/controllers/clientx_controller.rb
class ClientxController < ApplicationController
def echo
# authenticate client
# parse params
# send and receive rest request
# render response
end
end
What about Mule ESB? Supports a various form of input and output possibilities. Implemented a SOAP-receiving application based on Mule myself.