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

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.

Related

What's the difference between receiving data by SOAP header and SOAP body?

I would like what happen when an web service receive part of data by SOAP header. What's the diference between receive data by SOAP header and SOAP body (Before the web service receive all of data by SOAP body)
I don't understand at all what are benefits of this new version.
PD: My web service is based on Java with JAX-WS
Thanks a lot.
Same as any request SOAP has header and body. generally SOAP has all data in body.
Body is highly documented so you can not send additional data in SOAP body.
If you are doing It may break the other end code(Implementation in different for different technologies).
SO if you want to send additional data in SOAP without effecting the WSDL you can use SOAP header.
Headers are like to send additional information.
these header and values can be accessed from message context.
to access these value code may vary from technology to technology

How handle html responses in a Restful Api

I am working on a large api, it tries to be restful (and for most part it succeeds), one of our client requires a term of service in html format.
Is it ok to have a endpoint that returns html in a restful json api? Are there better alternatives?
I believe it's best to have the client dictate the content type via Accept header in the HTTP request. You can default to application/json and have the client call the API they require with a text/html Accept header.
It is okay for RESTful services to return any media type, as long as the API itself is agnostic of it.

What is http text post in webservice context?

I am having confusion around http text 'post' in terms of webservice context. We are having a web service which is built on SOAP protocol, now the integration partner wants to eliminate the SOAP portion of the XML message and wants us to post XML message as 'http text post'.
Is this REST HTTP POST? Please clarify.
POST is an HTTP request method, of which there are many (ex. GET, PUT, DELETE, HEAD...). POST is used to submit data to a server for processing, whereas GET (for example) is used to retrieve data for reading. You can read more here. These methods are used for all HTTP communication, whether the target is a SOAP/REST web service or an Apache server hosting a regular website.
SOAP normally operates using POST requests, although it is possible to use GET with SOAP 1.2 as well. GET requests have more restrictive size limitations than POST requests.

Expose Rest API as SOAP in WSO2 ESB

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.

Query about SOAP and HTTP fundamentals

Is a client SOAP request simply the use of HTTP POST to send a correctly formatted HTTP header followed by the correctly formatted XML SOAP content to the web service server over a TCP/IP socket connection and then waiting for and parsing the response?
Is it this 'simple' or is there more going on behind the scenes?
I ask because of difficulty using gSOAP with C++ for multiple WSDL files and am considering writing a client from scratch.
SOAP can be used over any transport protocol like TCP, HTTP, SMTP etc with HTTP being the most popular.
SOAP over HTTP basically translates to a valid POST HTTP request with a SOAP envelope inside it, there where the form parameters would have been if we were to talk about a classic POST from the browser. The response body also contains a SOAP envelope, there where you would expect the HTML to be as response to the request from the browser.
You just have to use the proper content type for the SOAP version you are using (text/xml for SOAP 1.1 and application/soap+xml for SOAP 1.2) and maybe specify the SOAPAction header if needed (for SOAP 1.1), but that's about it as HTTP communication is concerned.
Then the receiver of the envelope (be it the server on a request or the client on a response) must make use of the SOAP message, but this has nothing to do with HTTP any more, HTTP just got the message there.