⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xfire582test.java

📁 Xfire文件 用于开发web service 的一个开源工具 很好用的
💻 JAVA
字号:
package org.codehaus.xfire.x582;

import javax.xml.namespace.QName;

import org.codehaus.xfire.aegis.AbstractXFireAegisTest;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.jaxws.JAXWSServiceFactory;
import org.codehaus.xfire.service.Endpoint;
import org.codehaus.xfire.service.MessagePartInfo;
import org.codehaus.xfire.service.OperationInfo;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.soap.AbstractSoapBinding;
import org.codehaus.xfire.soap.Soap11Binding;
import org.codehaus.xfire.soap.SoapConstants;
import org.codehaus.xfire.transport.local.LocalTransport;
import org.jdom.Document;

public class XFire582Test extends AbstractXFireAegisTest
{

    private Service service;

    @Override
    protected void setUp()
        throws Exception
    {
        super.setUp();
        
        JAXWSServiceFactory asf = new JAXWSServiceFactory(getTransportManager());
        service = asf.create(CustomXFireNamespaceProblemServiceImpl.class,
                             null,
                             getTestFile("src/wsdl/XFire582.wsdl").toURL(),
                             null);
        
        Soap11Binding binding = new Soap11Binding(new QName("Soap"), 
                                                  LocalTransport.BINDING_ID, 
                                                  service);
        service.addBinding(binding);
        binding.setStyle(SoapConstants.STYLE_WRAPPED);
        binding.setSerializer(AbstractSoapBinding.getSerializer(SoapConstants.STYLE_WRAPPED,
                                                                SoapConstants.USE_LITERAL));
        Endpoint endpoint = new Endpoint(new QName("SoapEndpoint"), 
                                         binding, 
                                         "xfire.local://XFireNamespaceProblemService");
        service.addEndpoint(endpoint);
        
        getServiceRegistry().register(service);
    }

    public void testClient() throws Exception
    {
        XFireNamespaceProblemInterface client = (XFireNamespaceProblemInterface)
            new XFireProxyFactory(getXFire()).create(service, "xfire.local://XFireNamespaceProblemService");
        assertEquals("foo", client.makeCall2());
    }
    
    public void testService() throws Exception
    {
        OperationInfo operation = service.getServiceInfo().getOperation("makeCall");
        
        MessagePartInfo part = (MessagePartInfo) operation.getOutputMessage().getMessageParts().get(0);
        assertTrue(part.isSchemaElement());
        assertEquals("http://test.bt.com/2006/08/Service/Schema", part.getName().getNamespaceURI());
        
        Document res = invokeService("XFireNamespaceProblemService", "/org/codehaus/xfire/x582/callmessage.xml");
        
        addNamespace("b", "http://test.bt.com/2006/08/Service/Schema");
        assertValid("//b:makeCallResponse/b:status", res);
        
        res = invokeService("XFireNamespaceProblemService", "/org/codehaus/xfire/x582/callmessage2.xml");
        
        addNamespace("b", "http://test.bt.com/2006/08/Service/Schema");
        assertValid("//b:makeCall2Response/b:status", res);
    }
}

⌨️ 快捷键说明

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