This recipe explains how to define a document transport for a web service. We divide transportation mechanisms into two parts. One is the Remote Procedure Call (RPC) transport and the second one is the document transport. Actually, these two transports define styles which we use for transferring messages and their values. In the document transport, we indicate that SOAP messages are using XML instances, meaning each part of a SOAP message is referring to the XML schema definition. This type is also the default transport type for JAX-WS.
The following are the steps we need to take in order to create the document transport style for our web service:
BookLibraryImpl.java
class file in JDeveloper.@WebService(name = "BookLibrary", serviceName = "BookLibraryService", portName = "BookLibraryPort")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
public class BookLibraryImpl implements BookLibrary {
In a nutshell, document transport or document style (according to the style
attribute) means that the whole interaction between clients and the web service is performed through the XML documents. The XML documents are based on the schemas behind, and present the whole entity such as Member
, Book
, Order
, and Payment
. The XML document enables high interoperability because the content is self-explanatory, based on the schemas, and there is no need to perform any additional validation rules. Also, XML is technology-neutral, and we can process the XML content on any platform or programming language.
As we talk about interoperability, the important aspect of web service lifecycle presents maintenance period. When a change in the data occurs, only a change in the schema needs to be performed and no other change is needed. When using document transport, the information from the client comes to the web service in a structured way. It is easy for a web service to transform such data and perform various validation rules on top of incoming data.
Now look at the result of the new @SOAPBinding
annotation in our code. In JDeveloper, right-click on the BookLibraryImpl.java
class and select Show WSDL for Web Service Annotations. In the generated WSDL that shows up in JDeveloper, search for the <soap:binding>
tag as follows:
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
We can see that for our service, we will use the document binding style over SOAP/HTTP transport.