Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Post XML to URL not working
    primarykey
    data
    text
    <p>First of all, I am a WEB NOOB. Which probably explains this question. Anyway, when I use the <a href="http://reports.gogetagrip.com/gateway/xml-submit-orders-test" rel="nofollow noreferrer">web page test app</a> to post xml to a url, everything works fine. Here is the pertinant code from the web page (i think):</p> <pre><code>&lt;form action="/gateway/xml" method="post" id="xml-test-form"&gt; &lt;textarea name="data"&gt; {some xml is in here} &lt;/textarea&gt; &lt;input type="submit" value="Submit Test" /&gt; &lt;/form&gt; </code></pre> <p>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:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;SubmitOrdersResponse&gt; &lt;status code="0"&gt;FAILURE&lt;/status&gt; &lt;errors&gt; &lt;error code="1001"&gt;Invalid XML Version&lt;/error&gt; &lt;/errors&gt; &lt;/SubmitOrdersResponse&gt; &lt;br /&gt;&lt;b&gt;Warning&lt;/b&gt;: DOMDocument::loadXML() [&lt;a href='domdocument.loadxml'&gt;domdocument.loadxml&lt;/a&gt;]: Empty string supplied as input in &lt;b&gt;/var/www/vhosts/reports.gogetagrip.com/httpdocs/application/models/Gateway.php&lt;/b&gt; on line &lt;b&gt;90&lt;/b&gt;&lt;br /&gt; </code></pre> <p>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:</p> <pre><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 { } } </code></pre> <p>Any Ideas?????</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload