use of org.apache.axis2.addressing.EndpointReference in project tdi-studio-se by Talend.
the class MSCRMClient method setServiceClientOptions.
private static void setServiceClientOptions(ServiceClient sc, SecurityData securityData) throws AxisFault, XMLStreamException {
Options options = sc.getOptions();
options.setMessageId("urn:uuid:" + UUID.randomUUID().toString());
EndpointReference endPoint = new EndpointReference("http://www.w3.org/2005/08/addressing/anonymous");
options.setReplyTo(endPoint);
sc.setOptions(options);
sc.addHeader(createCRMSecurityHeaderBlock(securityData));
HttpTransportProperties.ProxyProperties proxyProps = getProxyProperties();
if (proxyProps != null) {
sc.getOptions().setProperty(HTTPConstants.PROXY, proxyProps);
}
try {
sc.engageModule("addressing");
} catch (AxisFault e) {
logger.error(e.getMessage());
throw e;
}
}
use of org.apache.axis2.addressing.EndpointReference in project wso2-axis2-transports by wso2.
the class XMPPPacketListener method createMessageContext.
/**
* Creates message context using values received in XMPP packet
* @param packet
* @return MessageContext
* @throws AxisFault
*/
private MessageContext createMessageContext(Packet packet) throws AxisFault {
Message message = (Message) packet;
Boolean isServerSide = (Boolean) message.getProperty(XMPPConstants.IS_SERVER_SIDE);
String serviceName = (String) message.getProperty(XMPPConstants.SERVICE_NAME);
String action = (String) message.getProperty(XMPPConstants.ACTION);
MessageContext msgContext = null;
TransportInDescription transportIn = configurationContext.getAxisConfiguration().getTransportIn("xmpp");
TransportOutDescription transportOut = configurationContext.getAxisConfiguration().getTransportOut("xmpp");
if ((transportIn != null) && (transportOut != null)) {
msgContext = configurationContext.createMessageContext();
msgContext.setTransportIn(transportIn);
msgContext.setTransportOut(transportOut);
if (isServerSide != null) {
msgContext.setServerSide(isServerSide.booleanValue());
}
msgContext.setProperty(CONTENT_TYPE, "text/xml");
msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, "UTF-8");
msgContext.setIncomingTransportName("xmpp");
Map services = configurationContext.getAxisConfiguration().getServices();
AxisService axisService = (AxisService) services.get(serviceName);
msgContext.setAxisService(axisService);
msgContext.setSoapAction(action);
// pass the configurationFactory to transport sender
msgContext.setProperty("XMPPConfigurationFactory", this.xmppConnectionFactory);
if (packet.getFrom() != null) {
msgContext.setFrom(new EndpointReference(packet.getFrom()));
}
if (packet.getTo() != null) {
msgContext.setTo(new EndpointReference(packet.getTo()));
}
XMPPOutTransportInfo xmppOutTransportInfo = new XMPPOutTransportInfo();
xmppOutTransportInfo.setConnectionFactory(this.xmppConnectionFactory);
String packetFrom = packet.getFrom();
if (packetFrom != null) {
EndpointReference fromEPR = new EndpointReference(packetFrom);
xmppOutTransportInfo.setFrom(fromEPR);
xmppOutTransportInfo.setDestinationAccount(packetFrom);
}
// Save Message-Id to set as In-Reply-To on reply
String xmppMessageId = packet.getPacketID();
if (xmppMessageId != null) {
xmppOutTransportInfo.setInReplyTo(xmppMessageId);
}
xmppOutTransportInfo.setSequenceID((String) message.getProperty(XMPPConstants.SEQUENCE_ID));
msgContext.setProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO, xmppOutTransportInfo);
buildSOAPEnvelope(packet, msgContext);
} else {
throw new AxisFault("Either transport in or transport out is null");
}
return msgContext;
}
use of org.apache.axis2.addressing.EndpointReference in project wso2-axis2-transports by wso2.
the class SMSManager method dispatchToAxis2.
/**
* Dispatch the SMS message to Axis2 Engine
* @param sms
*/
public void dispatchToAxis2(SMSMessage sms) {
try {
MessageContext msgctx = messageBuilder.buildMessaage(sms, configurationContext);
msgctx.setReplyTo(new EndpointReference("sms://" + sms.getSender() + "/"));
AxisEngine.receive(msgctx);
} catch (InvalidMessageFormatException e) {
log.debug("Invalid message format " + e);
} catch (AxisFault axisFault) {
log.debug(axisFault);
} catch (Throwable e) {
log.debug("Unknown Exception ", e);
}
}
use of org.apache.axis2.addressing.EndpointReference in project wso2-synapse by wso2.
the class JsonStreamBuilder method processDocument.
public OMElement processDocument(InputStream inputStream, String s, MessageContext messageContext) throws AxisFault {
if (inputStream != null) {
OMElement element = JsonUtil.getNewJsonPayload(messageContext, inputStream, false, false);
if (element != null) {
if (logger.isDebugEnabled()) {
logger.debug("#processDocument. Built JSON payload from JSON stream. MessageID: " + messageContext.getMessageID());
}
return element;
}
} else {
EndpointReference endpointReference = messageContext.getTo();
if (endpointReference == null) {
logger.error("#processDocument. Cannot build payload without a valid EPR. MessageID: " + messageContext.getMessageID());
throw new AxisFault("Cannot build payload without a valid EPR.");
}
String requestURL;
try {
requestURL = URIEncoderDecoder.decode(endpointReference.getAddress());
} catch (UnsupportedEncodingException e) {
logger.error("#processDocument. Could not decode request URL. MessageID: " + messageContext.getMessageID());
throw new AxisFault("Could not decode request URL.", e);
}
String jsonString;
int index;
// half as the incoming JSON message
if ((index = requestURL.indexOf('=')) > 0) {
jsonString = requestURL.substring(index + 1);
messageContext.setProperty(Constants.JSON_STRING, jsonString);
ByteArrayInputStream is = new ByteArrayInputStream(jsonString.getBytes());
return processDocument(is, s, messageContext);
} else {
messageContext.setProperty(Constants.JSON_STRING, null);
}
}
if (logger.isDebugEnabled()) {
logger.debug("#processDocument. No JSON payload found in request. MessageID: " + messageContext.getMessageID());
}
SOAPFactory factory = OMAbstractFactory.getSOAP12Factory();
return factory.getDefaultEnvelope();
}
use of org.apache.axis2.addressing.EndpointReference in project wso2-synapse by wso2.
the class XFormURLEncodedBuilder method processDocumentWrapper.
/**
* @return Returns the document element.
*/
private OMElement processDocumentWrapper(InputStream inputStream, String contentType, MessageContext messageContext) throws AxisFault {
MultipleEntryHashMap parameterMap = new MultipleEntryHashMap();
SOAPFactory soapFactory;
AxisBindingOperation axisBindingOperation = (AxisBindingOperation) messageContext.getProperty(Constants.AXIS_BINDING_OPERATION);
String queryParameterSeparator = null;
String templatedPath = null;
if (axisBindingOperation != null) {
queryParameterSeparator = (String) axisBindingOperation.getProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR);
templatedPath = (String) axisBindingOperation.getProperty(WSDL2Constants.ATTR_WHTTP_LOCATION);
}
if (queryParameterSeparator == null) {
queryParameterSeparator = WSDL20DefaultValueHolder.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR_DEFAULT;
}
AxisEndpoint axisEndpoint = (AxisEndpoint) messageContext.getProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME);
if (axisEndpoint != null) {
AxisBinding axisBinding = axisEndpoint.getBinding();
String soapVersion = (String) axisBinding.getProperty(WSDL2Constants.ATTR_WSOAP_VERSION);
soapFactory = getSOAPFactory(soapVersion);
} else {
soapFactory = getSOAPFactory(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
}
EndpointReference endpointReference = messageContext.getTo();
if (endpointReference == null) {
throw new AxisFault("Cannot create DocumentElement without destination EPR");
}
String requestURL = endpointReference.getAddress();
try {
requestURL = extractParametersUsingHttpLocation(templatedPath, parameterMap, requestURL, queryParameterSeparator);
} catch (UnsupportedEncodingException e) {
throw AxisFault.makeFault(e);
}
String query = requestURL;
int index;
if ((index = requestURL.indexOf("?")) > -1) {
query = requestURL.substring(index + 1);
}
extractParametersFromRequest(parameterMap, query, queryParameterSeparator, (String) messageContext.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING), inputStream);
messageContext.setProperty(Constants.REQUEST_PARAMETER_MAP, parameterMap);
return BuilderUtil.buildsoapMessage(messageContext, parameterMap, soapFactory);
}
Aggregations