Sto cercando di creare un client standalone per consumare alcuni servizi Web. Devo aggiungere il mio nome utente e password all'intestazione SOAP. Ho provato ad aggiungere le credenziali come segue:JAX-WS - Aggiunta di intestazioni SOAP
OTSWebSvcsService service = new OTSWebSvcsService();
OTSWebSvcs port = service.getOTSWebSvcs();
BindingProvider prov = (BindingProvider)port;
prov.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "myusername");
prov.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "mypassword");
...
Quando chiamo un metodo sul servizio ottengo la seguente eccezione:
com.ibm.wsspi.wssecurity.SoapSecurityException: WSEC5048E: One of "SOAP Header" elements required.
Che cosa sto facendo di sbagliato? Come aggiungerei queste proprietà all'intestazione SOAP?
Modificato: stavo usando JAX-WS 2.1 incluso in JDK6. Ora sto usando JAX-WS 2.2. Ricevo ora la seguente eccezione:
com.ibm.wsspi.wssecurity.SoapSecurityException: WSEC5509E: A security token whose type is [http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken] is required.
Come faccio a creare questo token?
Cosa pila ws stai usando? –
JAX-WS 2.1 incluso in JDK6. –