This discussion is archived
1 2 Previous Next 21 Replies Latest reply: Feb 20, 2013 7:46 AM by 977030 Go to original post RSS
  • 15. Re: Call Web Service method through a Proxy
    977030 Newbie
    Currently Being Moderated
    EJP wrote:
    Contrary to what you will read in certain books and web pages (not here), there is no such property as 'proxySet'. Setting it, clearing it, setting it to 'true', setting it to 'false', all accomplish exactly nothing.
    Thanks for the detail I will remove the line.
  • 16. Re: Call Web Service method through a Proxy
    977030 Newbie
    Currently Being Moderated
    jtahlborn wrote:
    why?
    I am not exactly aware why it doesn't work since it is other people who test the application.
    I believe it has something to do with setting up different proxies for different calls to the same web-service.

    In any case, do you know of another way to bind/set/specify a proxy to the client object (ThePort) I get from:
    TheService service= new TheService ();
    ThePort port= service.getPort();

    (names are not real, the WS is of Jax-WS technology but maybe the client can be jax-rpc?? I don't know)

    Thank you,
    Dimitris

    Edited by: 974027 on Feb 20, 2013 12:02 AM
  • 17. Re: Call Web Service method through a Proxy
    977030 Newbie
    Currently Being Moderated
    An other idea I have to solve this issue is using the technique described here: http://www.ibm.com/developerworks/library/x-jaxmsoap/
    that is "Send and receive SOAP messages with SAAJ"

    But i don't see a way to set a proxy to SOAPConnection class.

    Any ideas about this?

    THank you,
    DImitris
  • 18. Re: Call Web Service method through a Proxy
    jtahlborn Expert
    Currently Being Moderated
    DimitrisMich wrote:
    jtahlborn wrote:
    why?
    I am not exactly aware why it doesn't work since it is other people who test the application.
    I believe it has something to do with setting up different proxies for different calls to the same web-service.
    how do you expect to solve a problem, if you don't know what the problem is?

    i repeat, you had a viable solution. you encountered a secondary issue (unknown at this point). instead of trying to work through that, you are wandering down other paths which haven't yet provided any useful results. why not try to fix the "almost working" solution that you already have, instead of starting over from scratch?
  • 19. Re: Call Web Service method through a Proxy
    977030 Newbie
    Currently Being Moderated
    jtahlborn wrote:
    i repeat, you had a viable solution. you encountered a secondary issue (unknown at this point). instead of trying to work through that, you are wandering down other paths which haven't yet provided any useful results. why not try to fix the "almost working" solution that you already have, instead of starting over from scratch?
    Your logic makes sense of course.
    I talked to some colleagues and the issue that stops us using ProxySelector seems to be about 2 points:

    *1.* It is a class that affects the whole System and they worry about that.
    *2.* As i mentioned before. they would like to use 2 (or 3) different proxies for the same WS and
    since in ProxySelector() to chose which proxy to use i check:
    +if (uri.getHost().contains("the_host_of_the_web_service")) {+
    return proxyList; // use a specific proxy
    +}+

    I can not use different proxies for the same WS.....

    Hope I made our problem clear
  • 20. Re: Call Web Service method through a Proxy
    jtahlborn Expert
    Currently Being Moderated
    Okay, then one option is that you could make a ProxySelector which delegates to a ThreadLocal ProxySelector.
    public class TLProxySelector extends ProxySelector {
    
      private static final TLProxySelector _instance;
      private static final ThreadLocal<ProxySelector> _local = new ThreadLocal<ProxySelector>();
      
      static {
        _instance = new TLProxySelector();
        ProxySelector.setDefault(_instance);
      }
    
      private final ProxySelector _default;
    
      private ProxySelector() {
        // grab the original default before the TLProxySelector was installed
        _default = ProxySelector.getDefault();
      }
    
      public static void setCurrentSelector(ProxySelector newSelector) {
        _local.set(newSelector);
      }
    
      public List<> select(URI uri) {
        ProxySelector local = _local.get();
        // if a thread local instance has been set, use it, otherwise use the original system default
        return ((local != null) ? local : _default).select(uri);
      }
    }
    This allows you to use a specific selector in the context of a given call without affecting the rest of the system, like so:
      TLProxySelector.setCurrentSelector(myCustomSelector);
      try {
        // ... do some ws call here ...
      } finally {
        TLProxySelector.setCurrentSelector(null);
      }
  • 21. Re: Call Web Service method through a Proxy
    977030 Newbie
    Currently Being Moderated
    Thank you for the great-looking code.
    A colleague of mine will take a look at it and check if we can use it but it is very promising.
    We just want to check if each call to the web-service is made from a different thread.


    Do you happen to know about a connection between jax-ws and proxy-aware SocketFactory ?
    From various forums and hints I believe this can be another solution to the problem (http://metro.java.net/2.0/guide/HTTPS_SSLSocketFactory.html)
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points