Xamarin Forms asmx webservice 多次调用
Xamarin Forms asmx webservice multiple calls
在我的项目中,我这样调用 Web 服务:
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("**********");
req.Method = "POST";
req.ContentType = "application/json";
byte[] postDataAsBytesS = Encoding.UTF8.GetBytes(mobileJSON);
Stream postStreamS = req.GetRequestStream();
postStreamS.Write(postDataAsBytesS, 0, postDataAsBytesS.Length);
postStreamS.Flush();
postStreamS.Dispose();
WebResponse resS = req.GetResponse();
postStreamS = resS.GetResponseStream();
StreamReader srS = new StreamReader(postStreamS);
string responseFromServerS = srS.ReadToEnd();
public static class ExtensionsMethods
{
public static WebResponse GetResponse(this WebRequest request)
{
ManualResetEvent evt = new ManualResetEvent(false);
WebResponse response = null;
request.BeginGetResponse((IAsyncResult ar) => {
response = request.EndGetResponse(ar);
evt.Set();
}, null);
evt.WaitOne();
return response as WebResponse;
}
public static Stream GetRequestStream(this WebRequest request)
{
ManualResetEvent evt = new ManualResetEvent(false);
Stream requestStream = null;
request.BeginGetRequestStream((IAsyncResult ar) => {
requestStream = request.EndGetRequestStream(ar);
evt.Set();
}, null);
evt.WaitOne();
return requestStream;
}
}
当我同时调用上面的 Reqeust 2 次时,我从 web 服务中得到一个错误。
我收到以下错误:
{"Message":"Column \u0027*****\u0027 doesn't exist in the table.","StackTrace":" in System.Data.DataRow.GetDataColumn(String columnName)\r\n in System.Data.DataRow.get_Item(String columnName)\r\n in webserviceDWA.syncAndroidDWA.GetDWAPDFkategoriezuordnung(dwamobile[] mobile)","ExceptionType":"System.ArgumentException"}
但如果我只执行 1 次请求,我不会收到任何错误。
你能帮帮我吗?
谢谢。
我解决了这个问题。
我将应用程序池的设置 "Maximum number of work processes" 设置为 100.
在我的项目中,我这样调用 Web 服务:
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("**********");
req.Method = "POST";
req.ContentType = "application/json";
byte[] postDataAsBytesS = Encoding.UTF8.GetBytes(mobileJSON);
Stream postStreamS = req.GetRequestStream();
postStreamS.Write(postDataAsBytesS, 0, postDataAsBytesS.Length);
postStreamS.Flush();
postStreamS.Dispose();
WebResponse resS = req.GetResponse();
postStreamS = resS.GetResponseStream();
StreamReader srS = new StreamReader(postStreamS);
string responseFromServerS = srS.ReadToEnd();
public static class ExtensionsMethods
{
public static WebResponse GetResponse(this WebRequest request)
{
ManualResetEvent evt = new ManualResetEvent(false);
WebResponse response = null;
request.BeginGetResponse((IAsyncResult ar) => {
response = request.EndGetResponse(ar);
evt.Set();
}, null);
evt.WaitOne();
return response as WebResponse;
}
public static Stream GetRequestStream(this WebRequest request)
{
ManualResetEvent evt = new ManualResetEvent(false);
Stream requestStream = null;
request.BeginGetRequestStream((IAsyncResult ar) => {
requestStream = request.EndGetRequestStream(ar);
evt.Set();
}, null);
evt.WaitOne();
return requestStream;
}
}
当我同时调用上面的 Reqeust 2 次时,我从 web 服务中得到一个错误。
我收到以下错误:
{"Message":"Column \u0027*****\u0027 doesn't exist in the table.","StackTrace":" in System.Data.DataRow.GetDataColumn(String columnName)\r\n in System.Data.DataRow.get_Item(String columnName)\r\n in webserviceDWA.syncAndroidDWA.GetDWAPDFkategoriezuordnung(dwamobile[] mobile)","ExceptionType":"System.ArgumentException"}
但如果我只执行 1 次请求,我不会收到任何错误。
你能帮帮我吗?
谢谢。
我解决了这个问题。 我将应用程序池的设置 "Maximum number of work processes" 设置为 100.