/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * Generates a SOAP envelope based on XML Serialization provided by GData(BaseEntry) API generate method. * * @param baseEntry the object to be serialized. * @param contactsService Contacts Service object. * @return A SOAP Envelope containing the XML generated from the object. * @throws IOException On failure to initialize XML Writer. * @throws XMLStreamException On failure to convert XML String to OM Element. */ protected final SOAPEnvelope getGDataSOAPEnvelope(final BaseEntry< ? > baseEntry, final ContactsService contactsService) throws IOException, XMLStreamException { Writer stringWriter = new StringWriter(); XmlWriter xmlWriter = new XmlWriter(stringWriter); baseEntry.generate(xmlWriter, contactsService.getExtensionProfile()); return TransportUtils.createSOAPEnvelope(AXIOMUtil.stringToOM(stringWriter.toString())); }
/** * Generates a SOAP envelope based on XML Serialization provided by GData(BaseFeed) API generate method. * * @param baseFeed The object to be serialized. * @param contactsService Contact Service object. * @return a SOAP envelope containing the serialized XML. * @throws IOException Thrown on failure to initialize the XML writer. * @throws XMLStreamException On failure to convert the XML String to OMElement. */ public final SOAPEnvelope getGDataSOAPEnvelope(final BaseFeed< ? , ? > baseFeed, final ContactsService contactsService) throws IOException, XMLStreamException { Writer stringWriter = new StringWriter(); XmlWriter xmlWriter = new XmlWriter(stringWriter); baseFeed.generate(xmlWriter, contactsService.getExtensionProfile()); return TransportUtils.createSOAPEnvelope(AXIOMUtil.stringToOM(stringWriter.toString())); }
public static void invoke(MqttMessage mqttMessage, MessageContext msgContext, String contentType) throws AxisFault, AxisMqttException { if (contentType == null) { contentType = "text/plain"; } Builder builder = BuilderUtil.getBuilderFromSelector(contentType, msgContext); if (builder == null) { if (log.isDebugEnabled()) { log.debug("No message builder found for type '" + contentType + "'. Falling back to SOAP."); } builder = new SOAPBuilder(); } msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, "UTF-8"); OMElement documentElement = null; byte[] bytes = mqttMessage.getPayload(); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes); documentElement = builder.processDocument(byteArrayInputStream, contentType, msgContext); msgContext.setEnvelope(TransportUtils.createSOAPEnvelope(documentElement)); } }
public static void setSOAPEnvelope(RabbitMQMessage message, MessageContext msgContext, String contentType) throws AxisFault { int index = contentType.indexOf(';'); String type = index > 0 ? contentType.substring(0, index) : contentType; Builder builder = BuilderUtil.getBuilderFromSelector(type, msgContext); if (builder == null) { if (log.isDebugEnabled()) { log.debug("No message builder found for type '" + type + "'. Falling back to SOAP."); } builder = new SOAPBuilder(); } OMElement documentElement; String charSetEnc = null; try { if (contentType != null) { charSetEnc = new ContentType(contentType).getParameter("charset"); } } catch (ParseException ex) { log.debug("Parse error", ex); } msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc); documentElement = builder.processDocument( new ByteArrayInputStream(message.getBody()), contentType, msgContext); msgContext.setEnvelope(TransportUtils.createSOAPEnvelope(documentElement)); }
MessageContext messageContext = new MessageContext(); SOAPEnvelope soapEnvelope = TransportUtils.createSOAPEnvelope(request); messageContext.setEnvelope(soapEnvelope);
/** * Method to build a MEP Client with an attachment in the method context. * * @deprecated Please use * {@link #buildMEPClient(EndpointReference, OMElement, Map, String, String, String)} instead. * @param endpoint The endpoint to configure the client for. * @param request The request to add as a SOAP envelope. * @param attachmentMap The attachment map. * @return The built MEP Client * @throws AxisFault on failure to initialize the client. */ @Deprecated private OperationClient buildMEPClient(final EndpointReference endpoint, final OMElement request, final Map<String, DataHandler> attachmentMap) throws AxisFault { ServiceClient serviceClient = new ServiceClient(); Options serviceOptions = new Options(); serviceOptions.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE); serviceOptions.setTo(endpoint); serviceOptions.setAction("mediate"); serviceClient.setOptions(serviceOptions); MessageContext messageContext = new MessageContext(); SOAPEnvelope soapEnvelope = TransportUtils.createSOAPEnvelope(request); messageContext.setEnvelope(soapEnvelope); for (String contentId : attachmentMap.keySet()) { messageContext.addAttachment(contentId, attachmentMap.get(contentId)); } OperationClient mepClient = serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP); mepClient.addMessageContext(messageContext); return mepClient; }
/** * Method to build a MEP with a specified soap envelope. * * @deprecated Please use {@link #buildMEPClient(EndpointReference, OMElement, String, String, String)} * instead. * @param endpoint The endpoint to configure the client for. * @param request The request to add as a SOAP envelope * @return The built MEP Client * @throws AxisFault on failure to initialize the client. */ @Deprecated private OperationClient buildMEPClient(final EndpointReference endpoint, final OMElement request) throws AxisFault { ServiceClient serviceClient = new ServiceClient(); Options serviceOptions = new Options(); serviceOptions.setTo(endpoint); serviceOptions.setAction("mediate"); serviceClient.setOptions(serviceOptions); MessageContext messageContext = new MessageContext(); SOAPEnvelope soapEnvelope = TransportUtils.createSOAPEnvelope(request); messageContext.setEnvelope(soapEnvelope); OperationClient mepClient = serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP); mepClient.addMessageContext(messageContext); return mepClient; }
/** * Method to build a MEP with a specified soap envelope. * * @deprecated Please use {@link #buildMEPClient(EndpointReference, OMElement, String, String, String)} * instead. * @param endpoint The endpoint to configure the client for. * @param request The request to add as a SOAP envelope * @return The built MEP Client * @throws AxisFault on failure to initialize the client. */ @Deprecated private OperationClient buildMEPClient(final EndpointReference endpoint, final OMElement request) throws AxisFault { ServiceClient serviceClient = new ServiceClient(); Options serviceOptions = new Options(); serviceOptions.setTo(endpoint); serviceOptions.setAction("mediate"); serviceClient.setOptions(serviceOptions); MessageContext messageContext = new MessageContext(); SOAPEnvelope soapEnvelope = TransportUtils.createSOAPEnvelope(request); messageContext.setEnvelope(soapEnvelope); OperationClient mepClient = serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP); mepClient.addMessageContext(messageContext); return mepClient; }
SOAPEnvelope soapEnvelope; if (msgContext.getAxisService() == null) { soapEnvelope = TransportUtils.createSOAPEnvelope(null); msgContext.setProperty(Constants.Configuration.MESSAGE_TYPE, TransportUtils.getContentType(contentType, msgContext));
SOAPEnvelope soapEnvelope; if (msgContext.getAxisService() == null) { soapEnvelope = TransportUtils.createSOAPEnvelope(null); msgContext.setProperty(Constants.Configuration.MESSAGE_TYPE, TransportUtils.getContentType(contentType, msgContext));
SOAPEnvelope soapEnvelope; if (msgContext.getAxisService() == null) { soapEnvelope = TransportUtils.createSOAPEnvelope(null); } else { soapEnvelope = TransportUtils.createSOAPMessage(msgContext, in, contentType);
SOAPEnvelope soapEnvelope; if (msgContext.getAxisService() == null) { soapEnvelope = TransportUtils.createSOAPEnvelope(null); } else { soapEnvelope = TransportUtils.createSOAPMessage(msgContext, in, contentType);
MessageContext messageContext = new MessageContext(); SOAPEnvelope soapEnvelope = TransportUtils.createSOAPEnvelope(request); messageContext.setEnvelope(soapEnvelope);
/** * Method to build a MEP with a specified soap envelope. * * @param endpoint * The endpoint to configure the client for. * @param request * The request to add as a SOAP envelope * @return The built MEP Client * @throws AxisFault * on failure to initialize the client. */ public static OperationClient buildMEPClient(EndpointReference endpoint, OMElement request) throws AxisFault { ServiceClient serviceClient = new ServiceClient(); Options serviceOptions = new Options(); serviceOptions.setTo(endpoint); serviceOptions.setAction("mediate"); serviceClient.setOptions(serviceOptions); MessageContext messageContext = new MessageContext(); SOAPEnvelope soapEnvelope = TransportUtils.createSOAPEnvelope(request); messageContext.setEnvelope(soapEnvelope); OperationClient mepClient = serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP); mepClient.addMessageContext(messageContext); return mepClient; }