我在我的C#代码中调用了一个Web服务。 Web服务是用PHP构建的。我正在调用它的加载卸载方法。网络服务让我回报
"The server committed a protocol violation. Section=ResponseStatusLine"
如果我以5到10秒的延迟呼叫服务,则会出错。这是我用来调用服务的代码。
private MyServiceMachine client = new MyServiceMachine ();
client.loadunload();
Thanks in advance for help.
这是异常我得到的异常详细信息:
Message: The server committed a protocol violation. Section=ResponseStatusLine
Source: System.Web.Services
StackTrace: at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at SPLocker.Core.lendingMachineService.lendingMachine.loadUnLoad(String MID, String TS, String RE, Object BS)
at SPLocker.Core.TransactionHelper.loadUnLoad(EnumLendingServiceMode mode, Int32[] BoxIDs, Boolean IsAllBOXes)
TargetSite: System.Net.WebResponse
听起来像是C#HttpWebRequest类返回的错误,而不是端点服务器返回的错误。
打开调试是我的建议。
另一种可能性:当进行POST时,服务器以100不正确的方式响应100。
这解决了我的问题:
request.ServicePoint.Expect100Continue = false;