代码之家  ›  专栏  ›  技术社区  ›  abramhum

登录服务。LoginWebServiceSoapClient未初始化并导致系统。服务模型。通信对象故障异常

  •  0
  • abramhum  · 技术社区  · 4 年前

    我是ASP MVC的新手。当我使用LOGINSERVICE时。登录WebServiceSoapClient以检查 用户信息,我遇到一个关于类构造错误的问题。错误消息显示“System.ServiceModel.CommunicationObjectFaultedException”,并且LoginWebServiceSoapClient的状态为Faulted。

    以下是我的代码片段:

    [HttpPost]
    [AllowAnonymous]
    [ValidateAntiForgeryToken]
    public ActionResult Logon(LoginInfo data)
    {
        LOGINSERVICE.LoginWebServiceSoapClient client = new LOGINSERVICE.LoginWebServiceSoapClient();
        client.InnerChannel.OperationTimeout = new TimeSpan(0, 0, 5);
        .....
    }
    

    以及web的设置。配置如下:

     <system.web>
        <compilation debug="true" targetFramework="4.6" />
        <httpRuntime targetFramework="4.6" />
        <authentication mode="Forms">
          <forms name=".ExampleWeb" loginUrl="~/Account/Login/" timeout="120" />
        </authentication>
      </system.web>
      
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="LoginWebServiceSoap">
              <security mode="Transport" />
            </binding>
            <binding name="LoginWebServiceSoap1" />
            <binding name="LoginWebServiceSoap2">
              <security mode="Transport" />
            </binding>
            <binding name="LoginWebServiceSoap3" />
          </basicHttpBinding>
        </bindings>
        <client>
          <endpoint address="https:XXXXXXXXXXX.asmx"
            binding="basicHttpBinding" bindingConfiguration="LoginWebServiceSoap2"
            contract="LOGINSERVICE.LoginWebServiceSoap" name="LoginWebServiceSoap1" />
        </client>
     </system.serviceModel>
    

    有没有关于这方面的指导,以及如何解决这一问题,以及为什么会发生这种情况? 非常感谢您的指导。

    0 回复  |  直到 4 年前
        1
  •  0
  •   abramhum    4 年前

    经过一些讨论,通过删除和重建Web服务解决了这种情况, 此外,不在代码上设置断点:

      LOGINSERVICE.LoginWebServiceSoapClient client = new LOGINSERVICE.LoginWebServiceSoapClient();
    

    我的环境是Visul Studio 2019,如果运行到调试模式并在上面的代码段上的断点处停止,则连接状态将出现故障。 我只有这些了。感谢您的建议。