/** Returns user given in SOAP message */ public Principal getUser() { if (MessageContext.getCurrentContext() != null) { String username = MessageContext.getCurrentContext().getUsername(); if ((username != null) && (username.trim().length() >0)) { return new LoginAccount(username, MessageContext.getCurrentContext().getPassword()); } } return LoginAccount.ANONYMOUS; }
public void invoke(MessageContext msgContext) throws AxisFault { log.debug("Enter: URLMapper::invoke"); /** If there's already a targetService then just return. */ if ( msgContext.getService() == null ) { // path may or may not start with a "/". see http://issues.apache.org/jira/browse/AXIS-1372 String path = (String)msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETPATHINFO); if ((path != null) && (path.length() >= 1)) { //rules out the cases of path="", path=null if(path.startsWith("/")) path = path.substring(1); //chop the extra "/" msgContext.setTargetService( path ); } } log.debug("Exit: URLMapper::invoke"); }
private void logMessages(MessageContext msgContext) throws AxisFault { ... msgContext.setResponseMessage(new Message( <strong> stripNonValidXMLCharacters </strong> (((Message) msgContext .getResponseMessage()).getSOAPPartAsString()))); ... }
protected String findConnectionId() { MessageContext context = MessageContext.getCurrentContext(); return (String)context.getProperty(SOAPConstants.CONNECTION_ID_HEADER_NAME); } }
/** * set a fault code string that is turned into a qname * in the SOAP 1.1 or 1.2 namespace, depending on the current context * @param code fault code */ public void setFaultCodeAsString(String code) { SOAPConstants soapConstants = MessageContext.getCurrentContext() == null ? SOAPConstants.SOAP11_CONSTANTS : MessageContext.getCurrentContext().getSOAPConstants(); faultCode = new QName(soapConstants.getEnvelopeURI(), code); }
SOAPService saveService = msgContext.getService(); OperationDesc saveOp = msgContext.getOperation(); Call call = (Call) msgContext.getProperty( MessageContext.CALL ); String url = call.getTargetEndpointAddress(); String cls = url.substring(5); msgContext.setService( null ); msgContext.setOperation( null ); if ( msgContext.getProperty(MessageContext.IS_MSG) == null ) service = new SOAPService(new RPCProvider()); else service.setEngine(msgContext.getAxisEngine()); service.init(); msgContext.setService( service ); msgContext.setService( saveService ); msgContext.setOperation( saveOp );
SecurityProvider provider = (SecurityProvider)msgContext.getProperty(MessageContext.SECURITY_PROVIDER); if (provider == null) { provider = new SimpleSecurityProvider(); msgContext.setProperty(MessageContext.SECURITY_PROVIDER, provider); String userID = msgContext.getUsername(); if (log.isDebugEnabled()) { log.debug( Messages.getMessage("user00", userID) ); null, null ); String passwd = msgContext.getPassword(); if (log.isDebugEnabled()) { log.debug( Messages.getMessage("password00", passwd) ); msgContext.setProperty(MessageContext.AUTHUSER, authUser);
protected OperationDesc getOperationDesc(MessageContext msgContext, RPCElement body) throws SAXException, AxisFault { SOAPService service = msgContext.getService(); ServiceDesc serviceDesc = service.getServiceDescription(); String methodName = body.getMethodName(); OperationDesc operation = msgContext.getOperation(); if (operation == null) { QName qname = new QName(body.getNamespaceURI(), SOAPConstants soapConstants = msgContext == null ? SOAPConstants.SOAP11_CONSTANTS : msgContext.getSOAPConstants(); if (soapConstants == SOAPConstants.SOAP12_CONSTANTS) { AxisFault fault = msgContext.setOperation(operation);
public void createResult(final Object object) { messageContext.setPastPivot(true); try { final Message requestMessage = messageContext.getRequestMessage(); final SOAPEnvelope requestEnvelope = requestMessage.getSOAPEnvelope(); final RPCElement requestBody = getBody(requestEnvelope, messageContext); final Message responseMessage = messageContext.getResponseMessage(); final SOAPEnvelope responseEnvelope = responseMessage.getSOAPEnvelope(); final ServiceDesc serviceDescription = messageContext.getService().getServiceDescription(); final RPCElement responseBody = createResponseBody(requestBody, messageContext, operation, serviceDescription, object, responseEnvelope, getInOutParams()); responseEnvelope.removeBody(); responseEnvelope.addBodyElement(responseBody); } catch (final Exception e) { throw new ServerRuntimeException("Failed while creating response message body", e); } }
public void processReturnedMessageContext(MessageContext context) { cookie = context.getProperty(HTTPConstants.HEADER_COOKIE); cookie2 = context.getProperty(HTTPConstants.HEADER_COOKIE2); } }
private void doVisiting(MessageContext msgContext, HandlerIterationStrategy visitor) throws AxisFault { int i = 0 ; try { Enumeration enumeration = handlers.elements(); while (enumeration.hasMoreElements()) { Handler h = (Handler)enumeration.nextElement(); visitor.visit(h, msgContext); i++; } } catch( AxisFault f ) { // Something went wrong. If we haven't already put this fault // into the MessageContext's response message, do so and make sure // we only do it once. This allows onFault() methods to safely // set headers and such in the response message without them // getting stomped. if (!msgContext.isPropertyTrue(CAUGHTFAULT_PROPERTY)) { // Attach the fault to the response message; enabling access to the // fault details while inside the handler onFault methods. Message respMsg = new Message(f); msgContext.setResponseMessage(respMsg); msgContext.setProperty(CAUGHTFAULT_PROPERTY, Boolean.TRUE); } while( --i >= 0 ) ((Handler) handlers.elementAt( i )).onFault( msgContext ); throw f; } }
public void invoke(MessageContext msgContext) throws AxisFault { log.debug("Enter: EchoHandler::invoke"); try { Message msg = msgContext.getRequestMessage(); SOAPEnvelope env = (SOAPEnvelope) msg.getSOAPEnvelope(); msgContext.setResponseMessage( new Message( env ) ); } catch( Exception e ) { log.error( Messages.getMessage("exception00"), e ); throw AxisFault.makeFault(e); } log.debug("Exit: EchoHandler::invoke"); }
/** * isDotNetSoapEncFixNeeded - Do we need to compensate for the dotnet bug. * check the service specific flag before using the global flag * @return */ private boolean isDotNetSoapEncFixNeeded() { MessageContext msgContext = MessageContext.getCurrentContext(); if (msgContext != null) { SOAPService service = msgContext.getService(); if (service != null) { String dotNetSoapEncFix = (String) service.getOption(AxisEngine.PROP_DOTNET_SOAPENC_FIX); if (dotNetSoapEncFix != null) { return JavaUtils.isTrue(dotNetSoapEncFix); } } } return TypeMappingImpl.dotnet_soapenc_bugfix; }
private void logMessages(MessageContext msgContext) throws AxisFault { try { PrintWriter writer = null; writer = getWriter(); Message inMsg = msgContext.getRequestMessage(); Message outMsg = msgContext.getResponseMessage(); writer.println( "=======================================================" ); if (start != -1) { writer.println( "= " + Messages.getMessage("elapsed00", "" + (System.currentTimeMillis() - start))); } writer.println( "= " + Messages.getMessage("inMsg00", (inMsg == null ? "null" : inMsg.getSOAPPartAsString()))); writer.println( "= " + Messages.getMessage("outMsg00", (outMsg == null ? "null" : outMsg.getSOAPPartAsString()))); writer.println( "=======================================================" ); //START FIX: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16646 if (!writeToConsole) { writer.close(); } //END FIX: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16646 } catch( Exception e ) { log.error( Messages.getMessage("exception00"), e ); throw AxisFault.makeFault(e); } }
/** * Extract ans store soap constants info from the envelope * @param msgContext * @throws AxisFault */ private void initSOAPConstants(MessageContext msgContext) throws AxisFault { Message msg = msgContext.getRequestMessage(); if (msg == null) return; SOAPEnvelope env = msg.getSOAPEnvelope(); if (env == null) return; SOAPConstants constants = env.getSOAPConstants(); if (constants == null) return; // Ensure that if we get SOAP1.2, then reply using SOAP1.2 msgContext.setSOAPConstants(constants); }
public void generateWSDL(MessageContext msgContext) throws AxisFault { try { String url = msgContext.getStrProp(MessageContext.TRANS_URL); String wsdlString = wsdlStart + url + wsdlEnd; Document doc = XMLUtils.newDocument(new ByteArrayInputStream(wsdlString.getBytes("UTF-8"))); msgContext.setProperty("WSDL", doc); } catch (Exception e) { throw AxisFault.makeFault(e); } } };
public static TypeMappingDelegate createWithDelegate() { TypeMappingDelegate ret = new TypeMappingDelegate(new DefaultSOAPEncodingTypeMappingImpl()); MessageContext mc = MessageContext.getCurrentContext(); TypeMappingDelegate tm = null; if (mc != null) { tm = (TypeMappingDelegate)mc.getTypeMappingRegistry().getDefaultTypeMapping(); } else { tm = DefaultTypeMappingImpl.getSingletonDelegate(); } ret.setNext(tm); return ret; }
/** * Get the current encoding in effect * @return string */ public static String getEncoding() { XMLEncoder encoder = getXMLEncoder(MessageContext.getCurrentContext()); return encoder.getEncoding(); }
String username = msgContext.getUsername(); String password = msgContext.getPassword();
public void invoke(MessageContext context) throws AxisFault { Message message = context.getRequestMessage(); SOAPEnvelope envelope = message.getSOAPEnvelope(); SOAPHeaderElement header = envelope.getHeaderByName(SOAPConstants.NAMESPACE_URI, SOAPConstants.CONNECTION_ID_HEADER_NAME); if (header == null) throw new AxisFault("Could not find mandatory header " + SOAPConstants.CONNECTION_ID_HEADER_NAME); try { String id = (String)header.getValueAsType(XMLType.XSD_STRING); if (id != null && id.length() > 0) context.setProperty(SOAPConstants.CONNECTION_ID_HEADER_NAME, id); } catch (Exception x) { throw AxisFault.makeFault(x); } finally { header.setProcessed(true); } } }