2012-10-30 34 views
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> 

那麼,有什麼我失蹤

回答

0

AFAIK 401用於「請求失敗,HTTP狀態401:未經授權」。

有幾件事情需要驗證。

  1. 您嘗試訪問的Web服務是否允許匿名訪問?對於網絡到Web的調用,身份驗證可能會很棘手
  2. 什麼是在IWAM_xxx或IUSR_xxx下運行的Web應用程序?或者您是否使用以特定身份運行的應用程序池? 3.服務帳戶可以訪問您的Web服務服務器。