use of javax.xml.ws.soap.AddressingFeature in project cxf by apache.
the class WSAFaultToClientServerTest method testOneWayFaultTo.
@Test
public void testOneWayFaultTo() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
QName serviceName = new QName("http://apache.org/hello_world_soap_http", "SOAPServiceAddressing");
Greeter greeter = new SOAPService(wsdl, serviceName).getPort(Greeter.class, new AddressingFeature());
EndpointReferenceType faultTo = new EndpointReferenceType();
AddressingProperties addrProperties = new AddressingProperties();
AttributedURIType epr = new AttributedURIType();
String faultToAddress = "http://localhost:" + FaultToEndpointServer.FAULT_PORT + "/faultTo";
epr.setValue(faultToAddress);
faultTo.setAddress(epr);
addrProperties.setFaultTo(faultTo);
BindingProvider provider = (BindingProvider) greeter;
Map<String, Object> requestContext = provider.getRequestContext();
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + FaultToEndpointServer.PORT + "/jaxws/greeter");
requestContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, addrProperties);
greeter.greetMeOneWay("test");
// wait for the fault request
int i = 2;
while (HelloHandler.getFaultRequestPath() == null && i > 0) {
Thread.sleep(500);
i--;
}
assertTrue("FaultTo request fpath isn't expected", "/faultTo".equals(HelloHandler.getFaultRequestPath()));
}
use of javax.xml.ws.soap.AddressingFeature in project cxf by apache.
the class WSAFromWSDLTest method getPort.
private AddNumbersPortTypeProxy 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);
AddNumbersPortTypeProxy port = service.getAddNumbersPort(new AddressingFeature());
updateAddressPort(port, PORT);
return port;
}
use of javax.xml.ws.soap.AddressingFeature in project cxf by apache.
the class JaxWsServiceFactoryBean method loadWSFeatureAnnotation.
private void loadWSFeatureAnnotation(Class<?> serviceClass, Class<?> implementorClass) {
List<WebServiceFeature> features = new ArrayList<>();
MTOM mtom = implInfo.getImplementorClass().getAnnotation(MTOM.class);
if (mtom == null && serviceClass != null) {
mtom = serviceClass.getAnnotation(MTOM.class);
}
if (mtom != null) {
features.add(new MTOMFeature(mtom.enabled(), mtom.threshold()));
} else {
// deprecated way to set mtom
BindingType bt = implInfo.getImplementorClass().getAnnotation(BindingType.class);
if (bt != null && (SOAPBinding.SOAP11HTTP_MTOM_BINDING.equals(bt.value()) || SOAPBinding.SOAP12HTTP_MTOM_BINDING.equals(bt.value()))) {
features.add(new MTOMFeature(true));
}
}
Addressing addressing = null;
if (implementorClass != null) {
addressing = implementorClass.getAnnotation(Addressing.class);
}
if (addressing == null && serviceClass != null) {
addressing = serviceClass.getAnnotation(Addressing.class);
}
if (addressing != null) {
features.add(new AddressingFeature(addressing.enabled(), addressing.required(), addressing.responses()));
}
RespectBinding respectBinding = implInfo.getImplementorClass().getAnnotation(RespectBinding.class);
if (respectBinding == null && serviceClass != null) {
respectBinding = serviceClass.getAnnotation(RespectBinding.class);
}
if (respectBinding != null) {
features.add(new RespectBindingFeature(respectBinding.enabled()));
}
if (!features.isEmpty()) {
wsFeatures = features;
if (setWsFeatures != null) {
wsFeatures.addAll(setWsFeatures);
}
} else {
wsFeatures = setWsFeatures;
}
}
use of javax.xml.ws.soap.AddressingFeature in project cxf by apache.
the class WSDiscoveryClient method getDispatchInternal.
private synchronized Dispatch<Object> getDispatchInternal(boolean addSeq, String action) {
if (dispatch == null) {
AddressingFeature f = new AddressingFeature(true, true);
dispatch = getService().createDispatch(version.getServiceName(), getJAXBContext(), Service.Mode.PAYLOAD, f);
dispatch.getRequestContext().put("thread.local.request.context", Boolean.TRUE);
version.addVersionTransformer(dispatch);
}
addAddressing(dispatch, false, action);
return dispatch;
}
use of javax.xml.ws.soap.AddressingFeature in project cxf by apache.
the class SymmetricBindingTest method testUsernameTokenSAML1Dispatch.
@org.junit.Test
public void testUsernameTokenSAML1Dispatch() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = SymmetricBindingTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = SymmetricBindingTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItSymmetricSAML1Port");
Dispatch<DOMSource> dispatch = service.createDispatch(portQName, DOMSource.class, Service.Mode.PAYLOAD, new AddressingFeature());
updateAddressPort(dispatch, test.getPort());
// Setup STSClient
STSClient stsClient = createDispatchSTSClient(bus);
String wsdlLocation = "http://localhost:" + test.getStsPort() + "/SecurityTokenService/UT?wsdl";
stsClient.setWsdlLocation(wsdlLocation);
// Creating a DOMSource Object for the request
DOMSource request = createDOMRequest();
// Make a successful request
Client client = ((DispatchImpl<DOMSource>) dispatch).getClient();
client.getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
if (test.isStreaming()) {
client.getRequestContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
client.getResponseContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
}
DOMSource response = dispatch.invoke(request);
assertNotNull(response);
bus.shutdown(true);
}
Aggregations