You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Karnam, Jayashankar" <Ja...@in.pega.com> on 2014/02/13 10:14:52 UTC

SOAP Over JMS Dynamic Dispatch

Hi Andrei!


I'm in a situation to use Dynamic dispatch for SOAP Over JMS, I have been using one of the samples. Any pointers how to dispatch the soap request dynamically would be really helpful.
Here is the code snippet I'm using
{
Dispatch<SOAPMessage> dispatch = CXFUtils.getDispatch(
                           SOAPBinding.SOAP11HTTP_BINDING,
                           //"jms:jndi:dynamicQueues/test.cxf.jmstransport.queue?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;jndiConnectionFactoryName=ConnectionFactory&amp;jndiURL=tcp://localhost:61616");
                           "jms:jndi:dynamicQueues/test.cxf.jmstransport.queue?jndiInitialContextFactory="
                   + "org.apache.activemq.jndi.ActiveMQInitialContextFactory&jndiConnectionFactoryName="
                   + "ConnectionFactory&jndiURL=tcp://localhost:61616");

              InputStream is = new FileInputStream("C:\\sample2.xml");

               SOAPMessage soapReqMsg = MessageFactory.newInstance().createMessage(null,is);
               dispatch.invoke(soapReqMsg);

}

public static Dispatch<SOAPMessage> getDispatch(String soapBinding,
                     String endpoint) {
              QName serviceName = new QName("", "");
              Service s = Service.create(serviceName);

              QName portName = new QName("", "");

              s.addPort(portName, soapBinding, endpoint);

              Dispatch<SOAPMessage> dispatch = s.createDispatch(portName,
                           SOAPMessage.class, Service.Mode.MESSAGE);
              StringWriter sw = new StringWriter();
              //new Throwable("").printStackTrace(new PrintWriter(sw));
       //     String stackTrace = sw.toString();
              //System.out.println(stackTrace);
              return dispatch;
       }

The XML that is being used here is

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://cxf.apache.org/jms_greeter/types">
<soap:Header/>
<soap:Body>
<typ:greetMe>
<typ:requestType>"red"</typ:requestType>
</typ:greetMe>
</soap:Body>
</soap:Envelope> (SOAP 11 version)

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:typ="http://cxf.apache.org/jms_greeter/types">
   <soap:Header/>
   <soap:Body>
      <typ:greetMe>
         <typ:requestType>"red"</typ:requestType>
      </typ:greetMe>
   </soap:Body>
</soap:Envelope>(SOAP 12)

Are there any other flags that needs to be set in the soap envelope for SOAP over JMS ?


Thanks,
Jay