Earlier in this book, in the Message validation section of Chapter 3, we described how it is possible to validate the request and response messages of a service by specifying the schema files which describe the XML format of the service request, response, and fault messages. What we didn't tell you at the time is that this same information can be used, by JBoss ESB, to automatically generate a web service endpoint to represent the ESB service (also known as an EBWS).
In order to validate the request and response messages it is necessary to explicitly enable the functionality by specifying the
validate
attribute on the <actions>
element. As the desire to expose an ESB service through a web service is a common requirement, the opposite is true, the web service will be created by default unless it has been explicitly disabled by declaring the webservice
attribute on the <actions>
element to be false
.
The schemas declared in the inXsd
, outXsd
, and faultXsd
attributes of the <actions>
element are used by JBoss ESB to generate a Web Services Description Language (WSDL) definition of the service, where the inXsd
and
outXsd
attributes declare the message body contents of the request and response messages respectively and the faultXsd
attribute declares the message body contents for all of the service fault messages.
JBoss ESB supports two Message Exchange Patterns (MEP) when declaring the service through WSDL, they are:
RequestResponse
OneWay
The choice of MEP is based on the existence of the
outXsd
attribute. If this attribute present then an In-Out MEP will be declared otherwise it will use an In-Only MEP.
The processing of an In-Only web service may be handled in an asynchronous manner, depending entirely on the SOAP stack being used, so that it allows the client invoker to continue without being delayed. An In-Out web service, on the other hand, will always be forced to wait for its response before it can continue.
Now take a look at the contents of the esbcontent/META-INF/jboss-esb.xml
file for the Chapter8
project, the relevant snippet of which is highlighted here:
<service category="Chapter8Sample" description="A template for Chapter8" name="Chapter8Service"> <listeners> <jms-listener busidref="Chapter8EsbChannel" name="Chapter8EsbListener"/> </listeners> <actions mep="RequestResponse" inXsd="BookServiceRequest.xsd" outXsd="BookServiceResponse.xsd"> <action name="esbaction" class="org.jboss.soa.esb.samples.chapter8.MyAction"/> </actions> </service>