Search in sources :

Example 1 with AddressingFeature

use of javax.xml.ws.soap.AddressingFeature in project cxf by apache.

the class WSADisableTest method testDisableServerEnableClientRequired.

// CXF-3060
@Test
public void testDisableServerEnableClientRequired() throws Exception {
    AddNumbersPortType port = getService().getAddNumbersPort(new AddressingFeature(true, true));
    ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/jaxws/add");
    try {
        port.addNumbers(1, 2);
        fail("Expected missing WSA header exception");
    } catch (Exception e) {
        assertTrue("expected WebServiceException", e instanceof WebServiceException);
        String expected = "A required header representing a Message Addressing" + " Property is not present";
        assertTrue("Caught unexpected exception : " + e.getMessage(), e.getMessage().indexOf(expected) > -1);
    }
}
Also used : AddNumbersPortType(org.apache.cxf.systest.ws.addr_feature.AddNumbersPortType) AddressingFeature(javax.xml.ws.soap.AddressingFeature) WebServiceException(javax.xml.ws.WebServiceException) WebServiceException(javax.xml.ws.WebServiceException) Test(org.junit.Test)

Example 2 with AddressingFeature

use of javax.xml.ws.soap.AddressingFeature in project cxf by apache.

the class WSADisableTest method testDisableAll.

@Test
public void testDisableAll() throws Exception {
    ByteArrayOutputStream input = setupInLogging();
    ByteArrayOutputStream output = setupOutLogging();
    AddNumbersPortType port = getService().getAddNumbersPort(new AddressingFeature(false));
    ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/jaxws/add");
    assertEquals(3, port.addNumbers(1, 2));
    String expectedOut = "http://www.w3.org/2005/08/addressing";
    String expectedIn = "http://www.w3.org/2005/08/addressing";
    assertTrue(output.toString().indexOf(expectedOut) == -1);
    assertTrue(input.toString().indexOf(expectedIn) == -1);
}
Also used : AddNumbersPortType(org.apache.cxf.systest.ws.addr_feature.AddNumbersPortType) AddressingFeature(javax.xml.ws.soap.AddressingFeature) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 3 with AddressingFeature

use of javax.xml.ws.soap.AddressingFeature in project cxf by apache.

the class WSAClientServerTest method getNonAnonPort.

private AddNumbersPortType getNonAnonPort() {
    URL wsdl = getClass().getResource("/wsdl_systest_soap12/add_numbers_soap12.wsdl");
    assertNotNull("WSDL is null", wsdl);
    AddNumbersService service = new AddNumbersService(wsdl, serviceName);
    assertNotNull("Service is null ", service);
    return service.getAddNumbersNonAnonPort(new AddressingFeature());
}
Also used : AddressingFeature(javax.xml.ws.soap.AddressingFeature) WSAddressingFeature(org.apache.cxf.ws.addressing.WSAddressingFeature) URL(java.net.URL)

Example 4 with AddressingFeature

use of javax.xml.ws.soap.AddressingFeature in project cxf by apache.

the class WSAClientServerTest method testDuplicateHeaders.

// CXF-3456
@Test
public void testDuplicateHeaders() throws Exception {
    URL wsdl = getClass().getResource("/wsdl_systest_wsspec/add_numbers.wsdl");
    assertNotNull("WSDL is null", wsdl);
    AddNumbersService service = new AddNumbersService(wsdl, serviceName);
    QName portName = new QName("http://apache.org/cxf/systest/ws/addr_feature/", "AddNumbersPort");
    Dispatch<SOAPMessage> disp = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE, new AddressingFeature(false, false));
    disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/jaxws/add");
    InputStream msgIns = getClass().getResourceAsStream("./duplicate-wsa-header-msg.xml");
    String msg = new String(IOUtils.readBytesFromStream(msgIns));
    msg = msg.replaceAll("$PORT", PORT);
    ByteArrayInputStream bout = new ByteArrayInputStream(msg.getBytes());
    SOAPMessage soapReqMsg = MessageFactory.newInstance().createMessage(null, bout);
    assertNotNull(soapReqMsg);
    try {
        disp.invoke(soapReqMsg);
        fail("SOAPFaultFxception is expected");
    } catch (SOAPFaultException ex) {
        assertTrue("WSA header exception is expected", ex.getMessage().indexOf("A header representing a Message Addressing") > -1);
    }
}
Also used : AddressingFeature(javax.xml.ws.soap.AddressingFeature) WSAddressingFeature(org.apache.cxf.ws.addressing.WSAddressingFeature) ByteArrayInputStream(java.io.ByteArrayInputStream) QName(javax.xml.namespace.QName) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) SOAPMessage(javax.xml.soap.SOAPMessage) URL(java.net.URL) Test(org.junit.Test)

Example 5 with AddressingFeature

use of javax.xml.ws.soap.AddressingFeature in project cxf by apache.

the class WSAClientServerTest method getPort.

private AddNumbersPortType getPort() throws Exception {
    URL wsdl = getClass().getResource("/wsdl_systest_wsspec/add_numbers.wsdl");
    assertNotNull("WSDL is null", wsdl);
    AddNumbersService service = new AddNumbersService(wsdl, serviceName);
    assertNotNull("Service is null ", service);
    AddNumbersPortType port = service.getAddNumbersPort(new AddressingFeature());
    updateAddressPort(port, PORT);
    return port;
}
Also used : AddressingFeature(javax.xml.ws.soap.AddressingFeature) WSAddressingFeature(org.apache.cxf.ws.addressing.WSAddressingFeature) URL(java.net.URL)

Aggregations

AddressingFeature (javax.xml.ws.soap.AddressingFeature)67 BindingProvider (javax.xml.ws.BindingProvider)35 URL (java.net.URL)18 QName (javax.xml.namespace.QName)13 Test (org.junit.Test)13 Service (javax.xml.ws.Service)8 ArrayList (java.util.ArrayList)7 WebServiceFeature (javax.xml.ws.WebServiceFeature)7 MTOMFeature (javax.xml.ws.soap.MTOMFeature)7 MAP (org.jboss.ws.api.addressing.MAP)5 RespectBindingFeature (javax.xml.ws.RespectBindingFeature)4 DispatchImpl (org.apache.cxf.jaxws.DispatchImpl)3 WSAddressingFeature (org.apache.cxf.ws.addressing.WSAddressingFeature)3 SoapFaultPortType (org.jboss.jbossts.xts.soapfault.SoapFaultPortType)3 CoordinationContextHandler (com.jboss.transaction.txinterop.webservices.handlers.CoordinationContextHandler)2 Sc007Service (com.jboss.transaction.wstf.webservices.sc007.generated.Sc007Service)2 WSBinding (com.sun.xml.ws.api.WSBinding)2 ServletAdapterList (com.sun.xml.ws.transport.http.servlet.ServletAdapterList)2 Closeable (java.io.Closeable)2 InputStream (java.io.InputStream)2