Search in sources :

Example 11 with Path

use of com.predic8.membrane.core.config.Path in project service-proxy by membrane.

the class SOAPFaultTest method getExchangeCP.

private Exchange getExchangeCP(String path) throws IOException {
    Exchange exc = new Exchange(null);
    exc.setResponse(Response.ok().contentType("text/xml").body(getClass().getClassLoader().getResourceAsStream(path), true).build());
    return exc;
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange)

Example 12 with Path

use of com.predic8.membrane.core.config.Path in project service-proxy by membrane.

the class HTTP2XMLInterceptorTest method parseXML.

@Test
public void parseXML() throws Exception {
    String xml = "<request method='POST' http-version='1.1'><uri value='http://localhost:3011/manager/person?vorname=jim&amp;nachname=panse'><host>localhost</host><port>8080</port><path><component>manager</component><component>person</component></path><query><param name='vorname'>jim</param><param name='nachname'>panse</param></query></uri></request>";
    XMLStreamReader r = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xml));
    // skip DocumentNode
    r.next();
    Request req = new Request();
    req.parse(r);
    assertEquals("POST", req.getMethod());
    assertEquals("1.1", req.getHttpVersion());
    assertURI(req.getUri());
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) StringReader(java.io.StringReader) Request(com.predic8.membrane.core.http.xml.Request) Test(org.junit.Test)

Example 13 with Path

use of com.predic8.membrane.core.config.Path in project service-proxy by membrane.

the class EmbeddingJava method main.

public static void main(String[] args) throws Exception {
    String hostname = "*";
    String method = "GET";
    String path = ".*";
    int listenPort = 4000;
    ServiceProxyKey key = new ServiceProxyKey(hostname, method, path, listenPort);
    String targetHost = "predic8.com";
    int targetPort = 80;
    ServiceProxy sp = new ServiceProxy(key, targetHost, targetPort);
    sp.getInterceptors().add(new AddMyHeaderInterceptor());
    HttpRouter router = new HttpRouter();
    router.add(sp);
    router.init();
}
Also used : ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) HttpRouter(com.predic8.membrane.core.HttpRouter)

Example 14 with Path

use of com.predic8.membrane.core.config.Path in project service-proxy by membrane.

the class EtcdBasedConfigurator method setUpModuleServiceProxy.

private ServiceProxy setUpModuleServiceProxy(String name, int port, String path) {
    log.info("Creating serviceProxy for module: " + path);
    ServiceProxyKey key = new ServiceProxyKey("*", "*", path, port);
    key.setUsePathPattern(true);
    key.setPathRegExp(false);
    ServiceProxy sp = new ServiceProxy(key, null, 0);
    sp.getInterceptors().add(new LoadBalancingInterceptor());
    try {
        sp.init(router);
        router.add(sp);
        runningServiceProxyForModule.put(path, sp);
    } catch (Exception ignored) {
    }
    return sp;
}
Also used : LoadBalancingInterceptor(com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor) ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) BeansException(org.springframework.beans.BeansException)

Example 15 with Path

use of com.predic8.membrane.core.config.Path in project service-proxy by membrane.

the class MyApplication method createServiceProxy.

private static ServiceProxy createServiceProxy() {
    String hostname = "*";
    String method = "*";
    String path = ".*";
    int listenPort = 8080;
    ServiceProxyKey key = new ServiceProxyKey(hostname, method, path, listenPort);
    String targetHost = "localhost";
    int targetPort = 2001;
    return new ServiceProxy(key, targetHost, targetPort);
}
Also used : ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy)

Aggregations

Exchange (com.predic8.membrane.core.exchange.Exchange)8 Test (org.junit.Test)6 Request (com.predic8.membrane.core.http.Request)4 ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)4 ServiceProxyKey (com.predic8.membrane.core.rules.ServiceProxyKey)4 Process2 (com.predic8.membrane.examples.Process2)3 Definitions (com.predic8.wsdl.Definitions)3 WSDLParser (com.predic8.wsdl.WSDLParser)3 File (java.io.File)3 IOException (java.io.IOException)3 StringWriter (java.io.StringWriter)3 ParseException (com.floreysoft.jmte.message.ParseException)2 Header (com.predic8.membrane.core.http.Header)2 Response (com.predic8.membrane.core.http.Response)2 AbstractServiceProxy (com.predic8.membrane.core.rules.AbstractServiceProxy)2 ProxiesXmlUtil (com.predic8.membrane.examples.ProxiesXmlUtil)2 RequestTemplateCreator (com.predic8.wstool.creator.RequestTemplateCreator)2 SOARequestCreator (com.predic8.wstool.creator.SOARequestCreator)2 MarkupBuilder (groovy.xml.MarkupBuilder)2 MalformedURLException (java.net.MalformedURLException)2