我想創建一個獨立的客戶端來使用一些Web服務。我必須將我的用戶名和密碼添加到SOAP標題。我嘗試添加憑據如下:JAX-WS - 添加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");
...
當我呼籲我的服務得到以下異常的方法:
com.ibm.wsspi.wssecurity.SoapSecurityException: WSEC5048E: One of "SOAP Header" elements required.
我在做什麼錯?我將如何將這些屬性添加到SOAP標題?
編輯:我正在使用包含在JDK6中的JAX-WS 2.1。我現在使用JAX-WS 2.2。我現在得到以下例外:
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.
我該如何去創建此令牌?
什麼是您使用的WS棧? – 2010-02-24 01:25:04
JAX-WS 2.1包含在JDK6中。 – 2010-02-24 17:37:51