SOAP Building Blocks
The below picture shows various building blocks of a soap message

A soap message is a xml document with below blocks.
- SOAP Envelope – An Envelope element identifies the XML document as a SOAP message – This is the root element of the SOAP message. It is used to encapsulate all the details in the SOAP message.
- Header – A Header element contains header information such as authentication credentials. It can also contain the definition of complex types which could be used in the SOAP message.
- Body – A Body element contains data request and response information. Body contains the actual data which needs to be sent between the web service and the client application.
Note -> By default, the SOAP message contains parameters which are simple types such as strings and numbers. But they can also contain complex object type.
SOAP Body example
<soap:Body>
<BookInfo>
<BookName>SOAP Web Services</BookName>
<BookDescription>Learn SOAP based web services</BookDescription>
<Price>1000</Price>
</BookInfo>
</soap:Body>
Complete SOAP message structure
Below is an example of a soap request.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header>
<m:Trans xmlns:m="https://www.javatrainingschool.com/txn/" soap:mustUnderstand="1">
12345
</m:Trans>
</soap:Header>
<soap:Body>
<LibraryWebService xmlns="https://www.javatrainingschool.com/library">
<BookId>100</BookId>
</LibraryWebService>
</soap:Body>
</soap:Envelope>
In the above example, we can see that the message contains following three things.
- Envelope
- Header
- Body
Name of the web service in the above example is LibraryWebService. And it takes one parameter called BookId. Value of which in this example is 100.
Note the below points about Envelope element:
- Every soap message must have Envelope as the root element
- Every Envelope must contain one body element
- Header element is optional for Envelope. If it contains a header element, there must be just one. Header must appear as the first child of the Envelope, before the body element.
- The Envelope changes when the SOAP version change
- A v1.2-compliant SOAP processor generates a “Version Mismatch” fault, if the received message does not contain the v1.2 envelope namespace.
SOAP Fault Message
- The SOAP Fault element is used for error messages.
- It is optional.
- The SOAP Fault element holds information about errors and status of a SOAP message.
- Fault element appears as a child element of the Body element. It can appear only once.
Below are the sub elements of SOAP Fault element :
| Fault Sub element | Description |
|---|---|
| <faultcode> | A code for the fault |
| <faultstring> | A meaningful information about the fault |
| <faultactor> | Information about who caused the error |
| <detail> | Has error information related to the body element |
SOAP Fault Code
The fault code values defined below must be used in faultcode element
| Error | Description |
|---|---|
| VersionMismatch | An invalid namespace for the SOAP Envelope element |
| MustUnderstand | An immediate child element of the Header element, with the mustUnderstand attribute set to “1”, was not understood |
| Client | The message was incorrectly formed or contained incorrect information |
| Server | There was a problem with the server so the message could not proceed |
- Home
- Java
- Java Fundamentals
- What is Java
- History of Java
- Java Version History
- Local Environment Set-up
- First Java Program
- How to set ‘Path’ env variable
- JDK, JRE, and JVM
- Object Oriented Programming
- Java Data Types
- Classes in Java
- Objects in Java
- Interfaces in java
- Class attributes and methods
- Methods In Java
- Variables and Constants in Java
- Java packages and Imports
- Access Modifiers In Java
- Java Operators
- Constructors in Java
- Control Statements – If else
- Control Statements – Loops
- Arrays in Java
- Java Abstraction
- Java Inheritance
- Polymorphism
- Java Exception Handling
- Strings in Java
- File IO
- Java Miscellaneous
- Design Patterns
- Java Fundamentals
- Collections
- Multithreading
- Java New Features
- Servlet
- JSP
- Spring
- Spring-Introduction
- First Spring Application
- Setter Injection
- Constructor injection
- Spring annotations
- Autowiring
- @Autowired Annotation Spring
- Spring MVC
- Spring JdbcTemplate
- Spring jdbcTemplate with MySQL
- Spring AOP
- Spring AOP Examples
- Various pointcut expressions in Spring AOP
- Download and configure Tomcat server
- Hibernate
- Architecture
- Hibernate Example
- First Hibernate Application (using xml configuration)
- First Hibernate Application (using annotations)
- JPA/HB – annotations
- Hibernate Identifiers
- Hibernate Generator Classes
- Save vs saveOrUpdate vs persist in Hibernate
- Inheritance Mapping in Hibernate
- Inheritance Mapping using annotations
- Hibernate Mapping
- Hibernate Query Language (HQL)
- HCQL Hibernate Criteria Query Language
- Hibernate Named Query
- Hibernate Caching
- Second Level Cache
- Spring Boot
- Spring Boot Basics
- Spring Boot Web
- Spring Boot Exception Handling
- Service discovery using Netflix Eureka
- Springboot OpenAPI/Swagger3
- Zuul Proxy Server + Routing
- Spring Cloud Gateway
- Spring Boot Security
- Circuit Breaker using Spring Boot Hystrix
- Interservice Communication
- Spring Boot Hateoas Links Example
- Lombok api
- Spring Boot with Mongo DB
- Load Balancer in Springboot
- Spring Boot Testing
- Spring Web Flux
- Database
- Web Service
- HTML
- Blog & Programs
- Docker
- Trainings
- Home
- Java
- Java Fundamentals
- What is Java
- History of Java
- Java Version History
- Local Environment Set-up
- First Java Program
- How to set ‘Path’ env variable
- JDK, JRE, and JVM
- Object Oriented Programming
- Java Data Types
- Classes in Java
- Objects in Java
- Interfaces in java
- Class attributes and methods
- Methods In Java
- Variables and Constants in Java
- Java packages and Imports
- Access Modifiers In Java
- Java Operators
- Constructors in Java
- Control Statements – If else
- Control Statements – Loops
- Arrays in Java
- Java Abstraction
- Java Inheritance
- Polymorphism
- Java Exception Handling
- Strings in Java
- File IO
- Java Miscellaneous
- Design Patterns
- Java Fundamentals
- Collections
- Multithreading
- Java New Features
- Servlet
- JSP
- Spring
- Spring-Introduction
- First Spring Application
- Setter Injection
- Constructor injection
- Spring annotations
- Autowiring
- @Autowired Annotation Spring
- Spring MVC
- Spring JdbcTemplate
- Spring jdbcTemplate with MySQL
- Spring AOP
- Spring AOP Examples
- Various pointcut expressions in Spring AOP
- Download and configure Tomcat server
- Hibernate
- Architecture
- Hibernate Example
- First Hibernate Application (using xml configuration)
- First Hibernate Application (using annotations)
- JPA/HB – annotations
- Hibernate Identifiers
- Hibernate Generator Classes
- Save vs saveOrUpdate vs persist in Hibernate
- Inheritance Mapping in Hibernate
- Inheritance Mapping using annotations
- Hibernate Mapping
- Hibernate Query Language (HQL)
- HCQL Hibernate Criteria Query Language
- Hibernate Named Query
- Hibernate Caching
- Second Level Cache
- Spring Boot
- Spring Boot Basics
- Spring Boot Web
- Spring Boot Exception Handling
- Service discovery using Netflix Eureka
- Springboot OpenAPI/Swagger3
- Zuul Proxy Server + Routing
- Spring Cloud Gateway
- Spring Boot Security
- Circuit Breaker using Spring Boot Hystrix
- Interservice Communication
- Spring Boot Hateoas Links Example
- Lombok api
- Spring Boot with Mongo DB
- Load Balancer in Springboot
- Spring Boot Testing
- Spring Web Flux
- Database
- Web Service
- HTML
- Blog & Programs
- Docker
- Trainings
- Home
- Java
- Java Fundamentals
- What is Java
- History of Java
- Java Version History
- Local Environment Set-up
- First Java Program
- How to set ‘Path’ env variable
- JDK, JRE, and JVM
- Object Oriented Programming
- Java Data Types
- Classes in Java
- Objects in Java
- Interfaces in java
- Class attributes and methods
- Methods In Java
- Variables and Constants in Java
- Java packages and Imports
- Access Modifiers In Java
- Java Operators
- Constructors in Java
- Control Statements – If else
- Control Statements – Loops
- Arrays in Java
- Java Abstraction
- Java Inheritance
- Polymorphism
- Java Exception Handling
- Strings in Java
- File IO
- Java Miscellaneous
- Design Patterns
- Java Fundamentals
- Collections
- Multithreading
- Java New Features
- Servlet
- JSP
- Spring
- Spring-Introduction
- First Spring Application
- Setter Injection
- Constructor injection
- Spring annotations
- Autowiring
- @Autowired Annotation Spring
- Spring MVC
- Spring JdbcTemplate
- Spring jdbcTemplate with MySQL
- Spring AOP
- Spring AOP Examples
- Various pointcut expressions in Spring AOP
- Download and configure Tomcat server
- Hibernate
- Architecture
- Hibernate Example
- First Hibernate Application (using xml configuration)
- First Hibernate Application (using annotations)
- JPA/HB – annotations
- Hibernate Identifiers
- Hibernate Generator Classes
- Save vs saveOrUpdate vs persist in Hibernate
- Inheritance Mapping in Hibernate
- Inheritance Mapping using annotations
- Hibernate Mapping
- Hibernate Query Language (HQL)
- HCQL Hibernate Criteria Query Language
- Hibernate Named Query
- Hibernate Caching
- Second Level Cache
- Spring Boot
- Spring Boot Basics
- Spring Boot Web
- Spring Boot Exception Handling
- Service discovery using Netflix Eureka
- Springboot OpenAPI/Swagger3
- Zuul Proxy Server + Routing
- Spring Cloud Gateway
- Spring Boot Security
- Circuit Breaker using Spring Boot Hystrix
- Interservice Communication
- Spring Boot Hateoas Links Example
- Lombok api
- Spring Boot with Mongo DB
- Load Balancer in Springboot
- Spring Boot Testing
- Spring Web Flux
- Database
- Web Service
- HTML
- Blog & Programs
- Docker
- Trainings