Accessing a webservice with a different path and rewrite its wsdl

546 views
Skip to first unread message

Markus A

unread,
Feb 20, 2015, 9:47:23 AM2/20/15
to membrane...@googlegroups.com
I wanted to create a proxy for a Webservice, using a different path than the one under which it is hosted. I started with the membrane example "rewriter":

        
        <serviceProxy port="2000">
            <rewriter>
                <map from="^/bank/(.*)" to="/axis2/$1" />
            </rewriter>
            <target host="www.thomas-bayer.com" port="80" />
        </serviceProxy>

Now i need to rewrite my wsdl target endpoint, so i added a <wsdlRewriter/> interceptor:


        <serviceProxy port="2000">
            <rewriter>
                <map from="^/bank/(.*)" to="/axis2/$1" />
            </rewriter>
            <wsdlRewriter />
            <target host="www.thomas-bayer.com" port="80" />
        </serviceProxy>

But when i load the wsdl (http://localhost:2000/bank/services/BLZService?wsdl) i get a wrong location (http://localhost:2000/axis2/services/BLZService and not http://localhost:2000/bank/services/BLZService):

....
<wsdl:service name="BLZService">
<wsdl:port name="BLZServiceSOAP11port_http" binding="tns:BLZServiceSOAP11Binding">
</wsdl:port>
<wsdl:port name="BLZServiceSOAP12port_http" binding="tns:BLZServiceSOAP12Binding">
</wsdl:port>
<wsdl:port name="BLZServiceHttpport" binding="tns:BLZServiceHttpBinding">
</wsdl:port>
</wsdl:service>
...

As i noticed, the host and the port are changed by the wsdlRewriter interceptor, but the path itself not.

Is there a way to rewrite the entire path in the WSDL? Or should i use different approach?

Thomas Bayer

unread,
Feb 20, 2015, 10:55:06 AM2/20/15
to membrane...@googlegroups.com
Hi,
the simplest way is to use a soapProxy. A soapProxy knows WSDL:

        <soapProxy
            wsdl="http://www.thomas-bayer.com/axis2/services/BLZService?wsdl"
            port="8080">
            <path>/bank</path>
        </soapProxy>

then you reach the Service WSDL at:

http://localhost:8080/bank?wsdl

and everything is rewritten in the WSDL. The <rewriter> rewrites the URL but does not change the WSDL.

Cheers,
Thomas



Am 20.02.15 um 15:47 schrieb Markus A:
--
You received this message because you are subscribed to the Google Groups "membrane-monitor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to membrane-monit...@googlegroups.com.
To post to this group, send email to membrane...@googlegroups.com.
Visit this group at http://groups.google.com/group/membrane-monitor.
For more options, visit https://groups.google.com/d/optout.

Markus A

unread,
Feb 23, 2015, 5:34:33 AM2/23/15
to membrane...@googlegroups.com
Hi Thomas,

Thanks for the quick answer. My Problem is that my target service depends on SSL and client certificate authentication. Is there a way to configure an outgoing ssl connection for soapProxy? Or is this only supported with the generic serviceProxy?

Cheers,
Markus

Thomas Bayer

unread,
Feb 23, 2015, 5:53:30 AM2/23/15
to membrane...@googlegroups.com
Hi Markus,
to use outgoing SSL with the soapProxy, the endpoint URL in the WSDL has to start with https:// then Membrane is using SSL. But you need also a client certificate, many it works when you specify a keystore from commandline using the attribute:
-Djavax.net.ssl.keyStore
If you use a serviceProxy instead you do not get the path of the WSDL rewritten.

Please let me know if the solution suggested above works for you.

Cheers,
Thomas


Am 23.02.15 um 11:34 schrieb Markus A:

Markus A

unread,
Feb 24, 2015, 2:45:47 AM2/24/15
to membrane...@googlegroups.com
Hi Thomas,

I set my keystore and my truststore as a startup parameter (-Djava....), but i got a com.predic8.membrane.core.transport.http.NoResponseException

My configuration:

    <router>

        <soapProxy wsdl="https://myservice.com:443/my-service-ws/WebService?wsdll" port="8080">
            <path>check</path>
            <soapStackTraceFilter/>
            <log/>
        </soapProxy>

    </router>

and the Exception:

08:23:39,753  INFO TrackingFileSystemXmlApplicationContext:500 - Refreshing Membrane Service Proxy's Spring Context
08:23:39,802  INFO XmlBeanDefinitionReader:315 - Loading XML bean definitions from file [C:\membrane\membrane-service-proxy-4.0.18\examples\_Keystore\proxies.xml]
08:23:40,145  INFO DefaultListableBeanFactory:581 - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@726d73af: defining beans [router]; ro
ot of factory hierarchy
08:23:40,257  INFO DefaultLifecycleProcessor:334 - Starting beans in phase 0
08:23:40,258  INFO Router:247 - Starting Membrane Service Proxy 4.0.18
org.springframework.context.ApplicationContextException: Failed to start bean 'router'; nested exception is java.lang.RuntimeException: java.lang.IllegalArgumentException: Could not download
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:170)
        at org.springframework.context.support.DefaultLifecycleProcessor.access$1(DefaultLifecycleProcessor.java:154)
        at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:339)
        at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:143)
        at org.springframework.context.support.DefaultLifecycleProcessor.start(DefaultLifecycleProcessor.java:89)
        at org.springframework.context.support.AbstractApplicationContext.start(AbstractApplicationContext.java:1259)
        at com.predic8.membrane.core.Router.init(Router.java:138)
        at com.predic8.membrane.core.RouterCLI.main(RouterCLI.java:38)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.predic8.membrane.core.Starter.main(Starter.java:26)
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Could not download the WSDL 'https://myservice.com:443/my-service-ws/WebService?wsdl'.
        at com.predic8.membrane.core.Router.start(Router.java:270)
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:167)
        ... 12 more
Caused by: java.lang.IllegalArgumentException: Could not download the WSDL 'https://myservice.com:443/my-service-ws/WebService?wsdl'.
        at com.predic8.membrane.core.rules.SOAPProxy.parseWSDL(SOAPProxy.java:151)
        at com.predic8.membrane.core.rules.SOAPProxy.configure(SOAPProxy.java:194)
        at com.predic8.membrane.core.rules.SOAPProxy.init(SOAPProxy.java:268)
        at com.predic8.membrane.core.rules.AbstractProxy.init(AbstractProxy.java:180)
        at com.predic8.membrane.core.Router.init(Router.java:241)
        at com.predic8.membrane.core.Router.start(Router.java:256)
        ... 13 more
Caused by: java.lang.RuntimeException: com.predic8.membrane.core.resolver.ResourceRetrievalException: com.predic8.membrane.core.transport.http.NoResponseException while retrieving https://my
        at com.predic8.membrane.core.resolver.ResolverMap$ExternalResolverConverter$1.resolveViaHttp(ResolverMap.java:238)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:272)
        at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:52)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
        at com.predic8.xml.util.ExternalResolver.resolve(ExternalResolver.groovy:66)
        at com.predic8.xml.util.ExternalResolver$resolve.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
        at com.predic8.soamodel.AbstractParser.getResourceToken(AbstractParser.groovy:45)
        at com.predic8.soamodel.AbstractParser.this$2$getResourceToken(AbstractParser.groovy)
        at com.predic8.soamodel.AbstractParser$this$2$getResourceToken.callCurrent(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
        at com.predic8.soamodel.AbstractParser.parse(AbstractParser.groovy:34)
        at com.predic8.wsdl.WSDLParser.super$2$parse(WSDLParser.groovy)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1074)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:128)
        at com.predic8.wsdl.WSDLParser.parse(WSDLParser.groovy:29)
        at com.predic8.membrane.core.rules.SOAPProxy.parseWSDL(SOAPProxy.java:96)
        ... 18 more
Caused by: com.predic8.membrane.core.resolver.ResourceRetrievalException: com.predic8.membrane.core.transport.http.NoResponseException while retrieving https://myservice.com:443/my-ser
vice-ws/WebService?wsdl
        at com.predic8.membrane.core.resolver.HTTPSchemaResolver.resolve(HTTPSchemaResolver.java:67)
        at com.predic8.membrane.core.resolver.ResolverMap$ExternalResolverConverter$1.resolveViaHttp(ResolverMap.java:236)
        ... 50 more
Caused by: com.predic8.membrane.core.transport.http.NoResponseException
        at com.predic8.membrane.core.http.Response.parseStartLine(Response.java:294)
        at com.predic8.membrane.core.http.Response.read(Response.java:312)
        at com.predic8.membrane.core.transport.http.HttpClient.doCall(HttpClient.java:252)
        at com.predic8.membrane.core.transport.http.HttpClient.call(HttpClient.java:157)
        at com.predic8.membrane.core.transport.http.HttpClient.call(HttpClient.java:124)
        at com.predic8.membrane.core.resolver.HTTPSchemaResolver.resolve(HTTPSchemaResolver.java:56)
        ... 51 more
Drücken Sie eine beliebige Taste . . .

Cheers
Markus

Thomas Bayer

unread,
Feb 24, 2015, 3:37:16 PM2/24/15
to membrane...@googlegroups.com
Hi Markus,
the WSDL download is done by the ExternalResolver class in the soa-model project. Here is the code:

HttpClient client = new DefaultHttpClient();
        if ( proxyHost ) {
            HttpHost proxy = new HttpHost(proxyHost, proxyPort);
            client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
        }
        HttpParams params = client.getParams();
        HttpConnectionParams.setConnectionTimeout(params, timeout);

        HttpGet method = new HttpGet(url);
        method.setHeader("User-Agent", "SOA Model (see http://membrane-soa.org)")
        HttpResponse response = client.execute(method)

we must change this code to use the ssl configuration. But this will take some time because we have to release first a new SOA Model version.

Maybe you can download the WSDL and reference it from file. Or you can setup a serviceProxy that terminates the SSL connection using your stores:

    <serviceProxy name="WSDL Proxy" port="8080">
        <target host="myservice.com">
             <ssl>...</ssl>
        </target>
   </serviceProxy>

        <soapProxy wsdl="http://localhost:8080/my-service-ws/WebService?wsdll" port="8080">
            <path>check</path>
            <soapStackTraceFilter/>
            <log/>
        </soapProxy>

Please let me know if that helps.

Cheers,
Thomas



Am 24.02.15 um 08:45 schrieb Markus A:
Reply all
Reply to author
Forward
0 new messages