| JBoss ESB Webservice Producer |
| Written by Mark S. | ||||||
|
The SOAPProcessor action, formerly known as "JBossWSAdapter", allows you to expose JBossWS 2.x and higher Webservice Endpoints through listeners running on the ESB (“SOAP onto the bus”).
A classic JBossESB usecase is one where the ESB is used to expose a Webservice interface for an existing Java based Service that doesn't already expose a Webservice interface. This means that these Services are invocable over any transport channel supported by the ESB (http, ftp, jms etc). Let's see in practice how to use the SOAPProcessor action. If you have downloaded the ESB service bus Let's take a look at the jboss-esb.xml configuration file
<jbossesb
xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd"
parameterReloadSecs="5">
<providers>
<jms-provider name="JBossMQ" connection-factory="ConnectionFactory">
<jms-bus busid="quickstartGwChannel">
<jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_webservice_producer_gw"/>
</jms-bus>
<jms-bus busid="quickstartEsbChannel">
<jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_webservice_producer_esb"/>
</jms-bus>
</jms-provider>
<jbr-provider name="JBR-Http" protocol="http" host="localhost">
<jbr-bus busid="Http-1" port="8765" />
</jbr-provider>
<jbr-provider name="JBR-Socket" protocol="socket" host="localhost">
<jbr-bus busid="Socket-1" port="8888" />
</jbr-provider>
</providers>
<services>
<service category="MyServiceCategory" name="MyWSProducerService" description="WS Frontend speaks natively to the ESB">
<listeners>
<jms-listener name="JMS-Gateway" busidref="quickstartGwChannel" is-gateway="true"/>
<jbr-listener name="Http-Gateway" busidref="Http-1" is-gateway="true"/>
<jbr-listener name="Socket-Gateway" busidref="Socket-1" is-gateway="true"/>
<jms-listener name="JMS-ESBListener" busidref="quickstartEsbChannel"/>
</listeners>
<actions>
<action name="print-before" class="org.jboss.soa.esb.actions.SystemPrintln">
<property name="message"
value="[Quickstart_webservice_producer] BEFORE invoking jbossws endpoint"/>
</action>
<action name="JBossWSAdapter" class="org.jboss.soa.esb.actions.soap.SOAPProcessor">
<property name="jbossws-endpoint" value="GoodbyeWorldWS"/>
</action>
<action name="print-after" class="org.jboss.soa.esb.actions.SystemPrintln">
<property name="message"
value="[Quickstart_webservice_producer] AFTER invoking jbossws endpoint"/>
</action>
<action name="testStore" class="org.jboss.soa.esb.actions.TestMessageStore"/>
</actions>
</service>
</services>
</jbossesb>
Picture 1: JBoss ESB exposing WebServices over http,socket,jms protocols
<action name="JBossWSAdapter" class="org.jboss.soa.esb.actions.soap.SOAPProcessor">
<property name="jbossws-endpoint" value="GoodbyeWorldWS"/>
</action>
@WebService(name = "GoodbyeWorldWS", targetNamespace="http://webservice_producer/goodbyeworld")
public class GoodbyeWorldWS {
@WebMethod
public String sayGoodbye(@WebParam(name="message") String message) {
Message esbMessage = SOAPProcessor.getMessage();
if(esbMessage != null) {
System.out.println("**** SOAPRequest perhaps mediated by ESB:\n" + esbMessage.getBody().get());
}
System.out.println("Web Service Parameter - message=" + message);
return "... Ah Goodbye then!!!! - " + message;
}
@WebMethod
public String sayAdios(String message) {
Message esbMessage = SOAPProcessor.getMessage();
if(esbMessage != null) {
System.out.println("**** SOAPRequest perhaps mediated by ESB:\n" + esbMessage.getBody().get());
}
System.out.println("Web Service Parameter - message=" + message);
return "... Adios Amigo!!!! - " + message;
}
@WebMethod
@Oneway
public void sayGoodbyeWithoutResponse(@WebParam(name="message") String message) {
Message esbMessage = SOAPProcessor.getMessage();
if(esbMessage != null) {
System.out.println("**** SOAPRequest perhaps mediated by ESB:\n" + esbMessage.getBody().get());
}
System.out.println("Web Service Parameter - message=" + message);
}
$ ant deploy
If everything was successful .esb archive is now available and the wsdl archive was generated. Ok now the webservice is deployed but how the client interface knows which protocol can be used to interact with the WebServices ? this problem is solved by the ESB exposing a contract for the webservice. The SOAPProcessor Action publishes contract information by being annotated with the org.jboss.internal.soa.esb.publish.Publish annotation as follows : @Publish(WebserviceContractPublisher.class)
Picture 2: JBoss ESB Contracts console showing the available protocols for WebService endpoints
|
| Comments |
|




Notice : There's one optional property "rewrite-endpoint-url" which is not used in this sample. This property is there to support load balancing on HTTP endpoints, in which case the Webservice endpoint container will have been configured to set the HTTP(S) endpoint address in the WSDL to that of the Load Balancer. 