I am a newbie to ASP MVC. When I using the LOGINSERVICE.LoginWebServiceSoapClient to check the user info, I meet a problem about the class construct error. The error message shows "System.ServiceModel.CommunicationObjectFaultedException", and the state of LoginWebServiceSoapClient is Faulted.
the following is my code Snippet:
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Logon(LoginInfo data)
{
LOGINSERVICE.LoginWebServiceSoapClient client = new LOGINSERVICE.LoginWebServiceSoapClient();
client.InnerChannel.OperationTimeout = new TimeSpan(0, 0, 5);
.....
}
And the setting of the web.config is as belowed:
<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>
Is there any instruction for this, and how to fix that,and why it happening in this way? Any instruction is highly appreciated, thanks.
CodePudding user response:
After some discussions, the situation is solved via delete and rebuild Web Service, and furthermore, not setting breakpoint on the code:
LOGINSERVICE.LoginWebServiceSoapClient client = new LOGINSERVICE.LoginWebServiceSoapClient();
My environment is Visul Studio 2019, and if the run into debug mode and stop on the breakpoint on the upper code snippet, the connection state wii be Faulted. That's all I got. Any suggestion is appreciated, thanks.