use of jakarta.xml.ws.Binding in project metro-jax-ws by eclipse-ee4j.
the class WSServletDelegate method doPut.
/**
* Handles HTTP PUT for XML/HTTP binding based endpoints
*
* @param request the HTTP request object
* @param response the HTTP response object
* @param context servlet context
*/
public void doPut(HttpServletRequest request, HttpServletResponse response, ServletContext context) {
// TODO: unify this into doGet.
try {
EndpointAdapter target = getTarget(request);
if (target != null) {
if (logger.isLoggable(Level.FINEST)) {
logger.log(Level.FINEST, "Got request for endpoint {0}", target.getUrlPattern());
}
} else {
writeNotFoundErrorPage(response, "Invalid request");
return;
}
Binding binding = target.getEndpoint().getBinding();
if (binding instanceof HTTPBinding) {
target.handle(context, request, response);
} else {
response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
}
} catch (WebServiceException e) {
logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
} catch (Throwable e) {
logger.log(Level.SEVERE, "caught throwable", e);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
use of jakarta.xml.ws.Binding in project metro-jax-ws by eclipse-ee4j.
the class HttpAdapter method handleGet.
public boolean handleGet(@NotNull WSHTTPConnection connection) throws IOException {
if (connection.getRequestMethod().equals("GET")) {
// metadata query. let the interceptor run
for (Component c : endpoint.getComponents()) {
HttpMetadataPublisher spi = c.getSPI(HttpMetadataPublisher.class);
if (spi != null && spi.handleMetadataRequest(this, connection)) {
return true;
}
// handled
}
if (isMetadataQuery(connection.getQueryString())) {
// Sends published WSDL and schema documents as the default action.
publishWSDL(connection);
return true;
}
Binding binding = getEndpoint().getBinding();
if (!(binding instanceof HTTPBinding)) {
// Writes HTML page with all the endpoint descriptions
writeWebServicesHtmlPage(connection);
return true;
}
} else if (connection.getRequestMethod().equals("HEAD")) {
connection.getInput().close();
Binding binding = getEndpoint().getBinding();
if (isMetadataQuery(connection.getQueryString())) {
SDDocument doc = wsdls.get(connection.getQueryString());
connection.setStatus(doc != null ? HttpURLConnection.HTTP_OK : HttpURLConnection.HTTP_NOT_FOUND);
connection.getOutput().close();
connection.close();
return true;
} else if (!(binding instanceof HTTPBinding)) {
connection.setStatus(HttpURLConnection.HTTP_NOT_FOUND);
connection.getOutput().close();
connection.close();
return true;
}
// Let the endpoint handle for HTTPBinding
}
return false;
}
use of jakarta.xml.ws.Binding 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.Binding 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.Binding 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);
}
Aggregations