use of org.glassfish.webservices.monitoring.Endpoint in project Payara by payara.
the class EjbWebServiceServlet method service.
@Override
protected void service(HttpServletRequest hreq, HttpServletResponse hresp) throws ServletException, IOException {
String requestUriRaw = hreq.getRequestURI();
String requestUri = (requestUriRaw.charAt(0) == '/') ? requestUriRaw.substring(1) : requestUriRaw;
String query = hreq.getQueryString();
WebServiceEjbEndpointRegistry wsejbEndpointRegistry = (WebServiceEjbEndpointRegistry) Globals.getDefaultHabitat().getService(WSEjbEndpointRegistry.class);
EjbRuntimeEndpointInfo ejbEndpoint = wsejbEndpointRegistry.getEjbWebServiceEndpoint(requestUri, hreq.getMethod(), query);
if (requestUri.contains(WebServiceEndpoint.PUBLISHING_SUBCONTEXT) && ejbEndpoint == null) {
requestUri = requestUri.substring(0, requestUri.indexOf(WebServiceEndpoint.PUBLISHING_SUBCONTEXT) - 1);
ejbEndpoint = wsejbEndpointRegistry.getEjbWebServiceEndpoint(requestUri, hreq.getMethod(), query);
}
if (ejbEndpoint != null) {
/*
* We can actually assert that ejbEndpoint is != null,
* because this EjbWebServiceServlet would not have been
* invoked otherwise
*/
String scheme = hreq.getScheme();
WebServiceEndpoint wse = ejbEndpoint.getEndpoint();
if ("http".equals(scheme) && wse.isSecure()) {
// redirect to correct protocol scheme if needed
logger.log(Level.WARNING, LogUtils.INVALID_REQUEST_SCHEME, new Object[] { wse.getEndpointName(), "https", scheme });
URL url = wse.composeEndpointAddress(new WsUtil().getWebServerInfoForDAS().getWebServerRootURL(true));
StringBuilder sb = new StringBuilder(url.toExternalForm());
if (query != null && query.trim().length() > 0) {
sb.append("?");
sb.append(query);
}
hresp.sendRedirect(hresp.encodeRedirectURL(sb.toString()));
} else {
boolean dispatch = true;
// check if it is a tester servlet invocation
if ("Tester".equalsIgnoreCase(query) && (!(HTTPBinding.HTTP_BINDING.equals(wse.getProtocolBinding())))) {
Endpoint endpoint = WebServiceEngineImpl.getInstance().getEndpoint(hreq.getRequestURI());
if ((endpoint.getDescriptor().isSecure()) || (endpoint.getDescriptor().getMessageSecurityBinding() != null)) {
String message = endpoint.getDescriptor().getWebService().getName() + "is a secured web service; Tester feature is not supported for secured services";
(new WsUtil()).writeInvalidMethodType(hresp, message);
return;
}
if (Boolean.parseBoolean(endpoint.getDescriptor().getDebugging())) {
dispatch = false;
WebServiceTesterServlet.invoke(hreq, hresp, endpoint.getDescriptor());
}
}
if ("wsdl".equalsIgnoreCase(query) && (!(HTTPBinding.HTTP_BINDING.equals(wse.getProtocolBinding())))) {
if (wse.getWsdlExposed() != null && !Boolean.parseBoolean(wse.getWsdlExposed())) {
hresp.sendError(HttpServletResponse.SC_NOT_FOUND);
}
}
if (dispatch) {
RequestTraceSpan span = null;
try {
if (requestTracing.isRequestTracingEnabled()) {
span = constructWsRequestSpan(hreq, ejbEndpoint);
}
dispatchToEjbEndpoint(hreq, hresp, ejbEndpoint);
} finally {
if (requestTracing.isRequestTracingEnabled() && span != null) {
requestTracing.traceSpan(span);
}
}
}
}
} else {
hresp.sendError(HttpServletResponse.SC_NOT_FOUND);
}
}
use of org.glassfish.webservices.monitoring.Endpoint in project Payara by payara.
the class JAXWSServlet method doGet.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (("Tester".equalsIgnoreCase(request.getQueryString())) && (!(HTTPBinding.HTTP_BINDING.equals(endpoint.getProtocolBinding())))) {
Endpoint endpt = wsEngine_.getEndpoint(request.getServletPath());
if ((endpt != null) && ((endpt.getDescriptor().isSecure()) || (endpt.getDescriptor().getMessageSecurityBinding() != null) || endpoint.hasSecurePipeline())) {
String message = endpt.getDescriptor().getWebService().getName() + "is a secured web service; Tester feature is not supported for secured services";
(new WsUtil()).writeInvalidMethodType(response, message);
return;
}
if (endpt != null && Boolean.parseBoolean(endpt.getDescriptor().getDebugging())) {
WebServiceTesterServlet.invoke(request, response, endpt.getDescriptor());
return;
}
}
if (!("WSDL".equalsIgnoreCase(request.getQueryString())) && (HTTPBinding.HTTP_BINDING.equals(endpoint.getProtocolBinding()))) {
doPost(request, response);
return;
}
// normal WSDL retrieval invocation
try {
ServletAdapter targetEndpoint = (ServletAdapter) getEndpointFor(request);
if (targetEndpoint != null && wsdlExposed) {
targetEndpoint.publishWSDL(getServletContext(), request, response);
} else {
String message = "Invalid wsdl request " + request.getRequestURL();
(new WsUtil()).writeInvalidMethodType(response, message);
}
} catch (Throwable t) {
ServletException se = new ServletException();
se.initCause(t);
throw se;
}
}
use of org.glassfish.webservices.monitoring.Endpoint in project Payara by payara.
the class JAXWSServlet method doPost.
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException {
startedEvent(endpoint.getEndpointAddressPath());
if (("Tester".equalsIgnoreCase(request.getQueryString())) && (!(HTTPBinding.HTTP_BINDING.equals(endpoint.getProtocolBinding())))) {
Endpoint endpt = wsEngine_.getEndpoint(request.getServletPath());
if (endpt != null && Boolean.parseBoolean(endpt.getDescriptor().getDebugging())) {
WebServiceTesterServlet.invoke(request, response, endpt.getDescriptor());
endedEvent(endpoint.getEndpointAddressPath());
return;
}
}
// lookup registered URLs and get the appropriate adapter;
// pass control to the adapter
RequestTraceSpan span = null;
try {
ServletAdapter targetEndpoint = (ServletAdapter) getEndpointFor(request);
if (targetEndpoint != null) {
if (requestTracing.isRequestTracingEnabled()) {
span = constructWsRequestSpan(request, targetEndpoint.getAddress());
}
targetEndpoint.handle(getServletContext(), request, response);
} else {
throw new ServletException("Service not found");
}
} catch (Throwable t) {
ServletException se = new ServletException();
se.initCause(t);
throw se;
} finally {
if (requestTracing.isRequestTracingEnabled() && span != null) {
requestTracing.traceSpan(span);
}
}
endedEvent(endpoint.getEndpointAddressPath());
}
Aggregations