3 Replies Latest reply on Jun 12, 2009 1:34 PM by Sai Ari

    Initial code for publishing web service as web service

    Jim Ma Apprentice

      Hi all ,
      I wrote the initial code for publishing esb service as web service and committed into my branch(https://svn.labs.jboss.org/labs/jbossesb/workspace/jimma/) for your review. There is also a sample named helloworld_pub_service in quickstarts directory for it .
      When execute "ant deploy" under quickstarts/helloworld_pub_service , jboss will spit up these deployment message :

      17:43:33,000 INFO [JBoss4ESBDeployer] create esb service, Quickstart_helloworld_pub_service.esb
      
      17:43:33,035 INFO [QueueService] Queue[/queue/quickstart_helloworld_Request_esb] started, fullSize=200000, pageSize=2000, downCacheSize=2000
      
      17:43:33,041 INFO [QueueService] Queue[/queue/quickstart_helloworld_Request_gw] started, fullSize=200000, pageSize=2000, downCacheSize=2000
      
      17:43:33,362 INFO [JDBCDataStore] Generated token 'authToken:DB3B49D0-379A-11DD-BD9B-D7235840313A' for user: 'jbossesb/JBoss ESB User'
      
      17:43:33,383 INFO [JDBCDataStore] Generated token 'authToken:DB3E5710-379A-11DD-BD9B-9B9F5C506F1D' for user: 'jbossesb/JBoss ESB User'
      
      17:43:33,477 INFO [QuartzScheduler] Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
      
      17:43:38,606 INFO [DefaultEndpointRegistry] register: jboss.ws:context=firstserviceesb-simplelistener,endpoint=SimpleListener
      
      17:43:38,625 INFO [TomcatDeployer] deploy, ctxPath=/firstserviceesb-simplelistener, warUrl=.../tmp/deploy/tmp33655firstserviceesb-simplelistener-exp.war/
      
      17:43:39,206 INFO [WSDLFilePublisher] WSDL published to: file:/project/jbossesb/workspace/jimma/product/build/jbossesb-server-4.3.GA/server/default/data/wsdl/firstserviceesb-simplelistener.war/firstserviceesb_simplelistener.wsdl
      


      when run "ant runtest" , the SOAP message will be passed into ESB service and be printed by SystemPrintln action :

      17:46:39,815 INFO [STDOUT] &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
      
      17:46:39,815 INFO [STDOUT] Body: org.jboss.ws.core.soap.SOAPBodyImpl@1b50891[[soapenv:Body: null]]
      
      17:46:39,815 INFO [STDOUT] &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
      
      context: [ ]
      
      body: [ objects: {org.jboss.soa.esb.message.defaultEntry=org.jboss.ws.core.soap.SOAPBodyImpl@1b50891[[soapenv:Body: null]]} ]
      
      fault: [ ]
      
      attachments: [ Named:{}, Unnamed:[] ]
      
      properties: [ {org.jboss.soa.esb.message.time.dod=Wed Jun 11 17:46:39 CST 2008, org.jboss.soa.esb.message.time.dob=Deferred serialized value: 1b6847a, org.jboss.soa.esb.message.source=Deferred serialized value: 1b36a91, org.jboss.soa.esb.message.transport.type=Deferred serialized value: 196d07, javax.jms.message.redelivered=false} ] ]


      When this sample is deployed , the ESB server will firstly generate wsdl , jaxws dispatch provider class and web.xml used to deploy it as a web service , then packaged the generated artifacts into a war file and deploy it as a web service in ESB server .

      This is the generated jaxws dispatch provider class :

      package org.jboss.soa;
      @javax.xml.ws.WebServiceProvider(wsdlLocation="/WEB-INF/wsdl/firstserviceesb_simplelistener.wsdl", serviceName="SimpleListener Service", portName="SimpleListener Port", targetNamespace="http://soa.jboss.org/FirstServiceESB")
      @javax.xml.ws.ServiceMode(value = javax.xml.ws.Service.Mode.MESSAGE)
      public class SimpleListener implements javax.xml.ws.Provider {
       public Object invoke(Object obj) {
       javax.xml.soap.SOAPMessage request = (javax.xml.soap.SOAPMessage)obj;
       try {
       org.jboss.soa.esb.client.ServiceInvoker serviceInvoker = new org.jboss.soa.esb.client.ServiceInvoker("FirstServiceESB", "SimpleListener");
       org.jboss.soa.esb.message.Message msg = org.jboss.soa.esb.message.format.MessageFactory.getInstance().getMessage();
       msg.getBody().add(request.getSOAPBody().toString());
       org.jboss.soa.esb.message.Message resMsg = serviceInvoker.deliverSync(msg, (long)20000);
       } catch (Exception e) {
       e.printStackTrace();
       }
       return request;
       }
      }


      So far the dispatch provider simply pass the soap message into the esb service using ServiceInvoker and return this soap request as response. I will polish it later . and also make it support two way message and fault message . These are my initial codes and thoughts for publishing esb service as web service. Your thoughts and comments for it would be appreciated.