My EJB Business interface is as follows:
----------------------------------------
public interface HelloWorldBI{
  String sayHello(int num, String s) throws IOException;
}


My servicemix.xml is as follows:
--------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:sm="http://servicemix.apache.org/config/1.0";
            xmlns:eip="http://servicemix.apache.org/eip/1.0";
            xmlns:http="http://servicemix.apache.org/http/1.0";
            xmlns:jsr181="http://servicemix.apache.org/jsr181/1.0";
            xmlns:my="http://servicemix.apache.org/demo/";>

    <sm:container id="jbi" useMBeanServer="true"
        createMBeanServer="true" dumpStats="true" statsInterval="10">

        <sm:activationSpecs>

            <sm:activationSpec> 
                <sm:component> 
                    <http:component> 
                        <http:endpoints> 
                            <http:endpoint  service="my:ejbHttpBridge" 
                                            role="consumer" 
                                            defaultOperation="echo" 
                                           
locationURI="http://localhost:8192/Service/"; 
                                           
defaultMep="http://www.w3.org/2004/08/wsdl/in-out"; 
                                            soap="true"/> 
                        </http:endpoints> 
                    </http:component> 
                </sm:component> 
            </sm:activationSpec> 

        <sm:activationSpec componentName="ejbHttpBridge"
service="my:ejbHttpBridge">
          <sm:component>
            <bean xmlns="http://xbean.org/schemas/spring/1.0";
class="EjbHttpBridge" >
                <property name="name">
                  <value>1</value>
                </property>
            </bean>
          </sm:component>
        </sm:activationSpec>

            <sm:activationSpec componentName="jsrEjbBC"
service="my:jsrEjbBC" endpoint="jsrEjbBC">
                <sm:component>
                    <jsr181:component>
                        <jsr181:endpoints>
                            <jsr181:endpoint annotations="none"
service="my:jsrEjbEP" endpoint="jsrEjbEP">
                                <jsr181:pojo>
                                    <bean
class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean">
                                        <property name="jndiName"
value="esb-statelessSession-TraderHome"/>
                                        <property name="businessInterface"
value="examples.webservices.basic.statelessSession.HelloWorldBI"/>
                                        <property name="jndiTemplate">
                                            <ref bean="jndiTemplate"/>
                                        </property>
                                        <property
name="lookupHomeOnStartup">
                                            <value>false</value>
                                        </property>
                                    </bean>
                                </jsr181:pojo>
                            </jsr181:endpoint> 
                        </jsr181:endpoints>
                    </jsr181:component>
                </sm:component>
            </sm:activationSpec>

        </sm:activationSpecs>
    </sm:container>

    <!-- bean 
        Other code goes here
    </bean -->

</beans>

My EjbHttpBridge.java is as follows:
-----------------------------------

public class EjbHttpBridge extends TransformComponentSupport implements
MessageExchangeListener{

    protected boolean transform(MessageExchange exchange, NormalizedMessage
in, NormalizedMessage out) throws MessagingException {

        System.out.println("EjbHttpBridge(" + name + ").onMessageExchange01.
exchange.getService() = " + exchange.getService());

        NormalizedMessage copyMessage = exchange.createMessage();
        getMessageTransformer().transform(exchange, in, copyMessage);
        Source content = copyMessage.getContent();
        System.out.println("EjbHttpBridge(" + name + ").onMessageExchange02.
content = " + content);
        String contentString = null;
        if (content instanceof DOMSource){
            contentString = node2XML(((DOMSource) content).getNode());
            System.out.println("EjbHttpBridge(" + name +
").onMessageExchange03. contentString = " + contentString);
        }

        QName qName = new QName("http://servicemix.apache.org/demo/";,
"jsrEjbEP");
        InOut inOut = createInOutExchange(qName, null, null);
        NormalizedMessage normalizedMessageIn = inOut.createMessage();
        normalizedMessageIn.setContent(new StringSource(contentString));
        inOut.setInMessage(normalizedMessageIn);

        System.out.println("EjbHttpBridge(" + name + ").onMessageExchange04.
End");
        sendSync(inOut);
        System.out.println("EjbHttpBridge(" + name + ").onMessageExchange05.
End");

        NormalizedMessage normalizedMessageOut = inOut.getOutMessage();
        NormalizedMessage copyReturnMessage = exchange.createMessage();
        getMessageTransformer().transform(exchange, normalizedMessageOut,
copyReturnMessage);
        Source contentReturn = copyReturnMessage.getContent();
        String contentReturnString = null;
        if (contentReturn instanceof DOMSource){
            contentReturnString = node2XML(((DOMSource)
contentReturn).getNode());
            System.out.println("EjbHttpBridge(" + name +
").onMessageExchange06. contentReturnString = " + contentReturnString);
        }

        out.setContent(new StringSource(contentReturnString));
        System.out.println("EjbHttpBridge(" + name + ").onMessageExchange07.
End");

        return true;
    }

}

My contentString is as follows:
-------------------------------
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
    <env:Header/>
    <env:Body env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>
        <m:sayHello
xmlns:m="http://www.bea.com/servers/wls70/samples/examples/webservices/basic/statelessSession";>
            <intVal xsi:type="xsd:int">4</intVal>
            <string xsi:type="xsd:string">A</string>
        </m:sayHello>
    </env:Body>
</env:Envelope>

Things are fine, and I get contentReturnString as follows:
----------------------------------------------------------
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
    <env:Header/>
    <env:Body env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>
        <m:sayHelloResponse
xmlns:m="http://www.bea.com/servers/wls70/samples/examples/webservices/basic/statelessSession";>
            <result xsi:type="xsd:string">This message brought to you by the
letter A and the number 4</result>
        </m:sayHelloResponse>
    </env:Body>
</env:Envelope>

My servicemix console is as follows:
------------------------------------
EjbHttpBridge(1).onMessageExchange01. exchange.getService() =
{http://servicemix.apache.org/demo/}ejbHttpBridge
EjbHttpBridge(1).onMessageExchange02. content =
[EMAIL PROTECTED]
EjbHttpBridge(1).onMessageExchange03. contentString = <?xml version="1.0"
encoding="UTF-8"?><m:sayHello
xmlns:m="http://www.bea.com/servers/wls70/samples/examples/webservices/basic/statelessSession";
x
mlns:env="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";><intVal
xsi:type="xsd:int">4</intVal><string
xsi:type="xsd:string">A</string></m:sayHello>

EjbHttpBridge(1).onMessageExchange04. End
EjbHttpBridge(1).onMessageExchange05. End
EjbHttpBridge(1).onMessageExchange06. contentReturnString = <?xml
version="1.0" encoding="UTF-8"?><sayHelloResponse
xmlns="http://servicemix.apache.org/demo/";><out
xmlns="http://servicemix.apache.org/demo/";>This message brought to you by
the letter A and the number 4</out></sayHelloResponse>
EjbHttpBridge(1).onMessageExchange07. End

***************************************************

Now, I change my EjbHttpBridge.java as follows:
-----------------------------------------------

public class EjbHttpBridge extends TransformComponentSupport implements
MessageExchangeListener{

    protected boolean transform(MessageExchange exchange, NormalizedMessage
in, NormalizedMessage out) throws MessagingException {

        System.out.println("EjbHttpBridge(" + name + ").onMessageExchange01.
exchange.getService() = " + exchange.getService());

        QName qName = new QName("http://servicemix.apache.org/demo/";,
"jsrEjbEP");
        InOut inOut = createInOutExchange(qName, null, null);
        NormalizedMessage normalizedMessageIn = inOut.createMessage();
        //normalizedMessageIn.setContent(new StringSource(contentString));
        normalizedMessageIn.setProperty("intVal", new Integer(1));
        normalizedMessageIn.setProperty("string", "a");
        inOut.setInMessage(normalizedMessageIn);

        System.out.println("EjbHttpBridge(" + name + ").onMessageExchange04.
End");
        sendSync(inOut);
        System.out.println("EjbHttpBridge(" + name + ").onMessageExchange05.
End");

        NormalizedMessage normalizedMessageOut = inOut.getOutMessage();
        String result = (String) normalizedMessageOut.getProperty("result");

        System.out.println("EjbHttpBridge(" + name + ").result = " +
result);

        out.setContent(new StringSource(result));
        System.out.println("EjbHttpBridge(" + name + ").onMessageExchange07.
End");

        return true;
    }

}

Note:
-----
Now my aim is to EXPLICITELY SET parameters to invoke EJB.

My servicemix console is as follows:
------------------------------------

INFO  - log                            - Started SelectChannelConnector @
localhost:8192
EjbHttpBridge(1).onMessageExchange01. exchange.getService() =
{http://servicemix.apache.org/demo/}ej
bHttpBridge
EjbHttpBridge(1).onMessageExchange04. End
ERROR - Jsr181SpringComponent          - Error processing exchange
MessageExchange[
  id: ID:TVMKVML19213-1603-1149096464047-3:0
  status: Active
  role: provider
  service: {http://servicemix.apache.org/demo/}jsrEjbEP
  endpoint: jsrEjbEP
  in:
]
java.lang.NullPointerException
        at
org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:418)
        at
org.apache.servicemix.jsr181.Jsr181ExchangeProcessor.getXMLStreamReader(Jsr181ExchangeProcessor.java:113)
        at
org.apache.servicemix.jsr181.Jsr181ExchangeProcessor.process(Jsr181ExchangeProcessor.java:78)
        at
org.apache.servicemix.common.BaseLifeCycle.processExchange(BaseLifeCycle.java:390)
        at
org.apache.servicemix.common.BaseLifeCycle$2.run(BaseLifeCycle.java:247)
        at
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPolExecutor.java:650)
        at
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
        at java.lang.Thread.run(Thread.java:595)
EjbHttpBridge(1).onMessageExchange05. End
ERROR - SedaQueue                      -
[EMAIL PROTECTED]
 got error processing MessageExchange[
  id: ID:TVMKVML19213-1603-1149096464047-2:0
  status: Active
  role: provider
  service: {http://servicemix.apache.org/demo/}ejbHttpBridge
  endpoint: ejbHttpBridge
  operation: echo
  in: <?xml version="1.0" encoding="UTF-8"?><m:sayHello
xmlns:m="http://www.bea.com/servers/wls70/sa
mples/examples/webservices/basic/statelessSession"
xmlns:env="http://schemas.xmlsoap.org/soap/envelo
pe/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:xsd="http://www.w3.org/2001/XML
Schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";><intVal
xsi:type="xsd:int">4</intVal><
string xsi:type="xsd:string">A</string></m:sayHello>
]
java.lang.NullPointerException
        at EjbHttpBridge.transform(EjbHttpBridge.java:54)
        at
org.apache.servicemix.components.util.TransformComponentSupport.onMessageExchange(TransformComponentSupport.java:48)
        at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:564)
        at
org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:171)
        at
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:222)
        at
org.apache.geronimo.connector.work.WorkerContext.run(WorkerContext.java:291)
        at
EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:595)

NB:
--

My XML message here is just to trigger the flow, and not for EJB as
parameters. This note is just to avoid confusion.

MY QUERY:
---------
I have seen http://www.nabble.com/Passing+parameters-t1679729.html. Still I
have doubt how to explicitely set parameters and/or operations to invoke an
EJB.
--
View this message in context: 
http://www.nabble.com/How+to+set+parameter+to+invoke+EJB-t1711935.html#a4648284
Sent from the ServiceMix - User forum at Nabble.com.

Reply via email to