English 中文(简体)
用莫托什载荷的Xml在装置上失效
原标题:Uploading xml with Monotouch fails on the device

我正试图通过蒙托库的网络客户发出XML。 虽然所有工作都在SOS模拟器上,但当仪器上台时,我会例外。 这里是法典。

try
{
   Byte[] sendData = System.Text.Encoding.UTF8.GetBytes(someXML) ;
   WebClient client = new WebClient();
   Byte[] forResp;
   client.Headers.Add("Content-Type","text/xml");

   bresp = wc.UploadData(URL, sendData);
   string resp = System.Text.Encoding.ASCII.GetString(forResp);
   XmlDocument xresp = new XmlDocument();
   xresp.LoadXml(resp);
   return xresp;
}
catch
{
    // error
}

我尝试了网上电话,因为我与HttpWebRequest有同样的问题。

例外:

The request timed out
System.Net.Web例外: The request timed out
  at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00065] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:830 
  at System.Net.HttpWebRequest.GetResponse () [0x0000e] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:836 
  at System.Net.WebClient.GetWebResponse (System.Net.WebRequest request) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebClient.cs:1433 
  at System.Net.WebClient.ReadAll (System.Net.WebRequest request, System.Object userToken) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebClient.cs:866 
  at System.Net.WebClient.UploadDataCore (System.Uri address, System.String method, System.Byte[] data, System.Object userToken) [0x00038] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebClient.cs:462 
  at System.Net.WebClient.UploadData (System.Uri address, System.String method, System.Byte[] data) [0x00035] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebClient.cs:441 
最佳回答

批次告诉我们,时间是在<代码>WebClient试图从服务器(而不是在将数据上载到服务器)上得到回复时进行的。 也就是说,使用服务器不是问题(为什么门槛值非常有用?)

接下来的步骤取决于您是否控制服务器。 如果你控制服务器,则检查其记录,以便发现申请,并检查如何处理。 如果可能,也确保你收到/编码了模拟器和装置之间的数据。

如果你不控制服务器,那么就更难以知道该服务器内部的运行情况。 例如,它可能不喜欢请求(即服务器代码可以决定不根据任何条件,包括用户-代理人)作出答复。

在这种情况下,使用<条码>底线<>/条码>等工具,常常是你的最佳灯塔。 将会议与SOS模拟器和仪器相比较。

  • 请求是否相同? 例如,由于其他原因,你上载的数据可能有所不同;

  • 服务器是否回答该装置? ? 同一时间框架?

如果所有事情都相同,那么你就会发现一个ug子。 http://bugzilla.xamarin.com

否则,你就应该有更准确的lu子来解答这一问题和(或)将问题更具体地加以更新:-

问题回答

暂无回答




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签