Search in sources :

Example 1 with Relocator

use of com.predic8.membrane.core.ws.relocator.Relocator in project service-proxy by membrane.

the class WADLInterceptor method rewrite.

@Override
protected void rewrite(Exchange exc) throws Exception, IOException {
    log.debug("Changing endpoint address in WADL");
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    Relocator relocator = new Relocator(new OutputStreamWriter(stream, exc.getResponse().getCharset()), getLocationProtocol(), getLocationHost(exc), getLocationPort(exc), pathRewriter);
    relocator.getRelocatingAttributes().put(new QName(WADL_NS, "resources"), "base");
    relocator.getRelocatingAttributes().put(new QName(WADL_NS, "include"), "href");
    relocator.relocate(new InputStreamReader(exc.getResponse().getBodyAsStreamDecoded(), exc.getResponse().getCharset()));
    exc.getResponse().setBodyContent(stream.toByteArray());
}
Also used : InputStreamReader(java.io.InputStreamReader) QName(javax.xml.namespace.QName) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Relocator(com.predic8.membrane.core.ws.relocator.Relocator)

Example 2 with Relocator

use of com.predic8.membrane.core.ws.relocator.Relocator in project service-proxy by membrane.

the class WSDLInterceptor method rewrite.

@Override
protected void rewrite(Exchange exc) throws Exception, IOException {
    log.debug("Changing endpoint address in WSDL");
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    Relocator relocator = new Relocator(new OutputStreamWriter(stream, exc.getResponse().getCharset()), getLocationProtocol(), getLocationHost(exc), getLocationPort(exc), pathRewriter);
    if (rewriteEndpoint) {
        relocator.getRelocatingAttributes().put(new QName(WSDL_SOAP11_NS, "address"), "location");
        relocator.getRelocatingAttributes().put(new QName(WSDL_SOAP12_NS, "address"), "location");
        relocator.getRelocatingAttributes().put(new QName(WSDL_HTTP_NS, "address"), "location");
    }
    relocator.getRelocatingAttributes().put(new QName(XSD_NS, "import"), "schemaLocation");
    relocator.getRelocatingAttributes().put(new QName(XSD_NS, "include"), "schemaLocation");
    relocator.relocate(new InputStreamReader(exc.getResponse().getBodyAsStreamDecoded(), exc.getResponse().getCharset()));
    if (relocator.isWsdlFound()) {
        registerWSDL(exc);
    }
    exc.getResponse().setBodyContent(stream.toByteArray());
}
Also used : InputStreamReader(java.io.InputStreamReader) QName(javax.xml.namespace.QName) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Relocator(com.predic8.membrane.core.ws.relocator.Relocator)

Aggregations

Relocator (com.predic8.membrane.core.ws.relocator.Relocator)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 InputStreamReader (java.io.InputStreamReader)2 OutputStreamWriter (java.io.OutputStreamWriter)2 QName (javax.xml.namespace.QName)2