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

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

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.

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.

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.

WSDL and SOAP Clarification

Can someone confirm or clarify:
WSDL describes a web service's API to the outside world
SOAP represents an actual transmission of a web service request/response
So, if I understand correctly, WSDL-compliant XML is wrapped inside of SOAP and passed over HTTP to the web service interface, unwrapped, validated against the WSDL, processed, and responded to.
Yes? No? Close?
You're close.
The WSDL describes the contract that a Web Service adheres to or, in other words, the format that the service expects to receive and transmit data in.
SOAP (Simple Object Access Protocol) is one protocol by which Web Services communicate. SOAP will wrap the message with additional information. The message with the SOAP body carries must comply with the service's WSDL for the service to properly process the message.

How to create SOAP messages ? How to convert a soap message to an object?

1- How do i create soap messages to communicate with a web service? Let's say my client needs to send a request to a web service, Do i generate the FULL soap string and then send it to the web service, including header, body, envelop etc?
2- Let's say the web service sends me back a SOAP response, the response contains information about 4 different users info in my database?
How do i convert the soap message to 4 "objects of User"?
Do i need to loop through the message and read each parameter 1 by 1, and create my "User" objects? or is there an easier way of matching the parameters in the soap message with parameters in my class and create the objects automatically?
If you have the WSDL of that webservice, many IDE's have the ability to import the WSDL and auto generate a client program for the bindings.
So, if the webservice returns many USER objects, your IDE' will generate them back. If not, it will generate objects for the kind of response your webservice returns.
With those objects, i think will be easier to extract the users from it than from the raw envelope