Search in sources :

Example 21 with EndpointDefinition

use of org.apache.synapse.endpoints.EndpointDefinition in project wso2-synapse by wso2.

the class SynapseEventSource method getEndpointFromURL.

/**
 * Create a Endpoint for a given URL
 *
 * @param endpointUrl      URL
 * @param se    synapse environment
 * @return AddressEndpoint address endpoint
 */
private Endpoint getEndpointFromURL(String endpointUrl, SynapseEnvironment se) {
    AddressEndpoint endpoint = new AddressEndpoint();
    EndpointDefinition def = new EndpointDefinition();
    def.setAddress(endpointUrl.trim());
    endpoint.setDefinition(def);
    endpoint.init(se);
    return endpoint;
}
Also used : AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) EndpointDefinition(org.apache.synapse.endpoints.EndpointDefinition)

Example 22 with EndpointDefinition

use of org.apache.synapse.endpoints.EndpointDefinition in project wso2-synapse by wso2.

the class ProxyServiceTest method testBuildAxisServiceWithFaultyPublishWsdlEndpoint.

/**
 * Tests building a proxy service with a faulty wsdl endpoint specified as the wsdl endpoint.
 *
 * @throws Exception if an error occurs when converting the URI string to a URI
 */
public void testBuildAxisServiceWithFaultyPublishWsdlEndpoint() throws Exception {
    SynapseConfiguration synCfg = new SynapseConfiguration();
    AxisConfiguration axisCfg = new AxisConfiguration();
    ProxyService proxyService = new ProxyService("faultyPublishWsdlEndpointProxy");
    proxyService.setPublishWSDLEndpoint("wsdlEndPoint");
    try {
        proxyService.buildAxisService(synCfg, axisCfg);
        Assert.fail("Axis service built with null wsdl endpoint should throw fault");
    } catch (SynapseException e) {
        Assert.assertEquals("Unexpected exception thrown: " + e, "Unable to resolve WSDL url. wsdlEndPoint is null", e.getMessage());
    }
    AddressEndpoint wsdlEndpoint = new AddressEndpoint();
    EndpointDefinition endpointDefinition = new EndpointDefinition();
    endpointDefinition.setAddress(getClass().getResource("SimpleStockService.wsdl").toURI().toString());
    wsdlEndpoint.setDefinition(endpointDefinition);
    synCfg.addEndpoint("wsdlEndPoint", wsdlEndpoint);
    try {
        proxyService.buildAxisService(synCfg, axisCfg);
        Assert.fail("Axis service built with faulty wsdl endpoint should be null");
    } catch (SynapseException e) {
        Assert.assertEquals("Unexpected exception thrown: " + e, "Error building service from WSDL", e.getMessage());
    }
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) SynapseException(org.apache.synapse.SynapseException) EndpointDefinition(org.apache.synapse.endpoints.EndpointDefinition) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration)

Example 23 with EndpointDefinition

use of org.apache.synapse.endpoints.EndpointDefinition in project wso2-synapse by wso2.

the class WeightedRRLCAlgorithmTest method createEndpoints.

private List<Endpoint> createEndpoints() {
    List<Endpoint> endpoints = new ArrayList<Endpoint>();
    for (int i = 0; i < hosts.length; i++) {
        AddressEndpoint addressEndpoint = new AddressEndpoint();
        EndpointDefinition definition = new EndpointDefinition();
        definition.setAddress("http://" + hosts[i] + "/");
        addressEndpoint.setDefinition(definition);
        MediatorProperty property = new MediatorProperty();
        property.setName(WeightedRRLCAlgorithm.LB_WEIGHTED_RRLC_WEIGHT);
        property.setValue(weights[i]);
        addressEndpoint.addProperty(property);
        endpoints.add(addressEndpoint);
    }
    return endpoints;
}
Also used : AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) MediatorProperty(org.apache.synapse.mediators.MediatorProperty) AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) Endpoint(org.apache.synapse.endpoints.Endpoint) LoadbalanceEndpoint(org.apache.synapse.endpoints.LoadbalanceEndpoint) ArrayList(java.util.ArrayList) EndpointDefinition(org.apache.synapse.endpoints.EndpointDefinition) AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) Endpoint(org.apache.synapse.endpoints.Endpoint) LoadbalanceEndpoint(org.apache.synapse.endpoints.LoadbalanceEndpoint)

Example 24 with EndpointDefinition

use of org.apache.synapse.endpoints.EndpointDefinition in project wso2-synapse by wso2.

the class DynamicEndpointTest method testContextProperties.

public void testContextProperties() throws Exception {
    SynapseXPath xpath = new SynapseXPath("$ctx:timeout");
    AbstractEndpoint endpoint = new AddressEndpoint();
    EndpointDefinition definition = new EndpointDefinition();
    endpoint.setDefinition(definition);
    definition.setDynamicTimeoutExpression(xpath);
    MessageContext synCtx = new TestMessageContext();
    synCtx.setProperty("timeout", "90000");
    assertEquals(Long.valueOf((String) xpath.evaluate(synCtx)).longValue(), endpoint.getDefinition().evaluateDynamicEndpointTimeout(synCtx));
}
Also used : SynapseXPath(org.apache.synapse.util.xpath.SynapseXPath) AbstractEndpoint(org.apache.synapse.endpoints.AbstractEndpoint) AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) TestMessageContext(org.apache.synapse.TestMessageContext) EndpointDefinition(org.apache.synapse.endpoints.EndpointDefinition) TestMessageContext(org.apache.synapse.TestMessageContext) MessageContext(org.apache.synapse.MessageContext)

Aggregations

EndpointDefinition (org.apache.synapse.endpoints.EndpointDefinition)24 OMElement (org.apache.axiom.om.OMElement)10 AddressEndpoint (org.apache.synapse.endpoints.AddressEndpoint)10 QName (javax.xml.namespace.QName)6 OMAttribute (org.apache.axiom.om.OMAttribute)6 SynapseException (org.apache.synapse.SynapseException)6 MessageContext (org.apache.synapse.MessageContext)4 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)4 DefaultEndpoint (org.apache.synapse.endpoints.DefaultEndpoint)4 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)3 AbstractEndpoint (org.apache.synapse.endpoints.AbstractEndpoint)3 SynapseXPath (org.apache.synapse.util.xpath.SynapseXPath)3 IOException (java.io.IOException)2 URI (java.net.URI)2 AxisFault (org.apache.axis2.AxisFault)2 TestMessageContext (org.apache.synapse.TestMessageContext)2 Endpoint (org.apache.synapse.endpoints.Endpoint)2 HTTPEndpoint (org.apache.synapse.endpoints.HTTPEndpoint)2 WSDLEndpoint (org.apache.synapse.endpoints.WSDLEndpoint)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1