首页 > 解决方案 > 当我从另一个 .NET 应用程序调用它时,我的 WebService c# 不起作用

问题描述

这是我第一次在这里问,所以,是的,如果您需要更多信息,请在此处回复!

所以,继续,我的问题出在我的 .NET 应用程序上,我为从我创建的 Web 服务中读取/写入信息进行了编码,并且运行良好(在 VS2013 上测试)。

当我从浏览器调用它时,它工作得很好,但是当我从我的应用程序调用它时,它会返回以下错误:

The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM'

我真的尝试了很多东西,但没有找到任何解决方案。

我的下一步只是从 AD 服务器设置身份验证,换句话说,它应该只能在 Intranet 上工作。

我的配置文件是:

  <system.web>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5"/>

我的网络服务例程是:

public ImportFileClass ImportFile(string FileName, string PV)
{
    try
    {
        ImportFileClass ipt = new ImportFileClass(PV, FileName);
        ipt.DoEvents();
        return ipt;
    }
    catch (Exception ex) { throw; }
}

提前致谢!

标签: c#.netweb-servicesauthenticationntlm

解决方案


我发现了我正在做的错误!

添加服务引用 在添加服务引用时,我只是把我得到的 URI 放在 web 服务上,然后确认。问题就在那里!

我做了这些步骤,一切顺利: https ://www.aspsnippets.com/Articles/Call-Consume-Web-Service-ASMX-in-ASPNet-web-application-using-C-and-VBNet.aspx

顺便说一句,非常感谢您的宝贵时间!希望能帮助到你!


推荐阅读