2015-09-04 41 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财产

我希望我的提示可以帮助你解决你的问题。