Categories: SOAPTutorial

SOAP Transport

<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;" trbidi&equals;"on">&NewLine;<table border&equals;"0" cellpadding&equals;"0" cellspacing&equals;"0" style&equals;"width&colon; 100&percnt;px&semi;">&NewLine;<tbody>&NewLine;<tr>&NewLine;<td valign&equals;"top">&NewLine;<ul>&NewLine;<li><b>SOAP <&sol;b>is not tied to any one transport protocol&period; <&sol;li>&NewLine;<li><b>SOAP <&sol;b>can be transported via <b>SMTP<&sol;b>&comma; <b>FTP<&sol;b>&comma; <b>IBM<&sol;b>&&num;8216&semi;s <b>MQSeries<&sol;b>&comma; or <b>Microsoft Message Queuing &lpar;MSMQ&rpar;&period; <&sol;b><&sol;li>&NewLine;<li><b>SOAP <&sol;b>specification includes details on <b>HTTP <&sol;b>only&period; <&sol;li>&NewLine;<li><b>HTTP <&sol;b>remains the most popular <b>SOAP <&sol;b>transport protocol&period; <&sol;li>&NewLine;<&sol;ul>&NewLine;<p><b><br &sol;>&NewLine;SOAP via HTTP<&sol;b><br &sol;>&NewLine;Quite logically&comma; <b>SOAP<&sol;b> <b>requests <&sol;b>are sent via an <b>HTTP <&sol;b>request and <b>SOAP responses <&sol;b>are returned within the content of the <b>HTTP response<&sol;b>&period; While <b> SOAP requests<&sol;b> can be sent via an <b>HTTP GET<&sol;b>&comma; the specification includes details on <b>HTTP POST<&sol;b> only&period;<br &sol;>&NewLine;Additionally&comma; both <b>HTTP requests and responses<&sol;b> are required to set their content type to <b><i>text&sol;xml<&sol;i><&sol;b>&period;<br &sol;>&NewLine;The <b>SOAP <&sol;b>specification mandates that the client must provide a <i><b> SOAPAction <&sol;b><&sol;i>header&comma; but the actual value of the <i><b>SOAPAction <&sol;b><&sol;i>header is dependent on the <i><b>SOAP <&sol;b><&sol;i>server implementation&period;<&sol;p>&NewLine;<div align&equals;"center" id&equals;"ads-id"><&sol;div>&NewLine;<p>For example&comma; to access the AltaVista BabelFish Translation service&comma; hosted by XMethods&comma; you must specify the following as a <i><b>SOAPAction <&sol;b><&sol;i>header&period;<&sol;p>&NewLine;<table class&equals;"ex" style&equals;"width&colon; 100&percnt;px&semi;">&NewLine;<tbody>&NewLine;<tr>&NewLine;<td>&NewLine;<pre>urn&colon;xmethodsBabelFish&num;BabelFish&NewLine;<&sol;pre>&NewLine;<&sol;td>&NewLine;<&sol;tr>&NewLine;<&sol;tbody>&NewLine;<&sol;table>&NewLine;<p>Even if the server does not require a full <i><b>SOAPAction <&sol;b><&sol;i>header&comma; the client must specify an empty string &lpar;&&num;8220&semi;&&num;8221&semi;&rpar;&comma; or a null value&period; For example&colon;<&sol;p>&NewLine;<table class&equals;"ex" style&equals;"width&colon; 100&percnt;px&semi;">&NewLine;<tbody>&NewLine;<tr>&NewLine;<td>&NewLine;<pre class&equals;"highlight" name&equals;"code">SOAPAction&colon; ""&NewLine;SOAPAction&colon;&NewLine;<&sol;pre>&NewLine;<&sol;td>&NewLine;<&sol;tr>&NewLine;<&sol;tbody>&NewLine;<&sol;table>&NewLine;<p>Here is a sample request sent via <i><b>HTTP <&sol;b><&sol;i>to the <b><i>XMethods Babelfish <&sol;i><&sol;b>Translation service&colon;<&sol;p>&NewLine;<table class&equals;"src" style&equals;"width&colon; 100&percnt;px&semi;">&NewLine;<tbody>&NewLine;<tr>&NewLine;<td>&NewLine;<pre class&equals;"highlight" name&equals;"code">POST &sol;perl&sol;soaplite&period;cgi HTTP&sol;1&period;0&NewLine;Host&colon; services&period;xmethods&period;com&NewLine;Content-Type&colon; text&sol;xml&semi; charset&equals;utf-8&NewLine;Content-Length&colon; 538&NewLine;SOAPAction&colon; "urn&colon;xmethodsBabelFish&num;BabelFish"&NewLine;&NewLine;&lt&semi;&quest;xml version&equals;'1&period;0' encoding&equals;'UTF-8'&quest;&gt&semi;&NewLine;&lt&semi;SOAP-ENV&colon;Envelope&NewLine;xmlns&colon;SOAP-ENV&equals;"http&colon;&sol;&sol;schemas&period;xmlsoap&period;org&sol;soap&sol;envelope&sol;"&NewLine;xmlns&colon;xsi&equals;"http&colon;&sol;&sol;www&period;w3&period;org&sol;1999&sol;XMLSchema-instance"&NewLine;xmlns&colon;xsd&equals;"http&colon;&sol;&sol;www&period;w3&period;org&sol;1999&sol;XMLSchema"&gt&semi;&NewLine;&lt&semi;SOAP-ENV&colon;Body&gt&semi;&NewLine;&lt&semi;ns1&colon;BabelFish&NewLine;xmlns&colon;ns1&equals;"urn&colon;xmethodsBabelFish"&NewLine;SOAP-ENV&colon;encodingStyle&equals;"http&colon;&sol;&sol;schemas&period;xmlsoap&period;org&sol;soap&sol;encoding&sol;"&gt&semi;&NewLine;&lt&semi;translationmode xsi&colon;type&equals;"xsd&colon;string"&gt&semi;en&lowbar;fr&lt&semi;&sol;translationmode&gt&semi;&NewLine;&lt&semi;sourcedata xsi&colon;type&equals;"xsd&colon;string"&gt&semi;Hello&comma; world&excl;&lt&semi;&sol;sourcedata&gt&semi;&NewLine;&lt&semi;&sol;ns1&colon;BabelFish&gt&semi;&NewLine;&lt&semi;&sol;SOAP-ENV&colon;Body&gt&semi;&NewLine;&lt&semi;&sol;SOAP-ENV&colon;Envelope&gt&semi;&NewLine;<&sol;pre>&NewLine;<&sol;td>&NewLine;<&sol;tr>&NewLine;<&sol;tbody>&NewLine;<&sol;table>&NewLine;<p>Note the content type and the <i><b>SOAPAction <&sol;b><&sol;i>header&period; Also note that the <b><i> BabelFish <&sol;i><&sol;b>method requires two String parameters&period; The translation mode en&lowbar;fr will translate from English to French&period;<br &sol;>&NewLine;Here is the response from <i><b>XMethods<&sol;b><&sol;i>&colon;<&sol;p>&NewLine;<table class&equals;"src" style&equals;"width&colon; 100&percnt;px&semi;">&NewLine;<tbody>&NewLine;<tr>&NewLine;<td>&NewLine;<pre class&equals;"highlight" name&equals;"code">HTTP&sol;1&period;1 200 OK&NewLine;Date&colon; Sat&comma; 09 Jun 2001 15&colon;01&colon;55 GMT&NewLine;Server&colon; Apache&sol;1&period;3&period;14 &lpar;Unix&rpar; tomcat&sol;1&period;0 PHP&sol;4&period;0&period;1pl2&NewLine;SOAPServer&colon; SOAP&colon;&colon;Lite&sol;Perl&sol;0&period;50&NewLine;Cache-Control&colon; s-maxage&equals;60&comma; proxy-revalidate&NewLine;Content-Length&colon; 539&NewLine;Content-Type&colon; text&sol;xml&NewLine;&NewLine;&lt&semi;&quest;xml version&equals;"1&period;0" encoding&equals;"UTF-8"&quest;&gt&semi;&NewLine;&lt&semi;SOAP-ENV&colon;Envelope&NewLine;xmlns&colon;SOAP-ENC&equals;"http&colon;&sol;&sol;schemas&period;xmlsoap&period;org&sol;soap&sol;encoding&sol;"&NewLine;SOAP-ENV&colon;encodingStyle&equals;"http&colon;&sol;&sol;schemas&period;xmlsoap&period;org&sol;soap&sol;encoding&sol;"&NewLine;xmlns&colon;xsi&equals;"http&colon;&sol;&sol;www&period;w3&period;org&sol;1999&sol;XMLSchema-instance"&NewLine;xmlns&colon;SOAP-ENV&equals;"http&colon;&sol;&sol;schemas&period;xmlsoap&period;org&sol;soap&sol;envelope&sol;"&NewLine;xmlns&colon;xsd&equals;"http&colon;&sol;&sol;www&period;w3&period;org&sol;1999&sol;XMLSchema"&gt&semi;&NewLine;&lt&semi;SOAP-ENV&colon;Body&gt&semi;&NewLine;&lt&semi;namesp1&colon;BabelFishResponse xmlns&colon;namesp1&equals;"urn&colon;xmethodsBabelFish"&gt&semi;&NewLine;&lt&semi;return xsi&colon;type&equals;"xsd&colon;string"&gt&semi;Bonjour&comma; monde&excl;&lt&semi;&sol;return&gt&semi;&NewLine;&lt&semi;&sol;namesp1&colon;BabelFishResponse&gt&semi;&NewLine;&lt&semi;&sol;SOAP-ENV&colon;Body&gt&semi;&NewLine;&lt&semi;&sol;SOAP-ENV&colon;Envelope&gt&semi;&NewLine;&NewLine;<&sol;pre>&NewLine;<&sol;td>&NewLine;<&sol;tr>&NewLine;<&sol;tbody>&NewLine;<&sol;table>&NewLine;<p><i><b>SOAP <&sol;b><&sol;i>responses delivered via <i><b>HTTP <&sol;b><&sol;i>are required to follow the same <b><i> HTTP <&sol;i><&sol;b>status codes&period; For example&comma; a status code of 200 OK indicates a successful response&period; A status code of 500 Internal Server Error indicates that there is a server error and that the SOAP response includes a Fault element&period;<&sol;td>&NewLine;<&sol;tr>&NewLine;<&sol;tbody>&NewLine;<&sol;table>&NewLine;<p>&NewLine;<b><br &sol;>&NewLine;SOAP HTTP Binding<&sol;b><br &sol;>&NewLine; A SOAP method is an HTTP request&sol;response that complies with the SOAP encoding rules&period;<&sol;p>&NewLine;<h3>HTTP &plus; XML &equals; SOAP<&sol;h3>&NewLine;<p> A SOAP request could be an HTTP POST or an HTTP GET request&period;<br &sol;>&NewLine; The HTTP POST request specifies at least two HTTP headers&colon; Content-Type and Content-Length&period;<&sol;p>&NewLine;<p><&sol;p>&NewLine;<h2>Content-Type<&sol;h2>&NewLine;<p> The Content-Type header for a SOAP request and response defines the MIME type for the message and the character encoding &lpar;optional&rpar; used for the XML body of the request or response&period;<&sol;p>&NewLine;<h4>Syntax<&sol;h4>&NewLine;<p><&sol;p>&NewLine;<div class&equals;"code notranslate">&NewLine;<div> Content-Type&colon; MIMEType&semi; charset&equals;character-encoding <&sol;div>&NewLine;<&sol;div>&NewLine;<p><&sol;p>&NewLine;<h4>Example<&sol;h4>&NewLine;<p><&sol;p>&NewLine;<div class&equals;"code notranslate">&NewLine;<div> POST &sol;item HTTP&sol;1&period;1<br &sol;>&NewLine;Content-Type&colon; application&sol;soap&plus;xml&semi; charset&equals;utf-8 <&sol;div>&NewLine;<&sol;div>&NewLine;<p><&sol;p>&NewLine;<h2>Content-Length<&sol;h2>&NewLine;<p> The Content-Length header for a SOAP request and response specifies the number of bytes in the body of the request or response&period;<&sol;p>&NewLine;<h4>Syntax<&sol;h4>&NewLine;<p><&sol;p>&NewLine;<div class&equals;"code notranslate">&NewLine;<div> Content-Length&colon; bytes<&sol;div>&NewLine;<&sol;div>&NewLine;<p><&sol;p>&NewLine;<h4>Example<&sol;h4>&NewLine;<p><&sol;p>&NewLine;<div class&equals;"code notranslate">&NewLine;<div> <b><i>POST &sol;item HTTP&sol;1&period;1<br &sol;>&NewLine;Content-Type&colon; application&sol;soap&plus;xml&semi; charset&equals;utf-8<br &sol;>&NewLine;Content-Length&colon; 250 <&sol;i><&sol;b><&sol;div>&NewLine;<&sol;div>&NewLine;<p>&NewLine;<i><b>References<&sol;b><&sol;i><br &sol;>&NewLine;<i><b><a href&equals;"http&colon;&sol;&sol;en&period;wikipedia&period;org&sol;wiki&sol;SOAP" target&equals;"&lowbar;blank">Wikipedia for SOAP<&sol;a><&sol;b><&sol;i><&sol;p>&NewLine;<p>&nbsp&semi; <&sol;p>&NewLine;<div style&equals;"background-color&colon; pink&semi; border-width&colon; thin&semi; text-align&colon; center&semi;"><b>&lt&semi;&lt&semi;<a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2013&sol;05&sol;soap-encoding&period;html">Previous<&sol;a> &lt&semi;&lt&semi;&nbsp&semi;&nbsp&semi; &vert;&vert; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2013&sol;01&sol;core-java-baby-step-to-be-best-java-ian&period;html">Index <&sol;a>&vert;&vert; &nbsp&semi; &gt&semi;&gt&semi;<a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2013&sol;05&sol;soap-example&period;html">Next<&sol;a> &gt&semi;&gt&semi;<&sol;b><&sol;div>&NewLine;<p>&NewLine;<&sol;div>&NewLine;<div class&equals;"wp-post-navigation"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-pre"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;soap-encoding&sol;">Previous<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-next"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;soap-example&sol;">Next<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;<script type&equals;"text&sol;javascript">&NewLine;jQuery&lpar;document&rpar;&period;ready&lpar;function&lpar;&dollar;&rpar; &lbrace;&NewLine; &dollar;&period;post&lpar;'https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-admin&sol;admin-ajax&period;php'&comma; &lbrace;action&colon; 'mts&lowbar;view&lowbar;count'&comma; id&colon; '440'&rcub;&rpar;&semi;&NewLine;&rcub;&rpar;&semi;&NewLine;<&sol;script>

Dinesh Rajput

Dinesh Rajput is the chief editor of a website Dineshonjava, a technical blog dedicated to the Spring and Java technologies. It has a series of articles related to Java technologies. Dinesh has been a Spring enthusiast since 2008 and is a Pivotal Certified Spring Professional, an author of a book Spring 5 Design Pattern, and a blogger. He has more than 10 years of experience with different aspects of Spring and Java design and development. His core expertise lies in the latest version of Spring Framework, Spring Boot, Spring Security, creating REST APIs, Microservice Architecture, Reactive Pattern, Spring AOP, Design Patterns, Struts, Hibernate, Web Services, Spring Batch, Cassandra, MongoDB, and Web Application Design and Architecture. He is currently working as a technology manager at a leading product and web development company. He worked as a developer and tech lead at the Bennett, Coleman & Co. Ltd and was the first developer in his previous company, Paytm. Dinesh is passionate about the latest Java technologies and loves to write technical blogs related to it. He is a very active member of the Java and Spring community on different forums. When it comes to the Spring Framework and Java, Dinesh tops the list!

Share
Published by
Dinesh Rajput

Recent Posts

Strategy Design PatternsĀ using Lambda

Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…

4 years ago

Decorator Pattern using Lambda

Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…

4 years ago

Delegating pattern using lambda

Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…

4 years ago

Spring Vs Django- Know The Difference Between The Two

Technology has emerged a lot in the last decade, and now we have artificial intelligence;…

4 years ago

TOP 20 MongoDB INTERVIEW QUESTIONS 2022

Managing a database is becoming increasingly complex now due to the vast amount of data…

4 years ago

Scheduler @Scheduled Annotation Spring Boot

Overview In this article, we will explore Spring Scheduler how we could use it by…

4 years ago