3 Replies Latest reply on May 10, 2013 12:25 PM by piwaf

    how to dynamically change URL where client is connecting to?

    sodik

      Hi *,

      I have generated wsdl file of service I want to call. The service is fixed but I don't know where this service will be located.

      Is there an option how to generate client classes that I can use runtime URL parameter that specifies where the client is connecting to?

      Only solution I found out is to load wsdl from each of those services (runtime) and there will be the good url. Is there possibility to skip downloading wsdl each time I want to connect to other host?

      Thanks.

        • 1. Re: how to dynamically change URL where client is connecting
          asoldano

          If you only need to use different endpoints (with different addresses) and the services publish the same wsdl contract, just use this before the invocation:

          ((BindingProvider)myPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint);
          


          where "endpoint" is your runtime selected endpoint address.

          • 2. Re: how to dynamically change URL where client is connecting
            sodik

            thank you, looks exactly as what I need.

            • 3. Re: how to dynamically change URL where client is connecting
              piwaf

              This does exactly what I need, Stub created against a Dev URL but in Production want to call production url based on url in a config setup.  But is there not a more straight forward way to do this?  It just seems like such a basic need that I'm confused on why it appears the only way to change it is a "back door".

               

              I have tried using the wsdlLocation parameter of the generated Service Constructor, aka the Service.create call, and that seems to affect where it gets the WSDL from for validation, but it doesn't seem to affect where the call is actually made.  That call still defaults to the url in the port section of the original wsdl used to generate the client stub.

               

              Am I doing something wring or is this just how it is?