Examples of OutboundEndpoint


Examples of org.mule.api.endpoint.OutboundEndpoint

            // Get the dispatch endpoint
            String uri = msgContext.getStrProp(MessageContext.TRANS_URL);
            ImmutableEndpoint requestEndpoint = (ImmutableEndpoint)call
                .getProperty(MuleProperties.MULE_ENDPOINT_PROPERTY);
           
            OutboundEndpoint endpoint;
       
            // put username and password in URI if they are set on the current event
            if (msgContext.getUsername() != null)
            {
                String[] tempEndpoint = uri.split("//");
                String credentialString = msgContext.getUsername() + ":"
                                          + msgContext.getPassword();
                uri = tempEndpoint[0] + "//" + credentialString + "@" + tempEndpoint[1];
                endpoint = lookupEndpoint(uri);
            }
            else
            {
                endpoint = lookupEndpoint(uri);
            }

            if (requestEndpoint.getConnector() instanceof AxisConnector)
            {
                msgContext.setTypeMappingRegistry(((AxisConnector)requestEndpoint.getConnector())
                    .getAxis().getTypeMappingRegistry());
            }
           
            Map<String, Object> props = new HashMap<String, Object>();
            Object payload;
            int contentLength = 0;
            String contentType = null;
            if (msgContext.getRequestMessage().countAttachments() > 0)
            {
                File temp = File.createTempFile("soap", ".tmp");
                temp.deleteOnExit(); // TODO cleanup files earlier (IOUtils has a
                // file tracker)
                FileOutputStream fos = new FileOutputStream(temp);
                msgContext.getRequestMessage().writeTo(fos);
                fos.close();
                contentLength = (int)temp.length();
                payload = new FileInputStream(temp);
                contentType = "multipart/related";
            }
            else
            {
                ByteArrayOutputStream baos = new ByteArrayOutputStream(8192);
                msgContext.getRequestMessage().writeTo(baos);
                baos.close();
                payload = baos.toByteArray();
            }

            // props.putAll(event.getProperties());
            for (Iterator iterator = msgContext.getPropertyNames(); iterator.hasNext();)
            {
                String name = (String)iterator.next();
                if (!name.equals("call_object") && !name.equals("wsdl.service"))
                {
                    props.put(name, msgContext.getProperty(name));
                }
            }

            // add all custom headers, filter out all mule headers (such as
            // MULE_SESSION) except
            // for MULE_USER header. Filter out other headers like "soapMethods" and
            // MuleProperties.MULE_METHOD_PROPERTY and "soapAction"
            // and also filter out any http related header
            if ((RequestContext.getEvent() != null)
                && (RequestContext.getEvent().getMessage() != null))
            {
                props = AxisCleanAndAddProperties.cleanAndAdd(RequestContext.getEventContext());
            }
           
            // with jms and vm the default SOAPAction will result in the name of the endpoint, which we may not necessarily want. This should be set manually on the endpoint
            String scheme = requestEndpoint.getEndpointURI().getScheme();
            if (!("vm".equalsIgnoreCase(scheme) || "jms".equalsIgnoreCase(scheme)))
            {
                if (call.useSOAPAction())
                {
                    uri = call.getSOAPActionURI();
                }
                props.put(SoapConstants.SOAP_ACTION_PROPERTY_CAPS, uri);
            }
            if (contentLength > 0)
            {
                props.put(HttpConstants.HEADER_CONTENT_LENGTH, Integer.toString(contentLength)); // necessary
                // for
                // supporting
                // httpclient
            }

           
            if (props.get(HttpConstants.HEADER_CONTENT_TYPE) == null)
            {
                if (contentType == null)
                {
                    contentType = "text/xml";
                }
               
                props.put(HttpConstants.HEADER_CONTENT_TYPE, contentType);
            }
            MuleMessage message = new DefaultMuleMessage(payload, props, muleContext);
            MuleSession session;

            if(event != null)
            {
                session = event.getSession();
            }
            else
            {
                session = new DefaultMuleSession(muleContext);
            }

            logger.info("Making Axis soap request on: " + uri);
            if (logger.isDebugEnabled())
            {
                logger.debug("Soap request is:\n" + new String((payload instanceof byte[] ? (byte[])payload : payload.toString().getBytes())));
            }

            if (sync)
            {
                EndpointBuilder builder = new EndpointURIEndpointBuilder(endpoint);
                builder.setExchangePattern(MessageExchangePattern.REQUEST_RESPONSE);
                OutboundEndpoint syncEndpoint = muleContext.getRegistry()
                    .lookupEndpointFactory()
                    .getOutboundEndpoint(builder);
                MuleEvent dispatchEvent = new DefaultMuleEvent(message,
                    MessageExchangePattern.REQUEST_RESPONSE, session);
                MuleMessage result = null;
                MuleEvent resultEvent = syncEndpoint.process(dispatchEvent);
                if (resultEvent != null)
                {
                    result = resultEvent.getMessage();
                }
View Full Code Here

Examples of org.mule.api.endpoint.OutboundEndpoint

    protected OutboundEndpoint lookupEndpoint(String uri) throws MuleException
    {
        Service axis = muleContext.getRegistry().lookupService(AxisConnector.AXIS_SERVICE_COMPONENT_NAME);
        EndpointURI endpoint = new MuleEndpointURI(uri, muleContext);

        OutboundEndpoint ep;

        if (axis != null)
        {
            synchronized (endpointsCache)
            {
View Full Code Here

Examples of org.mule.api.endpoint.OutboundEndpoint

public class SoapActionTemplateTestCase extends AbstractMuleTestCase
{
    public void testHostInfoReplace() throws Exception
    {
        OutboundEndpoint ep = muleContext.getEndpointFactory().getOutboundEndpoint(
            "axis:http://mycompany.com:8080/services/myService?method=foo");
       
        AxisMessageDispatcher dispatcher = new AxisMessageDispatcher(ep);
        MuleEvent event = getTestEvent("test,");
        String result = dispatcher.parseSoapAction("#[hostInfo]/#[method]", new QName("foo"), event);
View Full Code Here

Examples of org.mule.api.endpoint.OutboundEndpoint

        assertEquals("http://mycompany.com:8080/foo", result);
    }

    public void testHostReplace() throws Exception
    {
        OutboundEndpoint ep = muleContext.getEndpointFactory().getOutboundEndpoint(
            "axis:http://mycompany.com:8080/services/myService?method=foo");
        AxisMessageDispatcher dispatcher = new AxisMessageDispatcher(ep);
        MuleEvent event = getTestEvent("test,");
        String name = event.getFlowConstruct().getName();
        String result = dispatcher.parseSoapAction("#[scheme]://#[host]:#[port]/#[serviceName]/#[method]",
View Full Code Here

Examples of org.mule.api.endpoint.OutboundEndpoint

     * @throws org.mule.api.MuleException
     */
    public void dispatch(String url, Object payload, Map messageProperties) throws MuleException
    {
        MuleMessage message = new DefaultMuleMessage(payload, messageProperties, muleContext);
        OutboundEndpoint endpoint = muleContext.getEndpointFactory().getOutboundEndpoint(url);
        MuleEvent event = getEvent(message,endpoint);
        try
        {
            endpoint.process(event);
        }
        catch (MuleException e)
        {
            throw e;
        }
View Full Code Here

Examples of org.mule.api.endpoint.OutboundEndpoint

     * @throws org.mule.api.MuleException
     */
    public MuleMessage send(String url, Object payload, Map messageProperties) throws MuleException
    {
        MuleMessage message = new DefaultMuleMessage(payload, messageProperties, muleContext);
        OutboundEndpoint endpoint = getOutboundEndpoint(url, MessageExchangePattern.REQUEST_RESPONSE);
        MuleEvent event = getEvent(message, endpoint);

        try
        {
            MuleEvent resultEvent = endpoint.process(event);
            if (resultEvent != null)
            {
                return resultEvent.getMessage();
            }
            else
View Full Code Here

Examples of org.mule.api.endpoint.OutboundEndpoint

public class AxisMessageDispatcherTestCase extends AbstractMuleTestCase
{
    public void testNullParametersInCallAllowed() throws Exception
    {
        OutboundEndpoint ep = muleContext.getEndpointFactory().getOutboundEndpoint(
            "axis:http://www.muleumo.org/services/myService?method=myTestMethod");
        AxisMessageDispatcher dispatcher = new AxisMessageDispatcher(ep);
        dispatcher.service = new Service();
        MuleEvent event = getTestEvent("testPayload");
        // there should be no NullPointerException
View Full Code Here

Examples of org.mule.api.endpoint.OutboundEndpoint

                InboundEndpoint ei = client.getInboundEndpoint(uri.getUri());
                uri.checkResultUri(ei);
            }
            if (!uri.getUri().startsWith("imap:"))
            {
                OutboundEndpoint oi = client.getOutboundEndpoint(uri.getUri());
                uri.checkResultUri(oi);
            }
        }
    }
View Full Code Here

Examples of org.mule.api.endpoint.OutboundEndpoint

    public void testOutputAppendEndpointOverride() throws Exception
    {
        FileConnector connector = (FileConnector) getConnector();

        EndpointBuilder endpointBuilder = new EndpointURIEndpointBuilder(new URIBuilder("file://foo", muleContext));
        OutboundEndpoint endpoint = endpointBuilder.buildOutboundEndpoint();

        // Endpoint wants String-typed properties
        endpoint.getProperties().put("outputAppend", "true");

        try
        {
            connector.getDispatcherFactory().create(endpoint);
            fail("outputAppend cannot be configured on File endpoints");
View Full Code Here

Examples of org.mule.api.endpoint.OutboundEndpoint

        assertEquals(e.getClass().getName() + ": " + msg, e.toString());
    }

    public final void testRoutingExceptionNullMessageValidEndpoint() throws MuleException
    {
        OutboundEndpoint endpoint = muleContext.getEndpointFactory().getOutboundEndpoint("test://outbound");
        assertNotNull(endpoint);

        RoutingException rex = new RoutingException((MuleEvent) null, endpoint);
        assertSame(endpoint, rex.getRoute());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.