0
我在WEBLOGIC服務器上運行此Web服務。當我將URL WSDL粘貼到瀏覽器並且瀏覽器提示輸入用戶名和密碼時,一切似乎都很好。但在客戶端,當我使用與服務器相同的身份驗證調用服務時,服務器響應401異常。具有Web服務身份驗證的例外401
這是我的客戶端代碼
SupplierService service = new SupplierService();
port = service.getSupplierPort();
Map<String, Object> rc = ((BindingProvider)port).getRequestContext();
rc.put(BindingProvider.USERNAME_PROPERTY, "username");
rc.put(BindingProvider.PASSWORD_PROPERTY, "pass");
port.hello();
這是我的web.xml配置(網址WSDL是:本地主機/店/ SupplierService WSDL)
<security-constraint>
<web-resource-collection>
<web-resource-name>Web service resources</web-resource-name>
<url-pattern>/SupplierService</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>suppliers</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>suppliers</role-name>
</security-role>
這是我的weblogic.xml
<wls:context-root>ass</wls:context-root>
<wls:security-role-assignment>
<wls:role-name>suppliers</wls:role-name>
<wls:principal-name>SupplierGroup</wls:principal-name>
</wls:security-role-assignment>
那麼,有什麼我失蹤