accessing web services via different proxies

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

accessing web services via different proxies

Wayne Johnston
The old forum contains wisdom about how to get all HTTP and/or HTTPS traffic to go through a proxy  Ignore the userid/password stuff:  http://forums.instantiations.com/topic-12-2393.html

It also contains at the bottom a snippet showing how even for a specific 'get', you can have the request go through a unique proxy.

HOWEVER, I don't see how to implement such flexibility in the web services framework.  That is, I'd like to access some web services over HTTPS via a proxy, and other web services over HTTPS without a proxy.  Or two different proxies.  Can that be done?

All I can see how to do is to get all HTTPS traffic to go through a proxy, which would impact all web services over HTTPS.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: accessing web services via different proxies

Wayne Johnston
This is more modern documentation:  http://www.instantiations.com/docs/86/wwhelp/wwhimpl/js/html/wwhelp.htm

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: accessing web services via different proxies

jtuchel
Wayne,

the way I read the thread you link to is that you can create local HttpClients for so-called transport schemes. And you can configure these transport schemes to use a certain proxy. So If I understand both your question and the thread right, you simply choose to use a specific SstHttpClient for a selected number of gets, and thus achieve what you want. 

Or am I understanding something wrong here?

Joachim

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: accessing web services via different proxies

Wayne Johnston
That works for ad-hoc things but I don't see how with to do that the web services framework - as far as I can tell I can only supply a URL to be deployed.  But I wouldn't doubt there's a clever way to do it with all the various SstWS* objects involved.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: accessing web services via different proxies

Wayne Johnston
http://www.instantiations.com/docs/86/ws/wwhelp/wwhimpl/common/html/wwhelp.htm#href=wscbsecure.html&single=true is another nice web page talking about certificates and stuff, but still messes with the one httpsl transport object.  I'd like to know how a client can deploy to different web services using SSL but with two different transport objects (in my case using different proxies).

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: accessing web services via different proxies

Wayne Johnston
I think I found it - #mapUrlScheme:toTransportScheme: !

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: accessing web services via different proxies

Wayne Johnston
Wow, this was a difficult exercise.  Therefore I assume it wasn't done before, or else I'm ignorant and didn't find the easy way.  Here is what I came up with, most of the magic in this method:


defineProxyFor: webServiceProfile inContainer: container
"If the profile specifies a proxy, then define the proxy transport
and also map the service's top URI to use that transport.
Answer the urlString of the service - possibly with the transport ID substituted for http or https at the front.
The caller uses the answer as the argument to SstWSContainer>>#deploy:."

| serviceUrlAsUrl transportIdentifier webServiceProfile urlString config urlScheme |

"framework doesn't work if 'https' or 'http' have any upper case,
whether or not a proxy is in play."
webServiceProfile urlString: ((webServiceProfile urlString asLowercase startsWith: 'https')
ifTrue: [urlString copyReplaceFrom: 1 to: 5 with: 'https']
ifFalse: [urlString serviceURL copyReplaceFrom: 1 to: 4 with: 'http']).
serviceUrlAsUrl := urlString sstAsUrl.
urlScheme := serviceUrlAsUrl scheme , '://' , serviceUrlAsUrl address.
transportIdentifier := serviceUrlAsUrl scheme , '_', webServiceProfile proxy.
"In case proxy contains : or / characters, strip out
because SstHttpClient>>#startup appends '://' to the transportIdentifier."
transportIdentifier := (transportIdentifier copyWithout: $:) copyWithout: $/.
webServiceProfile proxy isNilOrEmpty
ifTrue: [
container configuration removeTransportMappingFor: urlScheme.  "In case previously had used proxy (below), no longer map to it"
^urlString].

serviceUrlAsUrl scheme = 'https'
ifTrue: [
SstHttpClient
initializeTransportScheme: transportIdentifier
forHttpsTunnelThrough: webServiceProfile proxy
proxyAuth: nil.
config := SstTransport configurationForIdentifier: transportIdentifier]
ifFalse: [
config := SstHttpCommunications lightTransportConfiguration.
config
transportIdentifier: transportIdentifier;
proxyUrl: ('http://' , webServiceProfile proxy) sstAsUrl].
SstTransport register: config mutuallyReachableBy: (Array with: transportIdentifier).
SstUrl register: transportIdentifier as: MyTransportHonoringSstHttpUrl.

container configuration
mapUrlScheme: urlScheme
toTransportScheme: transportIdentifier.

^transportIdentifier , (urlString copyStartingAt: serviceUrlAsUrl scheme size + 1)
And a new class MyTransportHonoringSstHttpUrl, subclass of SstHttpUrl, which has just one method:

fetchMessage
"Unlike super, honor the transport specified"
| client |
(client := SstHttpClient forTransportScheme: self transport) startUp.

"Ugly - transport is in the form of this (no spaces):
scheme _ machine port
Set scheme back to http or https."
(self transport startsWith: 'https_')
ifTrue: [self scheme: 'https']
ifFalse: [self scheme: 'http'].

^[client get: self] ensure: [client shutDown].

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: accessing web services via different proxies

Wayne Johnston
If Instantiations makes any of this easier, I'd ask that 'transportMappings' gets lazy initialized.  Since it can be nil, the call to #removeTransportMappingFor: above can blow up.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.