public static SOAPEnvelope createSOAPMessage(MessageContext msgContext) throws AxisFault { return createSOAPMessage(msgContext, false); }
/** * Builds an empty result envelope for methods which do not need to return a large XML body. e.g. * deleteContacts, deleteGroup, updateContactPhoto * * @param namespace String value for namespace * @param resultTagName String tag for result * @return SOAP Envelope to be added to the message context * @throws IOException If a failure on parsing JSON */ protected final SOAPEnvelope buildResultEnvelope(final String namespace, final String resultTagName) throws IOException { OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = factory.createOMNamespace(namespace, "urn"); OMElement resultTag = factory.createOMElement(resultTagName, ns); return TransportUtils.createSOAPEnvelope(resultTag); }
msgContext.setDoingMTOM(TransportUtils.doWriteMTOM(msgContext)); msgContext.setDoingSwA(TransportUtils.doWriteSwA(msgContext)); if (!epr.hasNoneAddress()) { out = new ByteArrayOutputStream(); TransportUtils.writeMessage(msgContext, out); finalizeSendWithToAddress(msgContext, (ByteArrayOutputStream)out); TransportUtils.writeMessage(msgContext, out); } else { throw new AxisFault( TransportUtils.setResponseWritten(msgContext, true);
/** * Objective of this method is to capture the SOAPEnvelope creation logic * and make it a common for all the transports and to in/out flows. * * @param msgContext message context * @param inStream input stream * @param contentType content type of the message * @return the SOAPEnvelope * @throws AxisFault if an error occurs * @throws OMException if the xml is invalid * @throws XMLStreamException if the stream is invalid * @throws FactoryConfigurationError */ public static SOAPEnvelope createSOAPMessage(MessageContext msgContext, InputStream inStream, String contentType) throws AxisFault, OMException, XMLStreamException, FactoryConfigurationError { OMElement documentElement = createDocumentElement(contentType, msgContext, inStream); return createSOAPEnvelope(documentElement); }
public static OMElement createDocumentElement(String contentType, Builder builder, MessageContext msgContext, InputStream inStream) throws AxisFault, XMLStreamException { OMElement documentElement = null; String type = null; if (contentType != null) { type = getContentType(contentType, msgContext); if (builder != null) { if (log.isDebugEnabled()) { log.debug("createSOAPEnvelope using Builder (" + builder.getClass() + ") selected from type (" + type +")"); } documentElement = builder.processDocument(inStream, contentType, msgContext); } } if (documentElement == null) { documentElement = createDefaultDocumentElement(msgContext, inStream, type); } return documentElement; }
SOAPEnvelope soapEnvelope; if (msgContext.getAxisService() == null) { soapEnvelope = TransportUtils.createSOAPEnvelope(null); msgContext.setProperty(Constants.Configuration.MESSAGE_TYPE, TransportUtils.getContentType(contentType, msgContext)); } else { try { soapEnvelope = TransportUtils.createSOAPMessage(msgContext, null, contentType); } catch (XMLStreamException e) { throw AxisFault.makeFault(e);
SOAPEnvelope soapEnvelope; if (msgContext.getAxisService() == null) { soapEnvelope = TransportUtils.createSOAPEnvelope(null); } else { soapEnvelope = TransportUtils.createSOAPMessage(msgContext, in, contentType);
/** * Get the OMOutput format for the given message * @param msgContext the axis message context * @return the OMOutput format to be used */ public static OMOutputFormat getOMOutputFormat(MessageContext msgContext) { OMOutputFormat format = new OMOutputFormat(); msgContext.setDoingMTOM(TransportUtils.doWriteMTOM(msgContext)); msgContext.setDoingSwA(TransportUtils.doWriteSwA(msgContext)); msgContext.setDoingREST(TransportUtils.isDoingREST(msgContext)); format.setSOAP11(msgContext.isSOAP11()); format.setDoOptimize(msgContext.isDoingMTOM()); format.setDoingSWA(msgContext.isDoingSwA()); format.setCharSetEncoding(TransportUtils.getCharSetEncoding(msgContext)); Object mimeBoundaryProperty = msgContext.getProperty(Constants.Configuration.MIME_BOUNDARY); if (mimeBoundaryProperty != null) { format.setMimeBoundary((String) mimeBoundaryProperty); } return format; }
String contentType = contentTypeHdr != null ? TransportUtils.getContentType(contentTypeHdr, msgContext) : null; soapEnvelope = TransportUtils.createSOAPMessage(msgContext, null, contentType); } catch (Exception e) { log.error("Error while building message for REST_URL request");
SOAPEnvelope env = createSOAPMessage(msgContext, inStream, contentType); detachInputStream(msgContext);
/** * This is is a workaround for axis2 RestUtils behaviour * Based on an internal property and the http method, we set the message type * @param originalInMsgCtx IN message * @param axisOutMsgCtx Out message */ private static void processWSDL2RESTRequestMessageType(MessageContext originalInMsgCtx, MessageContext axisOutMsgCtx) { // TODO - this is a workaround for axis2 RestUtils behaviour Object restContentType = originalInMsgCtx.getProperty(NhttpConstants.REST_REQUEST_CONTENT_TYPE); if (restContentType == null) { String httpMethod = (String) originalInMsgCtx.getProperty( Constants.Configuration.HTTP_METHOD); if (Constants.Configuration.HTTP_METHOD_GET.equals(httpMethod) || Constants.Configuration.HTTP_METHOD_DELETE.equals(httpMethod)) { restContentType = HTTPConstants.MEDIA_TYPE_X_WWW_FORM; } } if (restContentType != null && restContentType instanceof String) { String contentType = TransportUtils.getContentType((String) restContentType, originalInMsgCtx); axisOutMsgCtx.setProperty( org.apache.axis2.Constants.Configuration.MESSAGE_TYPE, contentType); originalInMsgCtx.setProperty( org.apache.axis2.Constants.Configuration.MESSAGE_TYPE, contentType); } }
SOAPEnvelope soapEnvelope; if (msgContext.getAxisService() == null) { soapEnvelope = TransportUtils.createSOAPEnvelope(null); msgContext.setProperty(Constants.Configuration.MESSAGE_TYPE, TransportUtils.getContentType(contentType, msgContext)); } else { try { soapEnvelope = TransportUtils.createSOAPMessage(msgContext, null, contentType, builder); } catch (XMLStreamException e) {
SOAPEnvelope soapEnvelope; if (msgContext.getAxisService() == null) { soapEnvelope = TransportUtils.createSOAPEnvelope(null); } else { soapEnvelope = TransportUtils.createSOAPMessage(msgContext, in, contentType);
/** * Retirn the OMOutputFormat to be used for the message context passed in * @param msgContext the message context * @return the OMOutputFormat to be used */ public static OMOutputFormat getOMOutputFormat(MessageContext msgContext) { OMOutputFormat format = new OMOutputFormat(); msgContext.setDoingMTOM(TransportUtils.doWriteMTOM(msgContext)); msgContext.setDoingSwA(TransportUtils.doWriteSwA(msgContext)); msgContext.setDoingREST(TransportUtils.isDoingREST(msgContext)); format.setSOAP11(msgContext.isSOAP11()); format.setDoOptimize(msgContext.isDoingMTOM()); format.setDoingSWA(msgContext.isDoingSwA()); format.setCharSetEncoding(TransportUtils.getCharSetEncoding(msgContext)); Object mimeBoundaryProperty = msgContext.getProperty(Constants.Configuration.MIME_BOUNDARY); if (mimeBoundaryProperty != null) { format.setMimeBoundary((String) mimeBoundaryProperty); } return format; }
/** * Objective of this method is to capture the SOAPEnvelope creation logic * and make it a common for all the transports and to in/out flows. * * @param msgContext message context * @param inStream input stream * @param contentType content type of the message * @param builder the builder to be used * @return the SOAPEnvelope * @throws AxisFault if an error occurs * @throws OMException if the xml is invalid * @throws XMLStreamException if the stream is invalid * @throws FactoryConfigurationError */ public static SOAPEnvelope createSOAPMessage(MessageContext msgContext, InputStream inStream, String contentType, Builder builder) throws AxisFault, OMException, XMLStreamException, FactoryConfigurationError { OMElement documentElement = createDocumentElement(contentType, builder, msgContext, inStream); return createSOAPEnvelope(documentElement); }
public static OMElement createDocumentElement(String contentType, Builder builder, MessageContext msgContext, InputStream inStream) throws AxisFault, XMLStreamException { OMElement documentElement = null; String type = null; if (contentType != null) { type = getContentType(contentType, msgContext); if (builder != null) { if (log.isDebugEnabled()) { log.debug("createSOAPEnvelope using Builder (" + builder.getClass() + ") selected from type (" + type +")"); } documentElement = builder.processDocument(inStream, contentType, msgContext); } } if (documentElement == null) { documentElement = createDefaultDocumentElement(msgContext, inStream, type); } return documentElement; }
contentType = TransportUtils.getContentType(contentTypeHeader, msgContext);
public static SOAPEnvelope createSOAPMessage(MessageContext msgContext) throws AxisFault { return createSOAPMessage(msgContext, false); }
SOAPEnvelope soapEnvelope; if (msgContext.getAxisService() == null) { soapEnvelope = TransportUtils.createSOAPEnvelope(null); msgContext.setProperty(Constants.Configuration.MESSAGE_TYPE, TransportUtils.getContentType(contentType, msgContext)); } else { try { soapEnvelope = TransportUtils.createSOAPMessage(msgContext, null, contentType); } catch (XMLStreamException e) { throw AxisFault.makeFault(e);
/** * Builds an empty result envelope for methods which do not need to return a large XML body. e.g. * deleteContacts, deleteGroup, updateContactPhoto * * @param namespace String value for namespace * @param resultTagName String tag for result * @param elements to be written to the envelope in Map format * @return SOAP Envelope to be added to the message context * @throws IOException If a failure on parsing JSON */ protected final SOAPEnvelope buildResultEnvelope(final String namespace, final String resultTagName, final Map<String, String> elements) throws IOException { OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = factory.createOMNamespace(namespace, "urn"); OMElement resultTag = factory.createOMElement(resultTagName, ns); if (elements != null) { for (Entry<String, String> element : elements.entrySet()) { OMElement childElement = factory.createOMElement(new QName(element.getKey())); childElement.setText(element.getValue()); resultTag.addChild(childElement); } } return TransportUtils.createSOAPEnvelope(resultTag); }