Java Code Examples for org.apache.axiom.soap.SOAPFactory#getDefaultEnvelope()
The following examples show how to use
org.apache.axiom.soap.SOAPFactory#getDefaultEnvelope() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WSXACMLMessageReceiver.java From carbon-identity-framework with Apache License 2.0 | 6 votes |
private SOAPEnvelope createDefaultSOAPEnvelope(MessageContext inMsgCtx) { String soapNamespace = inMsgCtx.getEnvelope().getNamespace() .getNamespaceURI(); SOAPFactory soapFactory = null; if (soapNamespace.equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) { soapFactory = OMAbstractFactory.getSOAP11Factory(); } else if (soapNamespace .equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) { soapFactory = OMAbstractFactory.getSOAP12Factory(); } else { log.error("Unknown SOAP Envelope"); } if (soapFactory != null) { return soapFactory.getDefaultEnvelope(); } return null; }
Example 2
Source File: WSXACMLMessageReceiver.java From carbon-identity with Apache License 2.0 | 6 votes |
private SOAPEnvelope createDefaultSOAPEnvelope(MessageContext inMsgCtx) { String soapNamespace = inMsgCtx.getEnvelope().getNamespace() .getNamespaceURI(); SOAPFactory soapFactory = null; if (soapNamespace.equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) { soapFactory = OMAbstractFactory.getSOAP11Factory(); } else if (soapNamespace .equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) { soapFactory = OMAbstractFactory.getSOAP12Factory(); } else { log.error("Unknown SOAP Envelope"); } if (soapFactory != null) { return soapFactory.getDefaultEnvelope(); } return null; }
Example 3
Source File: EventBrokerUtils.java From carbon-commons with Apache License 2.0 | 6 votes |
public static MessageContext createMessageContext(OMElement payload, OMElement topic, int tenantId) throws EventBrokerException { MessageContext mc = new MessageContext(); mc.setConfigurationContext(new ConfigurationContext(new AxisConfiguration())); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId); SOAPFactory soapFactory = new SOAP12Factory(); SOAPEnvelope envelope = soapFactory.getDefaultEnvelope(); envelope.getBody().addChild(payload); if (topic != null) { envelope.getHeader().addChild(topic); } try { mc.setEnvelope(envelope); } catch (Exception e) { throw new EventBrokerException("Unable to generate event.", e); } return mc; }
Example 4
Source File: EntitlementMediator.java From micro-integrator with Apache License 2.0 | 5 votes |
private SOAPEnvelope createDefaultSOAPEnvelope(MessageContext inMsgCtx) { String soapNamespace = inMsgCtx.getEnvelope().getNamespace().getNamespaceURI(); SOAPFactory soapFactory = null; if (soapNamespace.equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) { soapFactory = OMAbstractFactory.getSOAP11Factory(); } else if (soapNamespace.equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) { soapFactory = OMAbstractFactory.getSOAP12Factory(); } else { log.error("Unknown SOAP Envelope"); } return soapFactory.getDefaultEnvelope(); }
Example 5
Source File: DataServiceCallMediator.java From micro-integrator with Apache License 2.0 | 5 votes |
private SOAPEnvelope createDefaultSOAPEnvelope(MessageContext inMsgCtx) { String soapNamespace = inMsgCtx.getEnvelope().getNamespace().getNamespaceURI(); SOAPFactory soapFactory = null; if (soapNamespace.equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) { soapFactory = OMAbstractFactory.getSOAP11Factory(); } else if (soapNamespace.equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) { soapFactory = OMAbstractFactory.getSOAP12Factory(); } else { log.error("Unknown SOAP Envelope"); } return soapFactory.getDefaultEnvelope(); }
Example 6
Source File: InboundWebsocketSourceHandler.java From micro-integrator with Apache License 2.0 | 5 votes |
private static org.apache.synapse.MessageContext createSynapseMessageContext(String tenantDomain) throws AxisFault { org.apache.axis2.context.MessageContext axis2MsgCtx = createAxis2MessageContext(); ServiceContext svcCtx = new ServiceContext(); OperationContext opCtx = new OperationContext(new InOutAxisOperation(), svcCtx); axis2MsgCtx.setServiceContext(svcCtx); axis2MsgCtx.setOperationContext(opCtx); axis2MsgCtx.setProperty(TENANT_DOMAIN, SUPER_TENANT_DOMAIN_NAME); SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); SOAPEnvelope envelope = fac.getDefaultEnvelope(); axis2MsgCtx.setEnvelope(envelope); return MessageContextCreatorForAxis2.getSynapseMessageContext(axis2MsgCtx); }
Example 7
Source File: WebSocketClientHandler.java From micro-integrator with Apache License 2.0 | 5 votes |
private static org.apache.synapse.MessageContext createSynapseMessageContext(String tenantDomain) throws AxisFault { org.apache.axis2.context.MessageContext axis2MsgCtx = createAxis2MessageContext(); ServiceContext svcCtx = new ServiceContext(); OperationContext opCtx = new OperationContext(new InOutAxisOperation(), svcCtx); axis2MsgCtx.setServiceContext(svcCtx); axis2MsgCtx.setOperationContext(opCtx); SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); SOAPEnvelope envelope = fac.getDefaultEnvelope(); axis2MsgCtx.setEnvelope(envelope); return MessageContextCreatorForAxis2.getSynapseMessageContext(axis2MsgCtx); }
Example 8
Source File: MTOMSwAClient.java From micro-integrator with Apache License 2.0 | 4 votes |
public static MessageContext sendUsingSwA(String fileName, String targetEPR) throws IOException { Options options = new Options(); options.setTo(new EndpointReference(targetEPR)); options.setAction("urn:uploadFileUsingSwA"); options.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE); ServiceClient sender = createServiceClient(); sender.setOptions(options); OperationClient mepClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP); MessageContext mc = new MessageContext(); System.out.println("Sending file : " + fileName + " as SwA"); FileDataSource fileDataSource = new FileDataSource(new File(fileName)); DataHandler dataHandler = new DataHandler(fileDataSource); String attachmentID = mc.addAttachment(dataHandler); SOAPFactory factory = OMAbstractFactory.getSOAP11Factory(); SOAPEnvelope env = factory.getDefaultEnvelope(); OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0"); OMElement payload = factory.createOMElement("uploadFileUsingSwA", ns); OMElement request = factory.createOMElement("request", ns); OMElement imageId = factory.createOMElement("imageId", ns); imageId.setText(attachmentID); request.addChild(imageId); payload.addChild(request); env.getBody().addChild(payload); mc.setEnvelope(env); mepClient.addMessageContext(mc); mepClient.execute(true); MessageContext response = mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE); SOAPBody body = response.getEnvelope().getBody(); String imageContentId = body. getFirstChildWithName(new QName("http://services.samples", "uploadFileUsingSwAResponse")). getFirstChildWithName(new QName("http://services.samples", "response")). getFirstChildWithName(new QName("http://services.samples", "imageId")). getText(); Attachments attachment = response.getAttachmentMap(); dataHandler = attachment.getDataHandler(imageContentId); File tempFile = File.createTempFile("swa-", ".gif"); FileOutputStream fos = new FileOutputStream(tempFile); dataHandler.writeTo(fos); fos.flush(); fos.close(); System.out.println("Saved response to file : " + tempFile.getAbsolutePath()); return response; }
Example 9
Source File: MTOMSwAClient.java From micro-integrator with Apache License 2.0 | 4 votes |
public static MessageContext sendUsingSwA(String fileName, String targetEPR) throws IOException { Options options = new Options(); options.setTo(new EndpointReference(targetEPR)); options.setAction("urn:uploadFileUsingSwA"); options.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE); ServiceClient sender = createServiceClient(); sender.setOptions(options); OperationClient mepClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP); MessageContext mc = new MessageContext(); System.out.println("Sending file : " + fileName + " as SwA"); FileDataSource fileDataSource = new FileDataSource(new File(fileName)); DataHandler dataHandler = new DataHandler(fileDataSource); String attachmentID = mc.addAttachment(dataHandler); SOAPFactory factory = OMAbstractFactory.getSOAP11Factory(); SOAPEnvelope env = factory.getDefaultEnvelope(); OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0"); OMElement payload = factory.createOMElement("uploadFileUsingSwA", ns); OMElement request = factory.createOMElement("request", ns); OMElement imageId = factory.createOMElement("imageId", ns); imageId.setText(attachmentID); request.addChild(imageId); payload.addChild(request); env.getBody().addChild(payload); mc.setEnvelope(env); mepClient.addMessageContext(mc); mepClient.execute(true); MessageContext response = mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE); SOAPBody body = response.getEnvelope().getBody(); String imageContentId = body. getFirstChildWithName(new QName("http://services.samples", "uploadFileUsingSwAResponse")). getFirstChildWithName(new QName("http://services.samples", "response")). getFirstChildWithName(new QName("http://services.samples", "imageId")). getText(); Attachments attachment = response.getAttachmentMap(); dataHandler = attachment.getDataHandler(imageContentId); File tempFile = File.createTempFile("swa-", ".gif"); FileOutputStream fos = new FileOutputStream(tempFile); dataHandler.writeTo(fos); fos.flush(); fos.close(); System.out.println("Saved response to file : " + tempFile.getAbsolutePath()); return response; }
Example 10
Source File: DBInOutMessageReceiver.java From micro-integrator with Apache License 2.0 | 4 votes |
/** * Invokes the business logic invocation on the service implementation class * * @param msgContext * the incoming message context * @param newMsgContext * the response message context * @throws AxisFault * on invalid method (wrong signature) or behavior (return null) */ public void invokeBusinessLogic(MessageContext msgContext, MessageContext newMsgContext) throws AxisFault { try { if (log.isDebugEnabled()) { log.debug("Request received to DSS: Data Service - " + msgContext.getServiceContext().getName() + ", Operation - " + msgContext.getSoapAction() + ", Request body - " + msgContext.getEnvelope().getText() + ", ThreadID - " + Thread.currentThread().getId()); } boolean isAcceptJson = false; Map transportHeaders = (Map) msgContext.getProperty(MessageContext.TRANSPORT_HEADERS); if (transportHeaders != null) { String acceptHeader = (String) transportHeaders.get(HTTPConstants.HEADER_ACCEPT); if (acceptHeader != null) { int index = acceptHeader.indexOf(";"); if (index > 0) { acceptHeader = acceptHeader.substring(0, index); } String[] strings = acceptHeader.split(","); for (String string : strings) { String accept = string.trim(); AxisConfiguration configuration = msgContext.getConfigurationContext().getAxisConfiguration(); if (HTTPConstants.MEDIA_TYPE_APPLICATION_JSON.equals(accept) && configuration.getMessageFormatter(accept) != null) { isAcceptJson = true; break; } } } } OMElement result = DataServiceProcessor.dispatch(msgContext); SOAPFactory fac = getSOAPFactory(msgContext); SOAPEnvelope envelope = fac.getDefaultEnvelope(); if (result != null) { envelope.getBody().addChild(result); } newMsgContext.setEnvelope(envelope); if (isAcceptJson) { newMsgContext.setProperty(Constants.Configuration.MESSAGE_TYPE, HTTPConstants.MEDIA_TYPE_APPLICATION_JSON); } } catch (Exception e) { log.error("Error in in-out message receiver", e); msgContext.setProperty(Constants.FAULT_NAME, DBConstants.DS_FAULT_NAME); throw DBUtils.createAxisFault(e); } finally { if (log.isDebugEnabled()) { String response; if (msgContext.getProperty(Constants.FAULT_NAME) != null && msgContext.getProperty(Constants.FAULT_NAME).equals(DBConstants.DS_FAULT_NAME)) { response = "Error in Response"; } else { response = newMsgContext.getEnvelope().getText(); } log.debug("Response send from DSS: Data Service - " + msgContext.getServiceContext().getName() + ", Operation - " + msgContext.getSoapAction() + ", Response body - " + response + ", ThreadID - " + Thread.currentThread().getId()); } } }
Example 11
Source File: MTOMSwAClient.java From product-ei with Apache License 2.0 | 4 votes |
public static MessageContext sendUsingSwA(String fileName, String targetEPR) throws IOException { Options options = new Options(); options.setTo(new EndpointReference(targetEPR)); options.setAction("urn:uploadFileUsingSwA"); options.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE); ServiceClient sender = createServiceClient(); sender.setOptions(options); OperationClient mepClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP); MessageContext mc = new MessageContext(); System.out.println("Sending file : " + fileName + " as SwA"); FileDataSource fileDataSource = new FileDataSource(new File(fileName)); DataHandler dataHandler = new DataHandler(fileDataSource); String attachmentID = mc.addAttachment(dataHandler); SOAPFactory factory = OMAbstractFactory.getSOAP11Factory(); SOAPEnvelope env = factory.getDefaultEnvelope(); OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0"); OMElement payload = factory.createOMElement("uploadFileUsingSwA", ns); OMElement request = factory.createOMElement("request", ns); OMElement imageId = factory.createOMElement("imageId", ns); imageId.setText(attachmentID); request.addChild(imageId); payload.addChild(request); env.getBody().addChild(payload); mc.setEnvelope(env); mepClient.addMessageContext(mc); mepClient.execute(true); MessageContext response = mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE); SOAPBody body = response.getEnvelope().getBody(); String imageContentId = body. getFirstChildWithName(new QName("http://services.samples", "uploadFileUsingSwAResponse")). getFirstChildWithName(new QName("http://services.samples", "response")). getFirstChildWithName(new QName("http://services.samples", "imageId")). getText(); Attachments attachment = response.getAttachmentMap(); dataHandler = attachment.getDataHandler(imageContentId); File tempFile = File.createTempFile("swa-", ".gif"); FileOutputStream fos = new FileOutputStream(tempFile); dataHandler.writeTo(fos); fos.flush(); fos.close(); System.out.println("Saved response to file : " + tempFile.getAbsolutePath()); return response; }