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.
