C#发布XML到URL不起作用(C# Post XML to URL not working)
首先,我是一个WEB NOOB。 这可能解释了这个问题。 无论如何,当我使用网页测试应用程序将xml发布到网址时,一切正常。 这里是从网页(我认为)pertinant代码:
<form action="/gateway/xml" method="post" id="xml-test-form"> <textarea name="data"> {some xml is in here} </textarea> <input type="submit" value="Submit Test" /> </form>
当我尝试使用缓存编码(ASCII或UTF8)的内容类型(“text / xml”或“application / x-www-form-urlencoded”)的C#(WebRequest或HttpWebRequest)提交完全相同的XML时,这意味着XML不能在另一端读取。 这是错误:
<?xml version="1.0"?> <SubmitOrdersResponse> <status code="0">FAILURE</status> <errors> <error code="1001">Invalid XML Version</error> </errors> </SubmitOrdersResponse> <br /><b>Warning</b>: DOMDocument::loadXML() [<a href='domdocument.loadxml'>domdocument.loadxml</a>]: Empty string supplied as input in <b>/var/www/vhosts/reports.gogetagrip.com/httpdocs/application/models/Gateway.php</b> on line <b>90</b><br />
我可以通过删除名为的XML元素使用Web测试人员重现此错误。 我认为这是检查的第一个元素,因此是“INVALID XML VERSION”错误。 我认为发生的事情是我的提交文件以不正确的格式发送,并且该内容不能被读取。 具体而言,我认为我必须模拟发布数据,其中数据来自“数据”表单字段(参见上文)。 我不知道如何使用WebRequest类来设置它,所以我无法测试它。 这是我的代码:
static private void Post(string sURL, string sXml) { try { //Our postvars byte[] buffer = Encoding.UTF8.GetBytes(sXml); // Tried ASCII...same result HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(sURL); // Tried WebRequest ... same result WebReq.Method = "POST"; WebReq.ContentType = "application/x-www-form-urlencoded"; // tried "text/xml"... same result WebReq.ContentLength = buffer.Length; Stream ReqStream = WebReq.GetRequestStream(); ReqStream.Write(buffer, 0, buffer.Length); ReqStream.Close(); WebResponse WebRes = WebReq.GetResponse(); //Console.WriteLine(WebResp.StatusCode); //Console.WriteLine(WebResp.Server); Stream ResStream = WebRes.GetResponseStream(); StreamReader ResReader = new StreamReader(ResStream); string sResponse = ResReader.ReadToEnd(); } catch (Exception ex) { } finally { } }
有任何想法吗?????
First of all, I am a WEB NOOB. Which probably explains this question. Anyway, when I use the web page test app to post xml to a url, everything works fine. Here is the pertinant code from the web page (i think):
<form action="/gateway/xml" method="post" id="xml-test-form"> <textarea name="data"> {some xml is in here} </textarea> <input type="submit" value="Submit Test" /> </form>
When I try to submit the exact same XML using C# (WebRequest or HttpWebRequest) with content type of ("text/xml" or "application/x-www-form-urlencoded") with a buffer encoded (ASCII or UTF8) I get an error that implies the XML cant be read at all on the other end. Here is the error:
<?xml version="1.0"?> <SubmitOrdersResponse> <status code="0">FAILURE</status> <errors> <error code="1001">Invalid XML Version</error> </errors> </SubmitOrdersResponse> <br /><b>Warning</b>: DOMDocument::loadXML() [<a href='domdocument.loadxml'>domdocument.loadxml</a>]: Empty string supplied as input in <b>/var/www/vhosts/reports.gogetagrip.com/httpdocs/application/models/Gateway.php</b> on line <b>90</b><br />
I can reproduce this error using the web tester by removing a XML element named . I think this is the first element that is checked for, and hence the "INVALID XML VERSION" error. I think what is happening is my submittal is comming accross slighlty in the wrong format and that element can't be read. I think specifically I have to simulate a posting data where my data is comming from the "data" form field (see above). I don't know how to set that using the WebRequest class, so I can't test it. Here is my code:
static private void Post(string sURL, string sXml) { try { //Our postvars byte[] buffer = Encoding.UTF8.GetBytes(sXml); // Tried ASCII...same result HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(sURL); // Tried WebRequest ... same result WebReq.Method = "POST"; WebReq.ContentType = "application/x-www-form-urlencoded"; // tried "text/xml"... same result WebReq.ContentLength = buffer.Length; Stream ReqStream = WebReq.GetRequestStream(); ReqStream.Write(buffer, 0, buffer.Length); ReqStream.Close(); WebResponse WebRes = WebReq.GetResponse(); //Console.WriteLine(WebResp.StatusCode); //Console.WriteLine(WebResp.Server); Stream ResStream = WebRes.GetResponseStream(); StreamReader ResReader = new StreamReader(ResStream); string sResponse = ResReader.ReadToEnd(); } catch (Exception ex) { } finally { } }
Any Ideas?????
原文:https://stackoverflow.com/questions/1368419
最满意答案
这是关于如何向
CellTable
添加数据的CellTable
。 例如,你可以myDataProvider.setList(rowData);
要么
myTable.setRowData(rowData);
但上述两种方法都不允许对数据进行排序。 那是因为,您已经使用空列表定义了
ListHandler
。 并且它不会注意到列表已更改,因此不会执行排序。请参阅
ListDataProvider
文档 :getList()返回的列表的修改(插入,移除,设置等)将反映在模型中。 但是,列表中包含的项目的突变不会反映在模型中。 您必须调用List.set(int,Object)来更新列表中的项目并将更改推送到显示,或调用refresh()将所有行推送到显示。 List.set(int,Object)执行得更好,因为它允许数据提供程序仅推送已更改的那些行,并且通常允许显示仅重新呈现行的子集。
所以,你应该先
getList()
并改变它:myDataProvider.getList().clear(); myDataProvider.getList().addAll(rowData);
It is all about how do you add data to the
CellTable
. For example, you canmyDataProvider.setList(rowData);
or
myTable.setRowData(rowData);
but both above methods will not allow the data to be sorted. That is because, you already have
ListHandler
defined with an empty list. And it will not notice that the list have changed, so no sorting will be performed.See
ListDataProvider
documentation:Modifications (inserts, removes, sets, etc.) to the list returned by getList() will be reflected in the model. However, mutations to the items contained within the list will NOT be reflected in the model. You must call List.set(int, Object) to update the item within the list and push the change to the display, or call refresh() to push all rows to the displays. List.set(int, Object) performs better because it allows the data provider to push only those rows which have changed, and usually allows the display to re-render only a subset of the rows.
So, you should first
getList()
and change it like this:myDataProvider.getList().clear(); myDataProvider.getList().addAll(rowData);
相关问答
更多-
这是关于如何向CellTable添加数据的CellTable 。 例如,你可以 myDataProvider.setList(rowData); 要么 myTable.setRowData(rowData); 但上述两种方法都不允许对数据进行排序。 那是因为,您已经使用空列表定义了ListHandler 。 并且它不会注意到列表已更改,因此不会执行排序。 请参阅ListDataProvider文档 : getList()返回的列表的修改(插入,移除,设置等)将反映在模型中。 但是,列表中包含的项目的突变 ...
-
我只是自己整理了一下,但这里有一个例子说明了我的工作原理: CellTable
dataTable = new CellTable (); Column status = new Column (new ImageResourceCell()) { @Override public ImageResource getValue(Entity enti ... -
如何在CellTable GWT中使用空单元格对Date Column进行排序(How to sort Date Column with empty cells in CellTable GWT)[2022-07-17]
我解决了我的问题 public class RegDateComparator implements Comparator{ @Override public int compare(DocList o1, DocList o2) { if (o1 == o2) { return 0; } DateTimeFormat dateFormat = DateTimeFormat ... -
我正在使用CellTable来显示文件列表(文件名,大小,Mime类型)。 我可以使用以下代码在单击标题时按列进行单独排序: 首先,我将列标记为可排序: urlColumn.setSortable(true); mimeColumn.setSortable(true); sizeColumn.setSortable(true); 然后我为每列添加一个创建ColumnSortHandler,并添加到表中,如下所示: // Add sorting for the Name column ...
-
您可以使用setColumnWidth方法设置列宽。 You can set the column width with the setColumnWidth method.
-
你可以在那里找到答案: http://groups.google.com/group/google-web-toolkit/browse_thread/thread/fcd4ad18e2435aba 基本上,当您向表中添加列时: 使用table.addColumn(Column column); 而不是table.addColumn(Column column, String header); You can find you answer there: http://groups.google.com/g ...
-
您可以在Button列上设置FieldUpdater: column.setFieldUpdater(new FieldUpdater
() { @Override public void update(int index, Auction object, String value) { // The user clicked on the button for the passed auction. } }); 来自GWT文档的CellSampler有 ... -
假设您的User对象具有如下所示的部门列表: public ArrayList
getDepartments() { // ... } 您可以创建一个列来列出部门,如下所示: TextColumn departmentsColumn = new TextColumn () { @Override public String getValue(User object) { StringBuilder departments ... -
您是否试图避免将Model类与View绑定? 我尝试为cellTable做这个,但是维护代码变得令人困惑所以我决定让Model类与View结合。 你可以在创建视图时通过一些通用参数来避免这种耦合。 -Saket Are you trying to avoid binding of Model class with View? i tried doing that for cellTable but it was becoming confusing to maintain code so i decided ...
-
我创建了一个看起来像这样的函数(其中redRow和yellowRow是我的CSS中的样式): private void highlightAlerts() { alertHighlight = true; Range range = siteTable.getVisibleRange(); int start = range.getStart(); for (int i=0; i
相关文章
更多- howto:solr post.jar使用
- httpclient post 请求
- Working on Free Software
- [转] C#开源项目大全
- 微信开发者-主动请求-准备工作-(1)发送get、post请求,上传文件(C#)
- C#开发微信公众化平台
- 应用SQLServer For XML 生成XML避免在C# 拼字符串
- solr 通过URL删除索引
- jstl c:url教程-jstl输出url标签
- C#开发微信公众平台-就这么简单(附Demo)
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)