public void test03() throws Exception { String ns1 = ""; String expectedPkg1 = ""; String pkg = JavaUtils.getPackageFromNamespace(ns1); assertTrue("Expected " + expectedPkg1 + "Received " + pkg, expectedPkg1.equals(pkg)); }
public void test02() throws Exception { String ns1 = "urn://example-org/NewBusiness"; String expectedPkg1 = "org.example"; String pkg = JavaUtils.getPackageFromNamespace(ns1); assertTrue("Expected " + expectedPkg1 + "Received " + pkg, expectedPkg1.equals(pkg)); }
/** * Adds the appropriate properties to the MessageContext that the user will see * * @param soapMessageContext * @param jaxwsMessageContext */ public static void addProperties( SOAPMessageContext soapMessageContext, MessageContext jaxwsMessageContext) { // Copy Axis2 MessageContext properties. It's possible that some set of Axis2 handlers // have run and placed some properties in the context that need to be visible. soapMessageContext.putAll(jaxwsMessageContext.getProperties()); EndpointDescription description = jaxwsMessageContext.getEndpointDescription(); if (description != null) { // Set the WSDL properties ServiceDescription sd = description.getServiceDescription(); if (sd != null) { String wsdlLocation = ((ServiceDescriptionWSDL) sd).getWSDLLocation(); if (wsdlLocation != null && !"".equals(wsdlLocation)) { URI wsdlLocationURI = JavaUtils.createURI(wsdlLocation); if (wsdlLocationURI == null) { log.warn( Messages.getMessage( "addPropertiesErr", wsdlLocation.toString(), description.getServiceQName().toString())); } setProperty( soapMessageContext, javax.xml.ws.handler.MessageContext.WSDL_DESCRIPTION, wsdlLocationURI, true); } setProperty( soapMessageContext, javax.xml.ws.handler.MessageContext.WSDL_SERVICE, description.getServiceQName(), true); } } // Lazily provide a list of available reference parameters. org.apache.axis2.context.MessageContext msgContext = jaxwsMessageContext.getAxisMessageContext(); SOAPHeader header = null; if (msgContext != null && msgContext.getEnvelope() != null) { header = msgContext.getEnvelope().getHeader(); } List<Element> list = new ReferenceParameterList(header); setProperty(soapMessageContext, javax.xml.ws.handler.MessageContext.REFERENCE_PARAMETERS, list); if (log.isDebugEnabled()) { log.debug("Added reference parameter list."); } // If we are running within a servlet container, then JAX-WS requires that the // servlet related properties be set on the MessageContext ServletContext servletContext = (ServletContext) jaxwsMessageContext.getProperty(HTTPConstants.MC_HTTP_SERVLETCONTEXT); if (servletContext != null) { log.debug("Servlet Context Set"); setProperty( soapMessageContext, javax.xml.ws.handler.MessageContext.SERVLET_CONTEXT, servletContext); } else { log.debug("Servlet Context not found"); } HttpServletRequest req = (HttpServletRequest) jaxwsMessageContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST); if (req == null) { if (log.isDebugEnabled()) { log.debug("HTTPServletRequest not found"); } } else { setProperty(soapMessageContext, javax.xml.ws.handler.MessageContext.SERVLET_REQUEST, req); if (log.isDebugEnabled()) { log.debug("SERVLET_REQUEST Set"); } String pathInfo = null; try { pathInfo = req.getPathInfo(); } catch (Throwable t) { log.debug("exception in getPathInfo", t); } setProperty(soapMessageContext, javax.xml.ws.handler.MessageContext.PATH_INFO, pathInfo); if (log.isDebugEnabled()) { if (pathInfo != null) { log.debug("HTTP_REQUEST_PATHINFO Set"); } else { log.debug("HTTP_REQUEST_PATHINFO not found"); } } String queryString = req.getQueryString(); setProperty( soapMessageContext, javax.xml.ws.handler.MessageContext.QUERY_STRING, queryString); if (log.isDebugEnabled()) { if (queryString != null) { log.debug("HTTP_REQUEST_QUERYSTRING Set"); } else { log.debug("HTTP_REQUEST_QUERYSTRING not found"); } } String method = req.getMethod(); setProperty( soapMessageContext, javax.xml.ws.handler.MessageContext.HTTP_REQUEST_METHOD, method); if (log.isDebugEnabled()) { if (method != null) { log.debug("HTTP_REQUEST_METHOD Set"); } else { log.debug("HTTP_REQUEST_METHOD not found"); } } } HttpServletResponse res = (HttpServletResponse) jaxwsMessageContext.getProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE); if (res == null) { if (log.isDebugEnabled()) { log.debug("Servlet Response not found"); } } else { setProperty(soapMessageContext, javax.xml.ws.handler.MessageContext.SERVLET_RESPONSE, res); if (log.isDebugEnabled()) { log.debug("SERVLET_RESPONSE Set"); } } }