如何从ASPX中使用SAP服务引用

本文关键字:SAP 服务 引用 ASPX | 更新日期: 2023-09-27 18:11:09

我是最新的在这种类型的项目,我需要一些帮助。我有一个ASPX应用程序,它必须通过SOAP使用SAP服务。第三个合作伙伴为我提供了wsdl文件以附加服务。好的,当我在web中添加基于WSDL的服务引用时。配置下面添加的文件:

<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:

"a solicicitud HTTP no estest autorizada con el esquema de autenticación de client 'Anonymous'。El encabezado de autenticación recibido del servidor era '基本领域="SAP NetWeaver Application Server [LP1/100]"'

任何想法?

如何从ASPX中使用SAP服务引用

您尝试调用的web服务似乎不允许匿名身份验证。相反,webservice只启用了基本的身份验证。

要了解WCF的身份验证是如何工作的,您可以阅读一篇非常好的两部分文章:第1部分和第2部分。

此外,在这里您可以找到一个完整的示例(包括服务器端和客户端)。

我无法重现你的情况,但似乎:

  1. 应该使用WSHttpBinding而不是BasicHttpBinding
  2. 在你的代码中,你没有设置绑定的ClientCredentialType属性(即_Binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic)

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