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);
}
}
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);
}
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());
}
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);
}
}
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;
}
Aggregations