相关疑难解决方法(0)

HttpWebRequest:请求已中止:请求已取消

我一直致力于开发一种中间人应用程序,它使用一系列日期的HTTP发布请求(通常一次只有7个)将文本上传到CMS后端.我正在使用HttpWebRequest来实现这一目标.它似乎在第一个日期工作正常,但是当它开始第二个日期时,我得到System.Net.WebException:请求被中止:请求被取消.

我四处搜寻,发现了以下重要线索:

http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/0d0afe40-c62a-4089-9d8b-fb4d206434dc

http://www.jaxidian.org/update/2007/05/05/8

http://arnosoftwaredev.blogspot.com/2006/09/net-20-httpwebrequestkeepalive-and.html

他们并没有太多帮助.我已经尝试重载GetWebReuqest,但这没有意义,因为我没有使用该函数.

这是我的代码:http: //pastebin.org/115268

在成功运行至少一次后,我在第245行得到错误.

我很感激我能得到的任何帮助,因为这是我一直在努力的项目的最后一步.这是我的第一个C#/ VS项目,所以我对任何提示持开放态度,但我想专注于首先解决这个问题.

谢谢!

c# httpwebrequest visual-studio-2008

22
推荐指数
2
解决办法
6万
查看次数

C#.NET中HTTP上的SOAP对象

我正在尝试在C#.NET中编写SOAP消息(包括头文件)以使用HTTP post发送到URL.我想将其发送到的URL不是Web服务,它只接收SOAP消息以最终从中提取信息.关于如何做到这一点的任何想法?

.net c# soap http-post envelope

12
推荐指数
1
解决办法
9084
查看次数

Soap调用在c#中给出500(内部服务器错误)

我有一个联盟帐户,我需要soap打电话来获取数据.我从一个站点获得了准备好的代码,我尝试应用它,但我得到了500(internal server error).我的代码如下.

public void getdata()
{
    var _url = "http://secure.directtrack.com/api/soap_affiliate.php";
    var _action = "http://secure.directtrack.com/api/soap_affiliate.php/dailyStatsInfo";

    XmlDocument soapEnvelopeXml = CreateSoapEnvelope();
    HttpWebRequest webRequest = CreateWebRequest(_url, _action);
    InsertSoapEnvelopeIntoWebRequest(soapEnvelopeXml, webRequest);

    // begin async call to web request.
    IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null);

    // suspend this thread until call is complete. You might want to
    // do something usefull here like update your UI.
    asyncResult.AsyncWaitHandle.WaitOne();

    // get the response from the completed web request.
    string soapResult;
    using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult)) …
Run Code Online (Sandbox Code Playgroud)

c# soap

4
推荐指数
3
解决办法
3万
查看次数

HttpWebRequest被取消了

我正在使用ASP.NET来读取Request.InputStream并将HttpRequest发送给发送给我的页面抛出一​​个QueryString参数,我正确读取了Request.InputStream并正确地进行了HttpRequest,但是在我的Request.InputStream中我发现像这样的"Porsvägen"这样的特殊字符我得到了这个错误:ystem.Net.WebException:请求被中止:请求被取消了.---> System.IO.IOException:在写入所有字节之前无法关闭流.在System.Net.ConnectStream.CloseInternal(Boolean internalCall,Boolean aborting)

我获取Request.InputStream的代码是这样的:

string requestData = (new StreamReader(Request.InputStream)).ReadToEnd();
Run Code Online (Sandbox Code Playgroud)

我制作HttpRequest并发送它的代码是这样的:

    webRequest = (HttpWebRequest)WebRequest.Create(new Uri(urlDestination));
    webRequest.Method = "POST";

    webRequest.ContentType = "application/x-www-form-urlencoded";
    webRequest.ContentLength = requestData.Length;

    writer = new StreamWriter(webRequest.GetRequestStream());
    writer.Write(requestData, 0, requestData.Length);//<-------Here I get the ERROR
    if (writer != null)
    {
        writer.Close();
    }
Run Code Online (Sandbox Code Playgroud)

你能否告诉我我的代码有什么问题,因为它有效,但对于特殊字符,它会崩溃.

c# asp.net xmlhttprequest

2
推荐指数
1
解决办法
4285
查看次数