2015-09-04 40 views
0

我是這類項目中最新的,我需要一些幫助。我有一個ASPX應用程序,它必須通過SOAP完成SAP服務。第三個合作伙伴爲我提供wsdl文件以附加de服務。 OK,當我基於WSDL添加服務引用,在我的web.config接下來的文件被添加:如何使用ASPX的SAP Service Reference

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="ZWSDISLINEPEDIDOS" /> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://SomeURL" binding="basicHttpBinding"   bindingConfiguration="ZWSDISLINEPEDIDOS" 
     contract="WS_SAP_PEDIDOS.ZWSDISLINEPEDIDOS" name="ZWSDISLINEPEDIDOS" /> 

    </client> 
    </system.serviceModel> 

而且我的.cs有下面的代碼:

 BasicHttpBinding _Binding = new BasicHttpBinding(); 
      EndpointAddress address = new EndpointAddress("http://SomeURL"); 

      ZWSDISLINEPEDIDOSClient _Client = new ZWSDISLINEPEDIDOSClient(_Binding, address); 
      _Client.ClientCredentials.UserName.UserName = "MyUserName"; 
      _Client.ClientCredentials.UserName.Password = "MyPassword"; 

When we try to call a method from the client the next error fires: 

「一solicitud HTTP沒有ESTA autorizada CON EL esquema德autenticación德cliente '匿名'。厄爾尼諾encabezado德autenticaciónrecibido德爾servidor時代 '基本境界= 「的SAP NetWeaver應用服務器[LP1/100]」'

任何想法?

+1

您應該翻譯中文錯誤消息 –

+0

對不起:HTTP請求未經客戶端身份驗證方案'匿名'未經授權。從服務器收到的驗證標頭爲'Basic realm =「SAP NetWeaver Application Server [LP1/100] –

回答

0

看來您嘗試調用的web服務不允許匿名身份驗證。相反,webservice只啓用了基本認證。

要了解身份驗證如何適用於WCF,您可以閱讀非常好的兩部分文章:part 1part 2

此外here你可以找到一個完整的示例(包括服務器端和客戶端)。

我無法重現您的情況,但似乎:

  1. 你應該在你的代碼中使用的WSHttpBinding代替BasicHttpBinding
  2. ,你不設置您的結合(即_Binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic
  3. ClientCredentialType財產

我希望我的提示可以幫助你解決你的問題。