use of jakarta.xml.ws.BindingProvider in project metro-jax-ws by eclipse-ee4j.
the class HandlerClient method testLogicalGetSourceOnly.
/*
* Test removes the static handler and adds a logical
* handler that uses JAXB to change the message.
*/
// public void testLogicalJAXB() throws Exception {
// Hello stub = createStub();
// Binding binding = ((BindingProvider) stub).getBinding();
//
// LogicalTestHandler handler = new LogicalTestHandler();
// handler.setHandleMode(LogicalTestHandler.HandleMode.JAXB);
// List<Handler> handlerChain = new ArrayList<Handler>();
// handlerChain.add(handler);
// binding.setHandlerChain(handlerChain);
//
//
// int x = 1;
// int diff = 4; // 2 per handler invoked
//
// int y = stub.hello(x);
// assertEquals(x+diff, y); // x+4 with all handlers
// }
/*
* Test removes the static handler and adds a logical
* handler that gets the source but does not change it.
*/
public void testLogicalGetSourceOnly() throws Exception {
Hello stub = createStub();
Binding binding = ((BindingProvider) stub).getBinding();
LogicalTestHandler handler = new LogicalTestHandler();
handler.setHandleMode(LogicalTestHandler.HandleMode.SOURCE_NO_CHANGE);
List<Handler> handlerChain = new ArrayList<Handler>();
handlerChain.add(handler);
binding.setHandlerChain(handlerChain);
int x = 1;
// 2 per handler invoked
int diff = 2;
int y = stub.hello(x);
assertEquals(x + diff, y);
}
use of jakarta.xml.ws.BindingProvider in project metro-jax-ws by eclipse-ee4j.
the class HandlerClient method testLogicalSource.
/*
* Test removes the static handler and adds a logical
* handler that uses a Source to change the message.
*/
public void testLogicalSource() throws Exception {
Hello stub = createStub();
Binding binding = ((BindingProvider) stub).getBinding();
LogicalTestHandler handler = new LogicalTestHandler();
handler.setHandleMode(LogicalTestHandler.HandleMode.SOURCE);
List<Handler> handlerChain = new ArrayList<Handler>();
handlerChain.add(handler);
binding.setHandlerChain(handlerChain);
int x = 1;
// 2 per handler invoked
int diff = 4;
int y = stub.hello(x);
// x+4 with all handlers
assertEquals(x + diff, y);
}
use of jakarta.xml.ws.BindingProvider in project metro-jax-ws by eclipse-ee4j.
the class HandlerClient method testDynamic1.
/*
* Test tries to add a handler programmatically after clearing
* handlers out of the service. Adds handler to binding. Uses
* an empty handler resolver for clearing the service.
*/
public void testDynamic1() throws Exception {
Hello_Service service = createService();
service.setHandlerResolver(new HandlerResolver() {
public List<Handler> getHandlerChain(PortInfo info) {
return new ArrayList<Handler>();
}
});
Hello stub = createStub(service);
int x = 1;
// 2 per handler invoked
int diff = 2;
int y = stub.hello(x);
assertTrue(y == x + diff);
// now add client handler
List<Handler> handlerList = new ArrayList<Handler>();
handlerList.add(new SOAPTestHandler());
Binding binding = ((BindingProvider) stub).getBinding();
binding.setHandlerChain(handlerList);
// test again
diff = 4;
y = stub.hello(x);
assertTrue(y == x + diff);
}
use of jakarta.xml.ws.BindingProvider in project metro-jax-ws by eclipse-ee4j.
the class HandlerClient method testSOAP12Binding1.
/*
* The normal tests in this file are for soap 1.1. This is a soap 1.2
* test to make sure that the port is created with the proper binding
* so that the proper handlers are called. See bug 6353179.
*
* Not working right now -- can't get endpoint to work.
*/
public void testSOAP12Binding1() throws Exception {
Hello_Service service = createService();
Hello12 stub = create12Stub(service);
// make sure port is working
int x = 1;
// server handler only
int diff = 2;
int y = stub.hello12(x);
assertEquals(x + diff, y);
Binding binding = ((BindingProvider) stub).getBinding();
List<Handler> handlers = binding.getHandlerChain();
assertEquals("should be 1 handler in chain", 1, handlers.size());
Handler handler = handlers.get(0);
assertTrue("handler should be type Port12Handler, not " + handler.getClass().toString(), handler instanceof Port12Handler);
Port12Handler p12h = (Port12Handler) handler;
p12h.resetCalled();
stub.hello12(2);
assertEquals("handler should have been called two times", 2, p12h.getCalled());
}
use of jakarta.xml.ws.BindingProvider in project metro-jax-ws by eclipse-ee4j.
the class ClientTest method test.
public void test() throws SOAPException, IOException {
// -- TEST different SOAPACTION properties in RequestContext
File file = new File("testcases/externalmetadata/fromjava/client/external-wsdl-customization-client.xml");
WebServiceFeature feature = ExternalMetadataFeature.builder().addFiles(file).build();
FAKENAME port = new EchoImplService().getFAKENAMEPort(feature);
Map<String, Object> requestContext = ((BindingProvider) port).getRequestContext();
// THIS next line is causing the SOAPACTION http header to go blank, if fix JAX_WS-1049 not applied ...
requestContext.keySet();
port.doSomething();
// -- TEST dispatch: http://java.net/jira/browse/JAX_WS-1014 : Bug <12883765>
String jaxwsMsg = "<?xml version='1.0' encoding='UTF-8'?>" + "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\">" + "<S:Body><doSomething xmlns=\"overriden-target-namespace\"/></S:Body></S:Envelope>";
EchoImplService service = new EchoImplService();
Dispatch<SOAPMessage> dispatch = service.createDispatch(new QName("overriden-target-namespace", "FAKE-NAMEPort"), SOAPMessage.class, Service.Mode.MESSAGE);
Map<String, List> headersMap = new HashMap<String, List>();
headersMap.put("X-ExampleHeader2", Collections.singletonList("Value"));
Map<String, Object> context = dispatch.getRequestContext();
context.put(MessageContext.HTTP_REQUEST_HEADERS, headersMap);
context.put(SOAPACTION_USE_PROPERTY, Boolean.TRUE);
MimeHeaders mhs = new MimeHeaders();
mhs.addHeader("My-Content-Type", "text/xml");
mhs.addHeader("SOAPAction", "overridenInputAction");
SOAPMessage msg = MessageFactory.newInstance().createMessage(mhs, new ByteArrayInputStream(jaxwsMsg.getBytes()));
dispatch.invoke(msg);
}
Aggregations