Search in sources :

Example 11 with Mapping

use of com.predic8.membrane.core.interceptor.administration.Mapping in project service-proxy by membrane.

the class REST2SOAPInterceptorIntegrationTest method getMappings.

private List<Mapping> getMappings() {
    List<Mapping> mappings = new ArrayList<Mapping>();
    Mapping m = new Mapping();
    m.regex = "/bank/.*";
    m.soapAction = "";
    m.soapURI = "/axis2/services/BLZService";
    m.requestXSLT = "classpath:/blz-httpget2soap-request.xsl";
    m.responseXSLT = "classpath:/strip-soap-envelope.xsl";
    mappings.add(m);
    return mappings;
}
Also used : Mapping(com.predic8.membrane.core.interceptor.rest.REST2SOAPInterceptor.Mapping)

Example 12 with Mapping

use of com.predic8.membrane.core.interceptor.administration.Mapping in project service-proxy by membrane.

the class RewriteInterceptorTest method setUp.

@Before
public void setUp() throws Exception {
    HttpRouter router = new HttpRouter();
    di = new DispatchingInterceptor();
    di.init(router);
    sp = new ServiceProxy(new ServiceProxyKey(80, null), "www.predic8.de", 80);
    sp.init(router);
    exc = new Exchange(null);
    exc.setRequest(MessageUtil.getGetRequest("/buy/banana/3"));
    rewriter = new RewriteInterceptor();
    List<Mapping> mappings = new ArrayList<Mapping>();
    mappings.add(new Mapping("/buy/(.*)/(.*)", "/buy?item=$1&amount=$2", null));
    rewriter.setMappings(mappings);
    rewriter.init(router);
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) ArrayList(java.util.ArrayList) Mapping(com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor.Mapping) HttpRouter(com.predic8.membrane.core.HttpRouter) DispatchingInterceptor(com.predic8.membrane.core.interceptor.DispatchingInterceptor) Before(org.junit.Before)

Example 13 with Mapping

use of com.predic8.membrane.core.interceptor.administration.Mapping in project service-proxy by membrane.

the class RESTBLZServiceIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "*", ".*", 3005), "thomas-bayer.com", 80);
    router = new HttpRouter();
    router.getRuleManager().addProxyAndOpenPortIfNew(rule);
    HTTP2XMLInterceptor http2xml = new HTTP2XMLInterceptor();
    router.getTransport().getInterceptors().add(http2xml);
    RewriteInterceptor urlRewriter = new RewriteInterceptor();
    List<Mapping> mappings = new ArrayList<Mapping>();
    mappings.add(new Mapping("/bank/.*", "/axis2/services/BLZService", null));
    urlRewriter.setMappings(mappings);
    router.getTransport().getInterceptors().add(urlRewriter);
    XSLTInterceptor xslt = new XSLTInterceptor();
    xslt.setXslt("classpath:/blz-httpget2soap-request.xsl");
    xslt.setFlow(Flow.Set.REQUEST);
    xslt.setXslt("classpath:/strip-soap-envelope.xsl");
    xslt.setFlow(Flow.Set.RESPONSE);
    router.getTransport().getInterceptors().add(xslt);
}
Also used : Mapping(com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor.Mapping) Rule(com.predic8.membrane.core.rules.Rule) HttpRouter(com.predic8.membrane.core.HttpRouter) XSLTInterceptor(com.predic8.membrane.core.interceptor.xslt.XSLTInterceptor)

Example 14 with Mapping

use of com.predic8.membrane.core.interceptor.administration.Mapping in project service-proxy by membrane.

the class RewriteInterceptorIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    interceptor = new RewriteInterceptor();
    interceptor.getMappings().add(new Mapping("/blz-service\\?wsdl", "/axis2/services/BLZService?wsdl", null));
    Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "POST", ".*", 3006), "thomas-bayer.com", 80);
    rule.getInterceptors().add(interceptor);
    router = new HttpRouter();
    router.getRuleManager().addProxyAndOpenPortIfNew(rule);
}
Also used : Mapping(com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor.Mapping) Rule(com.predic8.membrane.core.rules.Rule) HttpRouter(com.predic8.membrane.core.HttpRouter)

Example 15 with Mapping

use of com.predic8.membrane.core.interceptor.administration.Mapping in project service-proxy by membrane.

the class WebServiceExplorerInterceptor method createOperationResponse.

@Mapping("[^?]*/operation/([^/?]+)/([^/?]+)/([^/?]+)")
public Response createOperationResponse(QueryParameter params, String relativeRootPath) throws Exception {
    try {
        final String bindingName = params.getGroup(1);
        final String portName = params.getGroup(2);
        final String operationName = params.getGroup(3);
        final Definitions w = getParsedWSDL();
        final Service service = getService(w);
        StringWriter sw = new StringWriter();
        new StandardPage(sw, null) {

            @Override
            protected void createContent() {
                h1().text("Service Proxy for " + service.getName());
                h2().text("Operation: " + operationName).end();
                h3().text("Sample Request").end();
                pre().text(generateSampleRequest(portName, operationName, bindingName, w)).end();
            }
        };
        return Response.ok(sw.toString()).build();
    } catch (IllegalArgumentException e) {
        log.error("", e);
        return Response.internalServerError().build();
    }
}
Also used : StringWriter(java.io.StringWriter) Definitions(com.predic8.wsdl.Definitions) Service(com.predic8.wsdl.Service) Mapping(com.predic8.membrane.core.interceptor.administration.Mapping)

Aggregations

StringWriter (java.io.StringWriter)7 AbstractExchange (com.predic8.membrane.core.exchange.AbstractExchange)5 Rule (com.predic8.membrane.core.rules.Rule)5 JsonGenerationException (com.fasterxml.jackson.core.JsonGenerationException)4 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)4 Message (com.predic8.membrane.core.http.Message)4 JSONContent (com.predic8.membrane.core.interceptor.rest.JSONContent)4 ProxyRule (com.predic8.membrane.core.rules.ProxyRule)4 IOException (java.io.IOException)4 SQLException (java.sql.SQLException)4 HttpRouter (com.predic8.membrane.core.HttpRouter)3 Mapping (com.predic8.membrane.core.interceptor.administration.Mapping)3 Mapping (com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor.Mapping)3 AbstractServiceProxy (com.predic8.membrane.core.rules.AbstractServiceProxy)3 Header (com.predic8.membrane.core.http.Header)2 Node (com.predic8.membrane.core.interceptor.balancer.Node)2 ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)2 ServiceProxyKey (com.predic8.membrane.core.rules.ServiceProxyKey)2 URLParamUtil.createQueryString (com.predic8.membrane.core.util.URLParamUtil.createQueryString)2 Definitions (com.predic8.wsdl.Definitions)2