membrane / soa-model

Toolkit and Java API for WSDL, WADL and XML Schema.
http://www.membrane-soa.org/soa-model/
Apache License 2.0
94 stars 73 forks source link

No Proxy Support #218

Open rsolton opened 10 years ago

rsolton commented 10 years ago

There does not appear to be anyway to proxy the http request initiated by new WSDLParser().parser(url).

Is this on the roadmap? If not, can I contribute the solution?

keshavarzi commented 10 years ago

It is not on the roadmap. If you want to you can send a pull request.

Thomas

predic8 GmbH Moltkestr. 40

53173 Bonn

http://predic8.de Tel: +49 (0) 228 5552576-0 Fax: +49 (0) 228 5552576-50

Amtsgericht Bonn HRB 16152 Geschäftsführer: Thomas Bayer

Am 13/07/14 19:53, schrieb Randy Solton:

There does not appear to be anyway to proxy the http request initiated by new WSDLParser().parser(url).

Is this on the roadmap? If not, can I contribute the solution?

— Reply to this email directly or view it on GitHub https://github.com/membrane/soa-model/issues/218.

rrayst commented 10 years ago

The soa-model project can be used with a custom resource resolver. Such a resolver can be implemented to use a HTTP proxy.

The service-proxy does exactly this, for example. For example, in https://github.com/membrane/service-proxy/blob/master/core/src/main/java/com/predic8/membrane/core/rules/SOAPProxy.java#L94 it replaces soa-model's default resource resolver by a custom one. service-proxy's resolverMap used in this example is much more powerful and can be configured to use a HTTP proxy.

Note, though, that service-proxy completely implements its own HTTP stack. If this concerns you (it will, for example, impact your binary's size), you might be better of patching/overriding resolveViaHttp(...) in https://github.com/membrane/soa-model/blob/master/core/src/main/groovy/com/predic8/xml/util/ExternalResolver.groovy#L89 .

In case you go with service-proxy, I'd try

        ResolverMap rm = new ResolverMap();
        ProxyConfiguration proxyConfig = new ProxyConfiguration();
        proxyConfig.set...(...);
        rm.getHTTPSchemaResolver().getHttpClientConfig().setProxy(proxyConfig);
        WSDLParserContext context = new WSDLParserContext();
        context.setResourceResolver(rm.toExternalResolver().toExternalResolver());

I have not tested this, though. ;)

I thought about extracting the resolver map classes into a separate resolver project on which service-proxy and soa-model could depend. But then the HTTP resolver depends on service-proxy. As a resolver without a HTTP resolver is not much fun, this creates a cyclic dependency service-proxy -> resolver -> service-proxy. -- So this won't happen soon.

Of course, if you patch a simple HTTP proxy support into soa-model`s ExternalResolver, pull requests are very welcome! :)