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

📄 echofaulttest.java

📁 Xfire文件 用于开发web service 的一个开源工具 很好用的
💻 JAVA
字号:
package org.codehaus.xfire.message.wrapped;import org.codehaus.xfire.aegis.AbstractXFireAegisTest;import org.codehaus.xfire.client.XFireProxyFactory;import org.codehaus.xfire.service.Service;import org.codehaus.xfire.service.invoker.ObjectInvoker;import org.codehaus.xfire.soap.SoapConstants;import org.codehaus.xfire.wsdl11.builder.WSDLBuilder;import org.jdom.Document;public class EchoFaultTest    extends AbstractXFireAegisTest{    private Service service;    protected void setUp()        throws Exception    {        super.setUp();                service = getServiceFactory().create(EchoWithFault.class, "EchoWithFault", "urn:xfire:echo", null);        service.setProperty(ObjectInvoker.SERVICE_IMPL_CLASS, EchoWithFaultImpl.class);                getServiceRegistry().register(service);    }    public void testService() throws Exception    {        Document response = invokeService("EchoWithFault", "echoWithFault.xml");        addNamespace("e", "urn:xfire:echo");        addNamespace("f", "http://wrapped.message.xfire.codehaus.org");                assertValid("//detail/e:EchoFault/f:customMessage[text()='yo']", response);    }        public void testClient() throws Exception    {        XFireProxyFactory factory = new XFireProxyFactory(getXFire());        EchoWithFault echo = (EchoWithFault) factory.create(service, "xfire.local://EchoWithFault");                try        {            echo.echo("yo");            fail("Should have thrown custom fault.");        }        catch (EchoFault fault)        {            assertEquals("message", fault.getMessage());            assertEquals("yo", fault.getCustomMessage());        }        catch (Throwable e)        {        }    }        public void testFaultWSDL() throws Exception    {        Document wsdl = getWSDLDocument(service.getSimpleName());        String ns = service.getTargetNamespace();        addNamespace("xsd", SoapConstants.XSD);        addNamespace("w", WSDLBuilder.WSDL11_NS);        addNamespace("ws", WSDLBuilder.WSDL11_SOAP_NS);                assertValid("//xsd:schema[@targetNamespace='" + ns + "']/xsd:element[@name='EchoFault']", wsdl);        assertValid("//w:message[@name='EchoFault']/w:part[@name='EchoFault'][@element='tns:EchoFault']", wsdl);        assertValid("//w:portType[@name='EchoWithFaultPortType']/w:operation[@name='echo']" +                "/w:fault[@name='EchoFault']", wsdl);        assertValid("//w:binding[@name='EchoWithFaultHttpBinding']/w:operation[@name='echo']" +                    "/w:fault[@name='EchoFault']/ws:fault[@name='EchoFault'][@use='literal']", wsdl);    }}

⌨️ 快捷键说明

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