Categories: SOAPTutorial

SOAP Header Element

<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;" trbidi&equals;"on">&NewLine;<div class&equals;"intro">The SOAP Header element contains header information&period;<&sol;div>&NewLine;<p><b><br &sol;>&NewLine;The SOAP Header Element<&sol;b><br &sol;>&NewLine;The optional SOAP Header element contains application-specific information &lpar;like authentication&comma; payment&comma; etc&rpar; about the SOAP message&period;<br &sol;>&NewLine;If the Header element is present&comma; it must be the first child element of the Envelope element&period;<br &sol;>&NewLine;<b>Note&colon;<&sol;b> All immediate child elements of the Header element must be namespace-qualified&period;<&sol;p>&NewLine;<pre class&equals;"highlight" name&equals;"code">&lt&semi;&quest;xml version&equals;"1&period;0"&quest;&gt&semi;&NewLine;&lt&semi;soap&colon;Envelope&NewLine;xmlns&colon;soap&equals;"http&colon;&sol;&sol;www&period;w3&period;org&sol;2001&sol;12&sol;soap-envelope"&NewLine;soap&colon;encodingStyle&equals;"http&colon;&sol;&sol;www&period;w3&period;org&sol;2001&sol;12&sol;soap-encoding"&gt&semi;&NewLine;&NewLine;&lt&semi;soap&colon;Header&gt&semi;&NewLine; &lt&semi;m&colon;Trans xmlns&colon;m&equals;"http&colon;&sol;&sol;www&period;w3schools&period;com&sol;transaction&sol;"&NewLine; soap&colon;mustUnderstand&equals;"1"&gt&semi;234&NewLine; &lt&semi;&sol;m&colon;Trans&gt&semi;&NewLine;&lt&semi;&sol;soap&colon;Header&gt&semi;&NewLine;&period;&period;&period;&NewLine;&period;&period;&period;&NewLine;&lt&semi;&sol;soap&colon;Envelope&gt&semi; &NewLine;<&sol;pre>&NewLine;<div align&equals;'center' id&equals;"ads-id"><&sol;div>&NewLine;<p>The example above contains a header with a &&num;8220&semi;Trans&&num;8221&semi; element&comma; a &&num;8220&semi;mustUnderstand&&num;8221&semi; attribute with a value of 1&comma; and a value of 234&period;<br &sol;>&NewLine;SOAP defines three attributes in the default namespace &lpar;&&num;8220&semi;http&colon;&sol;&sol;www&period;w3&period;org&sol;2001&sol;12&sol;soap-envelope&&num;8221&semi;&rpar;&period; These attributes are&colon; mustUnderstand&comma; actor&comma; and encodingStyle&period;<br &sol;>&NewLine;The attributes defined in the SOAP Header defines how a recipient should process the SOAP message&period;<br &sol;>&NewLine;<b><br &sol;>&NewLine;The <i>mustUnderstand <&sol;i>Attribute<&sol;b><br &sol;>&NewLine;The SOAP mustUnderstand attribute can be used to indicate whether a header entry is mandatory or optional for the recipient to process&period;<br &sol;>&NewLine;If you add mustUnderstand&equals;&&num;8221&semi;1&&num;8243&semi; to a child element of the Header element it indicates that the receiver processing the Header must recognize the element&period; If the receiver does not recognize the element it will fail when processing the Header&period;<&sol;p>&NewLine;<h3>Syntax<&sol;h3>&NewLine;<div class&equals;"code notranslate">&NewLine;<div>soap&colon;mustUnderstand&equals;&&num;8221&semi;0&vert;1&&num;8243&semi;<&sol;div>&NewLine;<&sol;div>&NewLine;<p><b><br &sol;>&NewLine;Example<&sol;b><&sol;p>&NewLine;<pre class&equals;"highlight" name&equals;"code">&lt&semi;&quest;xml version&equals;"1&period;0"&quest;&gt&semi;&NewLine;&lt&semi;soap&colon;Envelope&NewLine;xmlns&colon;soap&equals;"http&colon;&sol;&sol;www&period;w3&period;org&sol;2001&sol;12&sol;soap-envelope"&NewLine;soap&colon;encodingStyle&equals;"http&colon;&sol;&sol;www&period;w3&period;org&sol;2001&sol;12&sol;soap-encoding"&gt&semi;&NewLine;&NewLine;&lt&semi;soap&colon;Header&gt&semi;&NewLine; &lt&semi;m&colon;Trans xmlns&colon;m&equals;"http&colon;&sol;&sol;www&period;w3schools&period;com&sol;transaction&sol;"&NewLine; soap&colon;mustUnderstand&equals;"1"&gt&semi;234&NewLine; &lt&semi;&sol;m&colon;Trans&gt&semi;&NewLine;&lt&semi;&sol;soap&colon;Header&gt&semi;&NewLine;&period;&period;&period;&NewLine;&period;&period;&period;&NewLine;&lt&semi;&sol;soap&colon;Envelope&gt&semi; &NewLine;<&sol;pre>&NewLine;<p><b><br &sol;>&NewLine;The <i>actor <&sol;i>Attribute<&sol;b><br &sol;>&NewLine;A SOAP message may travel from a sender to a receiver by passing different endpoints along the message path&period; However&comma; not all parts of a SOAP message may be intended for the ultimate endpoint&comma; instead&comma; it may be intended for one or more of the endpoints on the message path&period;<br &sol;>&NewLine;The SOAP actor attribute is used to address the Header element to a specific endpoint&period;<&sol;p>&NewLine;<h3>Syntax<&sol;h3>&NewLine;<div class&equals;"code notranslate">&NewLine;<div>soap&colon;actor&equals;&&num;8221&semi;<i>URI<&sol;i>&&num;8221&semi; <&sol;div>&NewLine;<&sol;div>&NewLine;<p><b><br &sol;>&NewLine;Example<&sol;b><&sol;p>&NewLine;<pre class&equals;"highlight" name&equals;"code">&lt&semi;&quest;xml version&equals;"1&period;0"&quest;&gt&semi;&NewLine;&lt&semi;soap&colon;Envelope&NewLine;xmlns&colon;soap&equals;"http&colon;&sol;&sol;www&period;w3&period;org&sol;2001&sol;12&sol;soap-envelope"&NewLine;soap&colon;encodingStyle&equals;"http&colon;&sol;&sol;www&period;w3&period;org&sol;2001&sol;12&sol;soap-encoding"&gt&semi;&NewLine;&NewLine;&lt&semi;soap&colon;Header&gt&semi;&NewLine; &lt&semi;m&colon;Trans xmlns&colon;m&equals;"http&colon;&sol;&sol;www&period;w3schools&period;com&sol;transaction&sol;"&NewLine; soap&colon;actor&equals;"http&colon;&sol;&sol;www&period;w3schools&period;com&sol;appml&sol;"&gt&semi;234&NewLine; &lt&semi;&sol;m&colon;Trans&gt&semi;&NewLine;&lt&semi;&sol;soap&colon;Header&gt&semi;&NewLine;&period;&period;&period;&NewLine;&period;&period;&period;&NewLine;&lt&semi;&sol;soap&colon;Envelope&gt&semi; &NewLine;<&sol;pre>&NewLine;<p><b><br &sol;>&NewLine;The <i>encodingStyle <&sol;i>Attribute<&sol;b><br &sol;>&NewLine;The <i><b>encodingStyle <&sol;b><&sol;i>attribute is used to define the data types used in the document&period; This attribute may appear on any SOAP element&comma; and it will apply to that element&&num;8217&semi;s contents and all child elements&period;<br &sol;>&NewLine;A SOAP message has no default encoding&period;<&sol;p>&NewLine;<h3>Syntax<&sol;h3>&NewLine;<div class&equals;"code notranslate">&NewLine;<div>soap&colon;encodingStyle&equals;&&num;8221&semi;<i>URI<&sol;i>&&num;8221&semi; <&sol;div>&NewLine;<&sol;div>&NewLine;<p><i><b>References<&sol;b><&sol;i><br &sol;>&NewLine;1&period; <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-envelope-element&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-body-element&period;html">Next<&sol;a> &gt&semi;&gt&semi;<&sol;b><&sol;div>&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-envelope-element&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-body-element&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; '444'&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