Search in sources :

Example 1 with PingMeFault

use of org.apache.hello_world_doc_lit.PingMeFault in project cxf by apache.

the class GreeterImplDoc method pingMe.

public void pingMe() throws PingMeFault {
    FaultDetail faultDetail = new FaultDetail();
    faultDetail.setMajor((short) 2);
    faultDetail.setMinor((short) 1);
    throw new PingMeFault("PingMeFault raised by server", faultDetail);
}
Also used : PingMeFault(org.apache.hello_world_doc_lit.PingMeFault) FaultDetail(org.apache.hello_world_doc_lit.types.FaultDetail)

Example 2 with PingMeFault

use of org.apache.hello_world_doc_lit.PingMeFault in project cxf by apache.

the class JMSClientServerSoap12Test method testGzipEncodingWithJms.

@Test
public void testGzipEncodingWithJms() throws Exception {
    QName serviceName = new QName("http://apache.org/hello_world_doc_lit", "SOAPService8");
    QName portName = new QName("http://apache.org/hello_world_doc_lit", "SoapPort8");
    URL wsdl = getWSDLURL("/wsdl/hello_world_doc_lit.wsdl");
    SOAPService2 service = new SOAPService2(wsdl, serviceName);
    Greeter greeter = markForClose(service.getPort(portName, Greeter.class, cff));
    for (int idx = 0; idx < 5; idx++) {
        greeter.greetMeOneWay("test String");
        String greeting = greeter.greetMe("Milestone-" + idx);
        Assert.assertEquals(new String("Hello Milestone-") + idx, greeting);
        String reply = greeter.sayHi();
        Assert.assertEquals("Bonjour", reply);
        try {
            greeter.pingMe();
            Assert.fail("Should have thrown FaultException");
        } catch (PingMeFault ex) {
            Assert.assertNotNull(ex.getFaultInfo());
        }
    }
}
Also used : PingMeFault(org.apache.hello_world_doc_lit.PingMeFault) QName(javax.xml.namespace.QName) Greeter(org.apache.hello_world_doc_lit.Greeter) SOAPService2(org.apache.hello_world_doc_lit.SOAPService2) URL(java.net.URL) Test(org.junit.Test)

Example 3 with PingMeFault

use of org.apache.hello_world_doc_lit.PingMeFault in project cxf by apache.

the class JMSClientServerSoap12Test method testWSAddressingWithJms.

@Test
public void testWSAddressingWithJms() throws Exception {
    QName serviceName = new QName("http://apache.org/hello_world_doc_lit", "SOAPService8");
    QName portName = new QName("http://apache.org/hello_world_doc_lit", "SoapPort8");
    URL wsdl = getWSDLURL("/wsdl/hello_world_doc_lit.wsdl");
    SOAPService2 service = new SOAPService2(wsdl, serviceName);
    Greeter greeter = markForClose(service.getPort(portName, Greeter.class, cff, new AddressingFeature()));
    for (int idx = 0; idx < 5; idx++) {
        greeter.greetMeOneWay("test String");
        String greeting = greeter.greetMe("Milestone-" + idx);
        Assert.assertEquals(new String("Hello Milestone-") + idx, greeting);
        String reply = greeter.sayHi();
        Assert.assertEquals("Bonjour", reply);
        try {
            greeter.pingMe();
            Assert.fail("Should have thrown FaultException");
        } catch (PingMeFault ex) {
            Assert.assertNotNull(ex.getFaultInfo());
        }
    }
}
Also used : PingMeFault(org.apache.hello_world_doc_lit.PingMeFault) AddressingFeature(javax.xml.ws.soap.AddressingFeature) QName(javax.xml.namespace.QName) Greeter(org.apache.hello_world_doc_lit.Greeter) SOAPService2(org.apache.hello_world_doc_lit.SOAPService2) URL(java.net.URL) Test(org.junit.Test)

Example 4 with PingMeFault

use of org.apache.hello_world_doc_lit.PingMeFault in project cxf by apache.

the class MultiTransportClientServerTest method testMultiTransportInOneService.

@Test
public void testMultiTransportInOneService() throws Exception {
    QName portName1 = new QName("http://apache.org/hello_world_doc_lit", "HttpPort");
    QName portName2 = new QName("http://apache.org/hello_world_doc_lit", "JMSPort");
    URL wsdl = getClass().getResource("/wsdl/hello_world_doc_lit.wsdl");
    Assert.assertNotNull(wsdl);
    MultiTransportService service = new MultiTransportService(wsdl, serviceName);
    String response1 = new String("Hello Milestone-");
    String response2 = new String("Bonjour");
    Greeter greeter = service.getPort(portName1, Greeter.class);
    TestUtil.updateAddressPort(greeter, PORT);
    for (int idx = 0; idx < 5; idx++) {
        String greeting = greeter.greetMe("Milestone-" + idx);
        Assert.assertNotNull("no response received from service", greeting);
        String exResponse = response1 + idx;
        Assert.assertEquals(exResponse, greeting);
        String reply = greeter.sayHi();
        Assert.assertNotNull("no response received from service", reply);
        Assert.assertEquals(response2, reply);
        try {
            greeter.pingMe();
            Assert.fail("Should have thrown FaultException");
        } catch (PingMeFault ex) {
            Assert.assertNotNull(ex.getFaultInfo());
        }
    }
    ((java.io.Closeable) greeter).close();
    greeter = null;
    greeter = service.getPort(portName2, Greeter.class, cff);
    for (int idx = 0; idx < 5; idx++) {
        String greeting = greeter.greetMe("Milestone-" + idx);
        Assert.assertNotNull("no response received from service", greeting);
        String exResponse = response1 + idx;
        Assert.assertEquals(exResponse, greeting);
        String reply = greeter.sayHi();
        Assert.assertNotNull("no response received from service", reply);
        Assert.assertEquals(response2, reply);
        try {
            greeter.pingMe();
            Assert.fail("Should have thrown FaultException");
        } catch (PingMeFault ex) {
            Assert.assertNotNull(ex.getFaultInfo());
        }
    }
    ((java.io.Closeable) greeter).close();
}
Also used : PingMeFault(org.apache.hello_world_doc_lit.PingMeFault) QName(javax.xml.namespace.QName) Greeter(org.apache.hello_world_doc_lit.Greeter) URL(java.net.URL) Endpoint(javax.xml.ws.Endpoint) MultiTransportService(org.apache.hello_world_doc_lit.MultiTransportService) Test(org.junit.Test)

Example 5 with PingMeFault

use of org.apache.hello_world_doc_lit.PingMeFault in project cxf by apache.

the class XMLFaultOutInterceptorTest method testFault.

@Test
public void testFault() throws Exception {
    FaultDetail detail = new FaultDetail();
    detail.setMajor((short) 2);
    detail.setMinor((short) 1);
    PingMeFault fault = new PingMeFault("TEST_FAULT", detail);
    XMLFault xmlFault = XMLFault.createFault(new Fault(fault));
    Element el = xmlFault.getOrCreateDetail();
    JAXBContext ctx = JAXBContext.newInstance(FaultDetail.class);
    Marshaller m = ctx.createMarshaller();
    m.marshal(detail, el);
    OutputStream outputStream = new ByteArrayOutputStream();
    xmlMessage.setContent(OutputStream.class, outputStream);
    XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(outputStream);
    xmlMessage.setContent(XMLStreamWriter.class, writer);
    xmlMessage.setContent(Exception.class, xmlFault);
    out.handleMessage(xmlMessage);
    outputStream.flush();
    XMLStreamReader reader = getXMLReader();
    DepthXMLStreamReader dxr = new DepthXMLStreamReader(reader);
    dxr.nextTag();
    StaxUtils.toNextElement(dxr);
    assertEquals(XMLConstants.NS_XML_FORMAT, dxr.getNamespaceURI());
    assertEquals(XMLFault.XML_FAULT_ROOT, dxr.getLocalName());
    dxr.nextTag();
    StaxUtils.toNextElement(dxr);
    assertEquals(XMLFault.XML_FAULT_STRING, dxr.getLocalName());
    assertEquals(fault.toString(), dxr.getElementText());
    dxr.nextTag();
    StaxUtils.toNextElement(dxr);
    assertEquals(XMLFault.XML_FAULT_DETAIL, dxr.getLocalName());
    dxr.nextTag();
    StaxUtils.toNextElement(dxr);
    assertEquals("faultDetail", dxr.getLocalName());
}
Also used : PingMeFault(org.apache.hello_world_doc_lit.PingMeFault) Marshaller(javax.xml.bind.Marshaller) XMLStreamReader(javax.xml.stream.XMLStreamReader) DepthXMLStreamReader(org.apache.cxf.staxutils.DepthXMLStreamReader) XMLFault(org.apache.cxf.binding.xml.XMLFault) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) FaultDetail(org.apache.hello_world_doc_lit.types.FaultDetail) Element(org.w3c.dom.Element) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) XMLFault(org.apache.cxf.binding.xml.XMLFault) Fault(org.apache.cxf.interceptor.Fault) PingMeFault(org.apache.hello_world_doc_lit.PingMeFault) JAXBContext(javax.xml.bind.JAXBContext) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DepthXMLStreamReader(org.apache.cxf.staxutils.DepthXMLStreamReader) Test(org.junit.Test)

Aggregations

PingMeFault (org.apache.hello_world_doc_lit.PingMeFault)8 Test (org.junit.Test)6 URL (java.net.URL)5 QName (javax.xml.namespace.QName)5 Greeter (org.apache.hello_world_doc_lit.Greeter)5 SOAPService2 (org.apache.hello_world_doc_lit.SOAPService2)4 Endpoint (javax.xml.ws.Endpoint)3 FaultDetail (org.apache.hello_world_doc_lit.types.FaultDetail)3 Closeable (java.io.Closeable)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStream (java.io.OutputStream)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)1 AddressingFeature (javax.xml.ws.soap.AddressingFeature)1 TibcoSoapActionInterceptor (org.apache.cxf.binding.soap.interceptor.TibcoSoapActionInterceptor)1 XMLFault (org.apache.cxf.binding.xml.XMLFault)1 Client (org.apache.cxf.endpoint.Client)1 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)1