0

在我的项目中,我调用了这样的 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 次请求,我就不会出错。

你能帮助我吗?

谢谢。

4

1 回答 1

0

我解决了这个问题。我将应用程序池的“最大工作进程数”设置为 100。

于 2017-03-13T10:40:36.400 回答