List of usage examples for javax.xml.soap SOAPMessage CHARACTER_SET_ENCODING
String CHARACTER_SET_ENCODING
To view the source code for javax.xml.soap SOAPMessage CHARACTER_SET_ENCODING.
Click Source Link
From source file:de.drv.dsrv.spoc.web.webservice.spring.SpocMessageDispatcherServlet.java
private void createExtraErrorAndWriteResponse(final HttpServletResponse httpServletResponse, final String errorText) throws SOAPException, JAXBException, DatatypeConfigurationException, IOException { final MessageFactory factory = MessageFactory.newInstance(); final SOAPMessage message = factory.createMessage(); final SOAPBody body = message.getSOAPBody(); final SOAPFault fault = body.addFault(); final QName faultName = new QName(SOAPConstants.URI_NS_SOAP_ENVELOPE, FaultCode.CLIENT.toString()); fault.setFaultCode(faultName);/*from ww w . j a v a 2 s . com*/ fault.setFaultString(this.soapFaultString); final Detail detail = fault.addDetail(); final ExtraJaxbMarshaller extraJaxbMarshaller = new ExtraJaxbMarshaller(); final ExtraErrorReasonType reason = ExtraErrorReasonType.INVALID_REQUEST; final ExtraErrorType extraError = ExtraHelper.generateError(reason, this.extraErrorCode, errorText); extraJaxbMarshaller.marshalExtraError(extraError, detail); // Schreibt die SOAPMessage in einen String. final ByteArrayOutputStream out = new ByteArrayOutputStream(); message.writeTo(out); // Das Encoding, in dem sich die Message rausschreibt, kann man als // Property abfragen. final Object encodingProperty = message.getProperty(SOAPMessage.CHARACTER_SET_ENCODING); String soapMessageEncoding = "UTF-8"; if (encodingProperty != null) { soapMessageEncoding = encodingProperty.toString(); } final String errorXml = out.toString(soapMessageEncoding); httpServletResponse.setStatus(HttpServletResponse.SC_OK); httpServletResponse.setContentType("text/xml"); httpServletResponse.getWriter().write(errorXml); httpServletResponse.getWriter().flush(); httpServletResponse.getWriter().close(); }
From source file:com.googlecode.ddom.saaj.SOAPMessageTest.java
@Validated @Test/*w ww . ja v a2s .c om*/ public void testGetSetCharacterSetEncoding() throws Exception { SOAPMessage message = getFactory().createMessage(); String encoding = "ISO-8859-15"; message.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, encoding); assertEquals(encoding, message.getProperty(SOAPMessage.CHARACTER_SET_ENCODING)); }
From source file:lucee.runtime.net.rpc.server.RPCServer.java
/** * Process a POST to the servlet by handing it off to the Axis Engine. * Here is where SOAP messages are received * @param req posted request/* w w w .j a v a 2 s. c o m*/ * @param res respose * @throws ServletException trouble * @throws IOException different trouble */ public void doPost(HttpServletRequest req, HttpServletResponse res, Component component) throws ServletException, IOException { long t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0; String soapAction = null; MessageContext msgContext = null; Message rspMsg = null; String contentType = null; InputStream is = null; try { AxisEngine engine = getEngine(); if (engine == null) { // !!! should return a SOAP fault... ServletException se = new ServletException(Messages.getMessage("noEngine00")); log.debug("No Engine!", se); throw se; } res.setBufferSize(1024 * 8); // provide performance boost. /** get message context w/ various properties set */ msgContext = createMessageContext(engine, req, res, component); ComponentController.set(msgContext); // ? OK to move this to 'getMessageContext', // ? where it would also be picked up for 'doGet()' ? if (securityProvider != null) { if (isDebug) { log.debug("securityProvider:" + securityProvider); } msgContext.setProperty(MessageContext.SECURITY_PROVIDER, securityProvider); } is = req.getInputStream(); Message requestMsg = new Message(is, false, req.getHeader(HTTPConstants.HEADER_CONTENT_TYPE), req.getHeader(HTTPConstants.HEADER_CONTENT_LOCATION)); // Transfer HTTP headers to MIME headers for request message. MimeHeaders requestMimeHeaders = requestMsg.getMimeHeaders(); for (Enumeration e = req.getHeaderNames(); e.hasMoreElements();) { String headerName = (String) e.nextElement(); for (Enumeration f = req.getHeaders(headerName); f.hasMoreElements();) { String headerValue = (String) f.nextElement(); requestMimeHeaders.addHeader(headerName, headerValue); } } if (isDebug) { log.debug("Request Message:" + requestMsg); /* Set the request(incoming) message field in the context */ /**********************************************************/ } msgContext.setRequestMessage(requestMsg); String url = HttpUtils.getRequestURL(req).toString().toLowerCase(); msgContext.setProperty(MessageContext.TRANS_URL, url); // put character encoding of request to message context // in order to reuse it during the whole process. try { String reqEnc = (String) requestMsg.getProperty(SOAPMessage.CHARACTER_SET_ENCODING); if (reqEnc != null) msgContext.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, reqEnc); } catch (SOAPException e1) { } try { /** * Save the SOAPAction header in the MessageContext bag. * This will be used to tell the Axis Engine which service * is being invoked. This will save us the trouble of * having to parse the Request message - although we will * need to double-check later on that the SOAPAction header * does in fact match the URI in the body. */ // (is this last stmt true??? (I don't think so - Glen)) /********************************************************/ soapAction = getSoapAction(req); if (soapAction != null) { msgContext.setUseSOAPAction(true); msgContext.setSOAPActionURI(soapAction); } // Create a Session wrapper for the HTTP session. // These can/should be pooled at some point. // (Sam is Watching! :-) msgContext.setSession(new AxisHttpSession(req)); if (tlog.isDebugEnabled()) { t1 = System.currentTimeMillis(); } /* Invoke the Axis engine... */ /*****************************/ if (isDebug) { log.debug("Invoking Axis Engine."); //here we run the message by the engine } //msgContext.setProperty("disablePrettyXML", "false"); engine.invoke(msgContext); if (isDebug) { log.debug("Return from Axis Engine."); } if (tlog.isDebugEnabled()) { t2 = System.currentTimeMillis(); } rspMsg = msgContext.getResponseMessage(); // We used to throw exceptions on null response messages. // They are actually OK in certain situations (asynchronous // services), so fall through here and return an ACCEPTED // status code below. Might want to install a configurable // error check for this later. } catch (AxisFault fault) { //log and sanitize processAxisFault(fault); configureResponseFromAxisFault(res, fault); rspMsg = msgContext.getResponseMessage(); if (rspMsg == null) { rspMsg = new Message(fault); ((org.apache.axis.SOAPPart) rspMsg.getSOAPPart()).getMessage().setMessageContext(msgContext); } } catch (Throwable t) { if (t instanceof InvocationTargetException) t = ((InvocationTargetException) t).getTargetException(); // Exception if (t instanceof Exception) { Exception e = (Exception) t; //other exceptions are internal trouble rspMsg = msgContext.getResponseMessage(); res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); rspMsg = convertExceptionToAxisFault(e, rspMsg); ((org.apache.axis.SOAPPart) rspMsg.getSOAPPart()).getMessage().setMessageContext(msgContext); } // throwable else { logException(t); //other exceptions are internal trouble rspMsg = msgContext.getResponseMessage(); res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); rspMsg = new Message(new AxisFault(t.toString(), t)); ((org.apache.axis.SOAPPart) rspMsg.getSOAPPart()).getMessage().setMessageContext(msgContext); } } } catch (AxisFault fault) { processAxisFault(fault); configureResponseFromAxisFault(res, fault); rspMsg = msgContext.getResponseMessage(); if (rspMsg == null) { rspMsg = new Message(fault); ((org.apache.axis.SOAPPart) rspMsg.getSOAPPart()).getMessage().setMessageContext(msgContext); } } finally { IOUtil.closeEL(is); } if (tlog.isDebugEnabled()) { t3 = System.currentTimeMillis(); } // Send response back along the wire... if (rspMsg != null) { // Transfer MIME headers to HTTP headers for response message. MimeHeaders responseMimeHeaders = rspMsg.getMimeHeaders(); for (Iterator i = responseMimeHeaders.getAllHeaders(); i.hasNext();) { MimeHeader responseMimeHeader = (MimeHeader) i.next(); res.addHeader(responseMimeHeader.getName(), responseMimeHeader.getValue()); } // synchronize the character encoding of request and response String responseEncoding = (String) msgContext.getProperty(SOAPMessage.CHARACTER_SET_ENCODING); if (responseEncoding != null) { try { rspMsg.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, responseEncoding); } catch (SOAPException e) { } } //determine content type from message response contentType = rspMsg.getContentType(msgContext.getSOAPConstants()); if (isDebug) log.debug("Returned Content-Type:" + contentType); // write result to response stream try { res.setContentType(contentType); rspMsg.writeTo(res.getOutputStream()); } catch (SOAPException e) { logException(e); } if (!res.isCommitted()) res.flushBuffer(); // Force it right now. } else { // No content, so just indicate accepted res.setStatus(202); } if (isDebug) { log.debug("Response sent."); log.debug("Exit: doPost()"); } if (tlog.isDebugEnabled()) { t4 = System.currentTimeMillis(); tlog.debug("axisServlet.doPost: " + soapAction + " pre=" + (t1 - t0) + " invoke=" + (t2 - t1) + " post=" + (t3 - t2) + " send=" + (t4 - t3) + " " + msgContext.getTargetService() + "." + ((msgContext.getOperation() == null) ? "" : msgContext.getOperation().getName())); } }
From source file:com.twinsoft.convertigo.engine.translators.WebServiceTranslator.java
public Object __buildOutputData(Context context, Object convertigoResponse) throws Exception { Engine.logBeans.debug("[WebServiceTranslator] Encoding the SOAP response..."); SOAPMessage responseMessage = null; String sResponseMessage = ""; String encodingCharSet = "UTF-8"; if (context.requestedObject != null) encodingCharSet = context.requestedObject.getEncodingCharSet(); if (convertigoResponse instanceof Document) { Engine.logBeans.debug("[WebServiceTranslator] The Convertigo response is a XML document."); Document document = (Document) convertigoResponse; //MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL); MessageFactory messageFactory = MessageFactory.newInstance(); responseMessage = messageFactory.createMessage(); responseMessage.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, encodingCharSet); SOAPPart sp = responseMessage.getSOAPPart(); SOAPEnvelope se = sp.getEnvelope(); SOAPBody sb = se.getBody(); sb.setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding/"); String targetNamespace = context.project.getTargetNamespace(); String prefix = getPrefix(context.projectName, targetNamespace); //se.addNamespaceDeclaration(prefix, targetNameSpace); se.addNamespaceDeclaration("soapenc", "http://schemas.xmlsoap.org/soap/encoding/"); se.addNamespaceDeclaration("xsi", "http://www.w3.org/2001/XMLSchema-instance"); se.addNamespaceDeclaration("xsd", "http://www.w3.org/2001/XMLSchema"); // Remove header as it not used. Seems that empty headers causes the WS client of Flex 4 to fail se.getHeader().detachNode();/*w w w .j a v a 2s . co m*/ // Add the method response element SOAPElement soapMethodResponseElement = null; String soapElementName = context.sequenceName != null ? context.sequenceName : context.connectorName + "__" + context.transactionName; soapElementName += "Response"; soapMethodResponseElement = sb.addChildElement(se.createName(soapElementName, prefix, targetNamespace)); if (XsdForm.qualified == context.project.getSchemaElementForm()) { soapMethodResponseElement.addAttribute(se.createName("xmlns"), targetNamespace); } // Add a 'response' root child element or not SOAPElement soapResponseElement; if (context.sequenceName != null) { Sequence sequence = (Sequence) context.requestedObject; if (sequence.isIncludeResponseElement()) { soapResponseElement = soapMethodResponseElement.addChildElement("response"); } else { soapResponseElement = soapMethodResponseElement; } } else { soapResponseElement = soapMethodResponseElement.addChildElement("response"); } if (soapResponseElement.getLocalName().equals("response")) { if (document.getDocumentElement().hasAttributes()) { addAttributes(responseMessage, se, context, document.getDocumentElement().getAttributes(), soapResponseElement); } } NodeList childNodes = document.getDocumentElement().getChildNodes(); int len = childNodes.getLength(); org.w3c.dom.Node node; for (int i = 0; i < len; i++) { node = childNodes.item(i); if (node instanceof Element) { addElement(responseMessage, se, context, (Element) node, soapResponseElement); } } sResponseMessage = SOAPUtils.toString(responseMessage, encodingCharSet); // Correct missing "xmlns" (Bug AXA POC client .NET) //sResponseMessage = sResponseMessage.replaceAll("<soapenv:Envelope", "<soapenv:Envelope xmlns=\""+targetNameSpace+"\""); } else { Engine.logBeans.debug("[WebServiceTranslator] The Convertigo response is not a XML document."); sResponseMessage = convertigoResponse.toString(); } if (Engine.logBeans.isDebugEnabled()) { Engine.logBeans.debug("[WebServiceTranslator] SOAP response:\n" + sResponseMessage); } return responseMessage == null ? sResponseMessage.getBytes(encodingCharSet) : responseMessage; }
From source file:com.twinsoft.convertigo.engine.translators.WebServiceTranslator.java
public Object buildOutputData(Context context, Object convertigoResponse) throws Exception { Engine.logBeans.debug("[WebServiceTranslator] Encoding the SOAP response..."); SOAPMessage responseMessage = null; String sResponseMessage = ""; String encodingCharSet = "UTF-8"; if (context.requestedObject != null) encodingCharSet = context.requestedObject.getEncodingCharSet(); if (convertigoResponse instanceof Document) { Engine.logBeans.debug("[WebServiceTranslator] The Convertigo response is a XML document."); Document document = Engine.theApp.schemaManager.makeResponse((Document) convertigoResponse); //MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL); MessageFactory messageFactory = MessageFactory.newInstance(); responseMessage = messageFactory.createMessage(); responseMessage.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, encodingCharSet); SOAPPart sp = responseMessage.getSOAPPart(); SOAPEnvelope se = sp.getEnvelope(); SOAPBody sb = se.getBody(); sb.setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding/"); //se.addNamespaceDeclaration(prefix, targetNameSpace); se.addNamespaceDeclaration("soapenc", "http://schemas.xmlsoap.org/soap/encoding/"); se.addNamespaceDeclaration("xsi", "http://www.w3.org/2001/XMLSchema-instance"); se.addNamespaceDeclaration("xsd", "http://www.w3.org/2001/XMLSchema"); // Remove header as it not used. Seems that empty headers causes the WS client of Flex 4 to fail se.getHeader().detachNode();/*from w w w . ja v a2 s . c om*/ addSoapElement(context, se, sb, document.getDocumentElement()); sResponseMessage = SOAPUtils.toString(responseMessage, encodingCharSet); // Correct missing "xmlns" (Bug AXA POC client .NET) //sResponseMessage = sResponseMessage.replaceAll("<soapenv:Envelope", "<soapenv:Envelope xmlns=\""+targetNameSpace+"\""); } else { Engine.logBeans.debug("[WebServiceTranslator] The Convertigo response is not a XML document."); sResponseMessage = convertigoResponse.toString(); } if (Engine.logBeans.isDebugEnabled()) { Engine.logBeans.debug("[WebServiceTranslator] SOAP response:\n" + sResponseMessage); } return responseMessage == null ? sResponseMessage.getBytes(encodingCharSet) : responseMessage; }
From source file:org.apache.axis.client.Call.java
/** * Invoke the service with a custom SOAPEnvelope. * <p>/*from w w w . ja v a 2s . c o m*/ * Note: Not part of JAX-RPC specification. * * @param env a SOAPEnvelope to send * @throws AxisFault if there is any failure */ public SOAPEnvelope invoke(SOAPEnvelope env) throws AxisFault { try { Message msg = new Message(env); if (getProperty(CHARACTER_SET_ENCODING) != null) { msg.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, getProperty(CHARACTER_SET_ENCODING)); } else if (msgContext.getProperty(CHARACTER_SET_ENCODING) != null) { msg.setProperty(CHARACTER_SET_ENCODING, msgContext.getProperty(CHARACTER_SET_ENCODING)); } setRequestMessage(msg); invoke(); msg = msgContext.getResponseMessage(); if (msg == null) { if (msgContext.isPropertyTrue(FAULT_ON_NO_RESPONSE, false)) { throw new AxisFault(Messages.getMessage("nullResponse00")); } else { return null; } } return (msg.getSOAPEnvelope()); } catch (Exception exp) { if (exp instanceof AxisFault) { throw (AxisFault) exp; } entLog.debug(Messages.getMessage("toAxisFault00"), exp); throw AxisFault.makeFault(exp); } }
From source file:org.apache.axis.client.Call.java
/** * Invoke this Call with its established MessageContext * (perhaps because you called this.setRequestMessage()) * * Note: Not part of JAX-RPC specification. * * @exception AxisFault//from www . j a va 2s. co m */ public void invoke() throws AxisFault { if (log.isDebugEnabled()) { log.debug("Enter: Call::invoke()"); } isNeverInvoked = false; Message reqMsg = null; SOAPEnvelope reqEnv = null; msgContext.reset(); msgContext.setResponseMessage(null); msgContext.setProperty(MessageContext.CALL, this); msgContext.setProperty(WSDL_SERVICE, service); msgContext.setProperty(WSDL_PORT_NAME, getPortName()); if (isMsg) { msgContext.setProperty(MessageContext.IS_MSG, "true"); } if (username != null) { msgContext.setUsername(username); } if (password != null) { msgContext.setPassword(password); } msgContext.setMaintainSession(maintainSession); if (operation != null) { msgContext.setOperation(operation); operation.setStyle(getOperationStyle()); operation.setUse(getOperationUse()); } if (useSOAPAction) { msgContext.setUseSOAPAction(true); } if (SOAPActionURI != null) { msgContext.setSOAPActionURI(SOAPActionURI); } else { msgContext.setSOAPActionURI(null); } if (timeout != null) { msgContext.setTimeout(timeout.intValue()); } msgContext.setHighFidelity(!useStreaming); // Determine client target service if (myService != null) { // If we have a SOAPService kicking around, use that directly msgContext.setService(myService); } else { if (portName != null) { // No explicit service. If we have a target service name, // try that. msgContext.setTargetService(portName.getLocalPart()); } else { // No direct config, so try the namespace of the first body. reqMsg = msgContext.getRequestMessage(); boolean isStream = ((SOAPPart) reqMsg.getSOAPPart()).isBodyStream(); if (reqMsg != null && !isStream) { reqEnv = reqMsg.getSOAPEnvelope(); SOAPBodyElement body = reqEnv.getFirstBody(); if (body != null) { if (body.getNamespaceURI() == null) { throw new AxisFault("Call.invoke", Messages.getMessage("cantInvoke00", body.getName()), null, null); } else { msgContext.setTargetService(body.getNamespaceURI()); } } } } } if (log.isDebugEnabled()) { log.debug(Messages.getMessage("targetService", msgContext.getTargetService())); } Message requestMessage = msgContext.getRequestMessage(); if (requestMessage != null) { try { msgContext.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, requestMessage.getProperty(SOAPMessage.CHARACTER_SET_ENCODING)); } catch (SOAPException e) { } if (myHeaders != null) { reqEnv = requestMessage.getSOAPEnvelope(); // If we have headers to insert, do so now. for (int i = 0; myHeaders != null && i < myHeaders.size(); i++) { reqEnv.addHeader((SOAPHeaderElement) myHeaders.get(i)); } } } // set up transport if there is one if (transport != null) { transport.setupMessageContext(msgContext, this, service.getEngine()); } else { msgContext.setTransportName(transportName); } SOAPService svc = msgContext.getService(); if (svc != null) { svc.setPropertyParent(myProperties); } else { msgContext.setPropertyParent(myProperties); } // For debugging - print request message if (log.isDebugEnabled()) { StringWriter writer = new StringWriter(); try { SerializationContext ctx = new SerializationContext(writer, msgContext); requestMessage.getSOAPEnvelope().output(ctx); writer.close(); } catch (Exception e) { throw AxisFault.makeFault(e); } finally { log.debug(writer.getBuffer().toString()); } } if (!invokeOneWay) { invokeEngine(msgContext); } else { invokeEngineOneWay(msgContext); } if (log.isDebugEnabled()) { log.debug("Exit: Call::invoke()"); } }
From source file:org.apache.axis.Message.java
/** * Do the work of construction./* www . jav a2 s . c o m*/ * * @param initialContents may be String, byte[], InputStream, SOAPEnvelope, * or AxisFault * @param bodyInStream is true if initialContents is an InputStream * containing just the SOAP body (no SOAP-ENV) * @param contentType this if the contentType has been already determined * (as in the case of servlets) * @param contentLocation the location of the content * @param mimeHeaders mime headers for attachments */ private void setup(Object initialContents, boolean bodyInStream, String contentType, String contentLocation, javax.xml.soap.MimeHeaders mimeHeaders) { if (contentType == null && mimeHeaders != null) { String contentTypes[] = mimeHeaders.getHeader("Content-Type"); contentType = (contentTypes != null) ? contentTypes[0] : null; } if (contentLocation == null && mimeHeaders != null) { String contentLocations[] = mimeHeaders.getHeader("Content-Location"); contentLocation = (contentLocations != null) ? contentLocations[0] : null; } if (contentType != null) { int delimiterIndex = contentType.lastIndexOf("charset"); if (delimiterIndex > 0) { String charsetPart = contentType.substring(delimiterIndex); int delimiterIndex2 = charsetPart.indexOf(';'); if (delimiterIndex2 != -1) { charsetPart = charsetPart.substring(0, delimiterIndex2); } int charsetIndex = charsetPart.indexOf('='); String charset = charsetPart.substring(charsetIndex + 1).trim(); if ((charset.startsWith("\"") || charset.startsWith("\'"))) { charset = charset.substring(1, charset.length()); } if ((charset.endsWith("\"") || charset.endsWith("\'"))) { charset = charset.substring(0, charset.length() - 1); } try { setProperty(SOAPMessage.CHARACTER_SET_ENCODING, charset); } catch (SOAPException e) { } } } // Try to construct an AttachmentsImpl object for attachment // functionality. // If there is no org.apache.axis.attachments.AttachmentsImpl class, // it must mean activation.jar is not present and attachments are not // supported. if (isAttachmentSupportEnabled(getMessageContext())) { // Construct one, and cast to Attachments. // There must be exactly one constructor of AttachmentsImpl, which // must take an org.apache.axis.Message! Constructor attachImplConstr = attachImpl.getConstructors()[0]; try { mAttachments = (Attachments) attachImplConstr .newInstance(new Object[] { initialContents, contentType, contentLocation }); //If it can't support it, it wont have a root part. mSOAPPart = (SOAPPart) mAttachments.getRootPart(); } catch (InvocationTargetException ex) { log.fatal(Messages.getMessage("invocationTargetException00"), ex); throw new RuntimeException(ex.getMessage()); } catch (InstantiationException ex) { log.fatal(Messages.getMessage("instantiationException00"), ex); throw new RuntimeException(ex.getMessage()); } catch (IllegalAccessException ex) { log.fatal(Messages.getMessage("illegalAccessException00"), ex); throw new RuntimeException(ex.getMessage()); } } else if (contentType != null && contentType.startsWith("multipart")) { throw new RuntimeException(Messages.getMessage("noAttachments")); } // text/xml if (null == mSOAPPart) { mSOAPPart = new SOAPPart(this, initialContents, bodyInStream); } else mSOAPPart.setMessage(this); // The stream was not determined by a more complex type so default to if (mAttachments != null) mAttachments.setRootPart(mSOAPPart); headers = (mimeHeaders == null) ? new MimeHeaders() : new MimeHeaders(mimeHeaders); }
From source file:org.apache.axis.providers.java.JavaProvider.java
/** * Invoke the message by obtaining various common fields, looking up * the service object (via getServiceObject), and actually processing * the message (via processMessage)./*from w w w . j a va 2 s . c o m*/ */ public void invoke(MessageContext msgContext) throws AxisFault { if (log.isDebugEnabled()) log.debug("Enter: JavaProvider::invoke (" + this + ")"); /* Find the service we're invoking so we can grab it's options */ /***************************************************************/ String serviceName = msgContext.getTargetService(); Handler service = msgContext.getService(); /* Now get the service (RPC) specific info */ /********************************************/ String clsName = getServiceClassName(service); if ((clsName == null) || clsName.equals("")) { throw new AxisFault("Server.NoClassForService", Messages.getMessage("noOption00", getServiceClassNameOptionName(), serviceName), null, null); } IntHolder scope = new IntHolder(); Object serviceObject = null; try { serviceObject = getServiceObject(msgContext, service, clsName, scope); SOAPEnvelope resEnv = null; // If there IS a response message AND this is a one-way operation, // we delete the response message here. Note that this might // cause confusing results in some cases - i.e. nothing fails, // but your response headers don't go anywhere either. It might // be nice if in the future there was a way to detect an error // when trying to install a response message in a MessageContext // associated with a one-way operation.... OperationDesc operation = msgContext.getOperation(); if (operation != null && OperationType.ONE_WAY.equals(operation.getMep())) { msgContext.setResponseMessage(null); } else { Message resMsg = msgContext.getResponseMessage(); // If we didn't have a response message, make sure we set one up // with the appropriate versions of SOAP and Schema if (resMsg == null) { resEnv = new SOAPEnvelope(msgContext.getSOAPConstants(), msgContext.getSchemaVersion()); resMsg = new Message(resEnv); String encoding = XMLUtils.getEncoding(msgContext); resMsg.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, encoding); msgContext.setResponseMessage(resMsg); } else { resEnv = resMsg.getSOAPEnvelope(); } } Message reqMsg = msgContext.getRequestMessage(); SOAPEnvelope reqEnv = reqMsg.getSOAPEnvelope(); processMessage(msgContext, reqEnv, resEnv, serviceObject); } catch (SAXException exp) { entLog.debug(Messages.getMessage("toAxisFault00"), exp); Exception real = exp.getException(); if (real == null) { real = exp; } throw AxisFault.makeFault(real); } catch (Exception exp) { entLog.debug(Messages.getMessage("toAxisFault00"), exp); AxisFault fault = AxisFault.makeFault(exp); //make a note if this was a runtime fault, for better logging if (exp instanceof RuntimeException) { fault.addFaultDetail(Constants.QNAME_FAULTDETAIL_RUNTIMEEXCEPTION, "true"); } throw fault; } finally { // If this is a request scoped service object which implements // ServiceLifecycle, let it know that it's being destroyed now. if (serviceObject != null && scope.value == Scope.REQUEST.getValue() && serviceObject instanceof ServiceLifecycle) { ((ServiceLifecycle) serviceObject).destroy(); } } if (log.isDebugEnabled()) log.debug("Exit: JavaProvider::invoke (" + this + ")"); }