jmsqueueexampletest.java

来自「Xfire文件 用于开发web service 的一个开源工具 很好用的」· Java 代码 · 共 49 行

JAVA
49
字号
package org.codehaus.xfire.transport.jms.example;// START SNIPPET: jmsimport java.lang.reflect.Proxy;import org.codehaus.xfire.client.XFireProxy;import org.codehaus.xfire.client.XFireProxyFactory;import org.codehaus.xfire.service.Service;import org.codehaus.xfire.service.binding.ObjectServiceFactory;import org.codehaus.xfire.spring.AbstractXFireSpringTest;import org.codehaus.xfire.test.Echo;import org.codehaus.xfire.transport.jms.JMSTransport;import org.springframework.context.ApplicationContext;import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;public class JMSQueueExampleTest    extends AbstractXFireSpringTest{    protected ApplicationContext createContext()    {        return new ClassPathXmlApplicationContext(new String[] {                "/org/codehaus/xfire/transport/jms/example/jms-queue.xml",                 "/org/codehaus/xfire/spring/xfire.xml" });      }    public void testClient()            throws Exception    {        // Create a ServiceFactory to create the ServiceModel.        // We need to add the JMSTransport to the list of bindings to create.        ObjectServiceFactory sf = new ObjectServiceFactory(getTransportManager());        sf.addSoap11Transport(JMSTransport.BINDING_ID);                // Create the service model        Service serviceModel = sf.create(Echo.class);                // Create a proxy for the service        XFireProxyFactory factory = new XFireProxyFactory(getXFire());        Echo echo = (Echo) factory.create(serviceModel, "jms://GenericQueue?queue=Echo");                // Since JMS doesn't really have a concept of anonymous endpoints, we need        // need to let xfire know what JMS endpoint we should use        ((XFireProxy) Proxy.getInvocationHandler(echo)).getClient().setEndpointUri("jms://Peer1");                // run the client!        String resString = echo.echo("hello");        assertEquals("hello", resString);    }}// END SNIPPET: jms

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?