如何从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
任何想法?
您尝试调用的web服务似乎不允许匿名身份验证。相反,webservice只启用了基本的身份验证。
要了解WCF的身份验证是如何工作的,您可以阅读一篇非常好的两部分文章:第1部分和第2部分。
此外,在这里您可以找到一个完整的示例(包括服务器端和客户端)。
我无法重现你的情况,但似乎:
- 应该使用
WSHttpBinding
而不是BasicHttpBinding
- 在你的代码中,你没有设置绑定的
ClientCredentialType
属性(即_Binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic
)