java - SOAP Server-Push with TomCat, CXF, Atmosphere over Websockets -


my application needs send , receive soap messages using websockets. of time client (written in python) talks server (java) in simple request-response pattern working.

sometimes, if client updates data in centralized database managed server, other clients should notified updated data or other kind of notifcation happend (broadcast)

my current stack consists of following technologies:

  • server written in java
  • client written in python 3.4
  • tomcat 8.5.12
  • apache cxf 3.1.10
  • atmosphere 2.4.9

the stack can changed, except following:

  • the languages server , client written in
  • the messages transferred need soap
  • tomcat servlet manager
  • websockets can changed long-polling if it's not possible otherwise.

talking server in request-response pattern working. however, don't know how server push working. played around @websocketprocessorservice, @managedservice, @atmosphereresourcelistenerservice listed within atmosphere wiki. either have access plain message no automatic soap handling, or other way around. using annotations @broadcast did not have effect within sample.serverendpoint. examples found on wiki or other blogs working on plain websockets handle messages , returning plain strings.

i thankfull example following features:

  • one service method working in simple request-response pattern (like below, working)
  • one service method returns normal reponse starts broadcast clients (in - or excluding 1 calling method) on condition (e.g. update variable successfull or not)

my current status:

web.xml (server)

<?xml version="1.0" encoding="iso-8859-1"?> <!doctype web-app     public "-//sun microsystems, inc.//dtd web application 2.3//en"     "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app>   <description>atmosphereservlet</description>   <display-name>atmosphereservlet</display-name>   <servlet>     <description>atmosphereservlet</description>     <servlet-name>atmosphereservlet</servlet-name>     <servlet-class>org.atmosphere.cpr.atmosphereservlet</servlet-class>     <!-- if want use servlet 3.0 -->     <async-supported>true</async-supported>   </servlet>   <servlet-mapping>     <servlet-name>atmosphereservlet</servlet-name>     <url-pattern>/*</url-pattern>   </servlet-mapping> </web-app> 

atmosphere.xml (server)

<atmosphere-handlers>     <atmosphere-handler support-session="false"                     context-root="/*"                     class-name="org.atmosphere.handler.reflectorservletprocessor">         <property name="servletclassname"               value="sample.serverservlet"/>     </atmosphere-handler> </atmosphere-handlers> 

sample.serverservlet.java (server)

package sample;  import org.apache.cxf.bus; import org.apache.cxf.busfactory;  import javax.servlet.servletconfig; import javax.xml.ws.endpoint;  public class serverservlet extends org.apache.cxf.transport.servlet.cxfservlet {      private static final long serialversionuid = 1l;      @override     public void loadbus(servletconfig servletconfig) {         super.loadbus(servletconfig);         bus bus = getbus();         busfactory.setdefaultbus(bus);         endpoint.publish("/greetingservice", new serverendpoint());     } } 

sample.serverendpoint.java (server)

package sample;  import javax.jws.webmethod; import javax.jws.webparam; import javax.jws.webservice; import javax.jws.soap.soapbinding; import javax.xml.ws.responsewrapper;  @webservice(name="greetingservice",     targetnamespace="http://sample",     wsdllocation="file:///data/projects/apache-cfx/build/service.wsdl",     servicename="greetingservice") @soapbinding(style=soapbinding.style.rpc) public class serverendpoint {     @responsewrapper(targetnamespace="http://sample/types",                      classname="java.lang.string")     @webmethod(action = "getquote")     public string getquote(@webparam(name="ticker") string ticker,                            @webparam(name="name") string name) {         return "foobar! " + ticker + " - " + name;     } } 


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -