2016-03-05 117 views
1

我有一個soap web服務(sap me web服務),我生成了wcf代理。沒問題,我開發了一個WinForms應用程序沒有問題 現在,我嘗試使用它在我的WCF服務(的WebHttpBinding域網絡的結合),但我有一個身份驗證錯誤: WCF - HTTP請求是未經授權的客戶端身份驗證方案「基本」 。從服務器接收認證報頭是「基本境界=‘mySoapServiceName’ 這是IIS用戶的問題?在wcf web服務中調用SAP ME web服務

謝謝

回答

1

SAP正在使用基本身份驗證。你需要指定的用戶名和密碼,您已經創建了代理之後,例如:

proxy.Credentials.UserName.UserName = "joe"; 
proxy.Credentials.UserName.Password = "doe"; 
+0

是,密碼和登錄OK – Tanite

0
BasicHttpBinding myBinding = new BasicHttpBinding(); 

myBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; 

myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; 
EndpointAddress ea = new EndpointAddress("url de mon web service soap"); 

SfcServices.SFCProcessingInClient myClient = new SfcServices.SFCProcessingInClient(myBinding, ea); 

myClient.ClientCredentials.UserName.UserName = _MESwsLogin; 
myClient.ClientCredentials.UserName.Password = _MESwsPassword; 

SfcServices.SFCStateRequestMessage_sync srm = new SfcServices.SFCStateRequestMessage_sync(); 
SfcServices.SFCStateRequest sr = new SfcServices.SFCStateRequest(); 
srm.SfcStateRequest = sr; 
sr.SiteRef = new SfcServices.SiteRef(); 
sr.SiteRef.Site = _MESsite; 
sr.SfcRef = new SfcServices.SFCRef(); 
sr.SfcRef.Sfc = "12345678903"; 

sr.includeSFCStepList = true; 

SfcServices.SFCStateConfirmationMessage_sync response = myClient.FindStateByBasicData(srm); 
strOrdreFab = response.SfcStateResponse.SFCStatus.Sfc.ShopOrderRef.ShopOrder; 
strCodeProduit = response.SfcStateResponse.SFCStatus.Sfc.ItemRef.Item; 
strIndice = response.SfcStateResponse.SFCStatus.Sfc.ItemRef.Revision;