no elegant way without accessing Stub that I know of, or inserting it into generated stub
but you can cast it to DownloadServiceBindingStub so all it adds is just one import
i dont think this is too bad:

DownloadServiceLocator locator = new DownloadServiceLocator();
DownloadService binding = locator. getDownload();

((DownloadServiceBindingStub) binding).setUsername("foo");
((DownloadServiceBindingStub) binding).setPassword("bar");

binding.methodcall(...)


On Friday, October 18, 2002, at 02:32 PM, Jesper S�derlund wrote:

How do I set username/password for a WSDL-generated class.

In my case the DownloadServiceLocator has a "getDownload()" method for returning a proxy to call the service (examples strongly simplified).

class DownloadServiceLocator {
��� DownloadServiceBindingStub member;
��� DownloadService getDownload(URL u) { ... return member;}
��� ...
}

But the problem is that the implementation returns the "DownloadService" interface that defines the service operations (which is implemented by the Stub subclass.

class DownloadServiceBindingStub extends Stub implements DownloadService {
�� // DownloadService methods
}

The problem now is that to set the username/password I have to access the Stub sub-class which breakes the nice encapsulation of working with a DownloadService. Sure I can cast it back to a Stub but that's not very elegant, there must be a simple / better solution.

In the JAX-RPC specification there are two different examples (chapter 13.1.1), either you provide it�as "getDownload(URL u, String user, String password)" or your provide a way to get at the stub (and now I don't think that casting is an elegant solution).

Yet another solution would be to expose the "get/setProperty" items in the (DownloadService)Locator class.

Reply via email to