Search in sources :

Example 26 with EndpointReference

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());
    }
}
Also used : SynapseSubscription(org.apache.synapse.eventing.SynapseSubscription) MessageContext(org.apache.axis2.context.MessageContext) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 27 with EndpointReference

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());
    }
}
Also used : SynapseSubscription(org.apache.synapse.eventing.SynapseSubscription) Calendar(java.util.Calendar) MessageContext(org.apache.axis2.context.MessageContext) Date(java.util.Date) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 28 with EndpointReference

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;
}
Also used : OperationContext(org.apache.axis2.context.OperationContext) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ServiceContext(org.apache.axis2.context.ServiceContext) TransportInDescription(org.apache.axis2.description.TransportInDescription) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) EndpointReference(org.apache.axis2.addressing.EndpointReference) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) MessageContext(org.apache.synapse.MessageContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) InOutAxisOperation(org.apache.axis2.description.InOutAxisOperation) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext)

Example 29 with EndpointReference

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);
}
Also used : Policy(org.apache.neethi.Policy) Options(org.apache.axis2.client.Options) HttpTransportProperties(org.apache.axis2.transport.http.HttpTransportProperties) ServiceClient(org.apache.axis2.client.ServiceClient) URL(java.net.URL) FileInputStream(java.io.FileInputStream) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 30 with EndpointReference

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);
}
Also used : Options(org.apache.axis2.client.Options) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) ServiceClient(org.apache.axis2.client.ServiceClient) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Aggregations

EndpointReference (org.apache.axis2.addressing.EndpointReference)126 Options (org.apache.axis2.client.Options)49 ServiceClient (org.apache.axis2.client.ServiceClient)29 OMElement (org.apache.axiom.om.OMElement)26 AxisFault (org.apache.axis2.AxisFault)26 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)25 MessageContext (org.apache.axis2.context.MessageContext)25 MessageContext (org.apache.synapse.MessageContext)25 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)25 Map (java.util.Map)20 Test (org.junit.Test)14 URL (java.net.URL)13 HttpTransportProperties (org.apache.axis2.transport.http.HttpTransportProperties)13 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)13 QName (javax.xml.namespace.QName)12 AxisService (org.apache.axis2.description.AxisService)12 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)11 MalformedURLException (java.net.MalformedURLException)10 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)10