use of org.apache.axis2.addressing.EndpointReference in project wso2-synapse by wso2.
the class MessageBuilderTest method testSubscriptionMessageBuilderScenarioFour.
public void testSubscriptionMessageBuilderScenarioFour() {
String addressUrl = "http://synapse.test.com/eventing/subscriptions";
String message = "<wse:GetStatus xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\"/>";
try {
MessageContext msgCtx = TestUtils.getAxis2MessageContext(message, null).getAxis2MessageContext();
msgCtx.setTo(new EndpointReference(addressUrl));
String id = addIdentifierHeader(msgCtx);
SubscriptionMessageBuilder.resetErrorInfo();
SynapseSubscription sub = SubscriptionMessageBuilder.createGetStatusMessage(msgCtx);
assertEquals(id, sub.getId());
assertEquals(addressUrl, sub.getAddressUrl());
assertNull(SubscriptionMessageBuilder.getErrorCode());
assertNull(SubscriptionMessageBuilder.getErrorReason());
assertNull(SubscriptionMessageBuilder.getErrorSubCode());
} catch (Exception e) {
e.printStackTrace();
fail("Error while constructing the sample subscription request: " + e.getMessage());
}
}
use of org.apache.axis2.addressing.EndpointReference in project wso2-synapse by wso2.
the class MessageBuilderTest method testSubscriptionMessageBuilderScenarioThree.
public void testSubscriptionMessageBuilderScenarioThree() {
String addressUrl = "http://synapse.test.com/eventing/subscriptions";
Date date = new Date(System.currentTimeMillis() + 3600000);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
String message = "<wse:Renew xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\">\n" + " <wse:Expires>" + ConverterUtil.convertToString(cal) + "</wse:Expires>\n" + "</wse:Renew>";
try {
MessageContext msgCtx = TestUtils.getAxis2MessageContext(message, null).getAxis2MessageContext();
msgCtx.setTo(new EndpointReference(addressUrl));
String id = addIdentifierHeader(msgCtx);
SubscriptionMessageBuilder.resetErrorInfo();
SynapseSubscription sub = SubscriptionMessageBuilder.createRenewSubscribeMessage(msgCtx);
assertEquals(id, sub.getId());
assertEquals(addressUrl, sub.getAddressUrl());
assertEquals(date, sub.getExpires().getTime());
assertNull(SubscriptionMessageBuilder.getErrorCode());
assertNull(SubscriptionMessageBuilder.getErrorReason());
assertNull(SubscriptionMessageBuilder.getErrorSubCode());
} catch (Exception e) {
e.printStackTrace();
fail("Error while constructing the sample subscription request: " + e.getMessage());
}
}
use of org.apache.axis2.addressing.EndpointReference in project wso2-synapse by wso2.
the class DynamicLoadBalanceEndpointTest method createMessageContext.
/**
* Create a empty message context
*
* @return A context with empty message
* @throws AxisFault on an error creating a context
*/
private MessageContext createMessageContext() throws AxisFault {
Axis2SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(new SynapseConfiguration());
org.apache.axis2.context.MessageContext axis2MC = new org.apache.axis2.context.MessageContext();
axis2MC.setConfigurationContext(new ConfigurationContext(new AxisConfiguration()));
ServiceContext svcCtx = new ServiceContext();
OperationContext opCtx = new OperationContext(new InOutAxisOperation(), svcCtx);
axis2MC.setServiceContext(svcCtx);
axis2MC.setOperationContext(opCtx);
axis2MC.setTransportIn(new TransportInDescription("http"));
axis2MC.setTo(new EndpointReference("http://localhost:9000/services/SimpleStockQuoteService"));
MessageContext mc = new Axis2MessageContext(axis2MC, new SynapseConfiguration(), synapseEnvironment);
mc.setMessageID(UIDGenerator.generateURNString());
mc.setEnvelope(OMAbstractFactory.getSOAP12Factory().createSOAPEnvelope());
mc.getEnvelope().addChild(OMAbstractFactory.getSOAP12Factory().createSOAPBody());
return mc;
}
use of org.apache.axis2.addressing.EndpointReference in project wso2-synapse by wso2.
the class StockQuoteSampleClient method init.
private void init(String addUrl, String trpUrl, String prxUrl, String policyKey, long timeout) throws Exception {
if (log.isDebugEnabled()) {
log.debug("Initializing sample Axis2 client");
}
configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(clientConfig.getClientRepo(), clientConfig.getAxis2Xml());
serviceClient = new ServiceClient(configContext, null);
Options options = new Options();
if (addUrl != null && !"".equals(addUrl)) {
serviceClient.engageModule("addressing");
options.setTo(new EndpointReference(addUrl));
}
if (trpUrl != null && !"".equals(trpUrl)) {
options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl);
}
if (prxUrl != null && !"".equals(prxUrl)) {
HttpTransportProperties.ProxyProperties proxyProperties = new HttpTransportProperties.ProxyProperties();
URL url = new URL(prxUrl);
proxyProperties.setProxyName(url.getHost());
proxyProperties.setProxyPort(url.getPort());
proxyProperties.setUserName("");
proxyProperties.setPassWord("");
proxyProperties.setDomain("");
options.setProperty(HTTPConstants.PROXY, proxyProperties);
}
if (policyKey != null && !"".equals(policyKey)) {
log.info("Using WS-Security");
serviceClient.engageModule("addressing");
serviceClient.engageModule("rampart");
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(new FileInputStream(policyKey));
Policy policy = PolicyEngine.getPolicy(builder.getDocumentElement());
options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy);
}
if (timeout > 0) {
log.info("setting client timeout to: " + timeout);
options.setTimeOutInMilliSeconds(timeout);
}
options.setProperty(HTTPConstants.HTTP_HEADERS, httpHeaders);
serviceClient.setOptions(options);
}
use of org.apache.axis2.addressing.EndpointReference in project wso2-synapse by wso2.
the class EventSampleClient method initializeClient.
private void initializeClient(String addUrl) throws Exception {
options = new Options();
ConfigurationContext configContext;
configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(configuration.getClientRepo(), configuration.getAxis2Xml());
serviceClient = new ServiceClient(configContext, null);
if (addUrl != null && !"null".equals(addUrl)) {
serviceClient.engageModule("addressing");
options.setTo(new EndpointReference(addUrl));
}
serviceClient.setOptions(options);
message = factory.createOMElement("message", null);
}
Aggregations