0

Here's my code:

        string url = @"http://eafsys:1234/vp.xml";
        try
        {
            XmlTextReader reader = new XmlTextReader(url);
            while (reader.Read())
            {
                // do whatever..
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }

When I run it I catch the following error:

'The server committed a protocol violation. Section=ResponseStatusLine'

I searched the internet and apparently I am supposed to change some web.config file in my IIS. The thing is the system where the XML data comes from doesn't have IIS, it doesn't even have a web server. It's just a program listening on that port waiting to output XML.

I can surf (with a any browser, I.E or FireFox) to http://eafsys:1234/vp.xml and I get nicely formatted XML.

Here is the raw (source view) of the XML:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<EAFSTATUS>
<EAST>
<HEAT_NO>100633</HEAT_NO>
<GRADE>EA174  </GRADE>
<HEATSTATUS>MELT</HEATSTATUS>
<CHARGENUM>2</CHARGENUM>
<CRMTEMP>1657</CRMTEMP>
<CRMC> 0.0519</CRMC>
<CHARGE>178000</CHARGE>
<ENERGY>80710</ENERGY>
<ELECTKWH>46400</ELECTKWH>
<POWERONTIME> 33:18</POWERONTIME>
<POWERSTATUS>OFF</POWERSTATUS>
<DELAYDUR>3:18</DELAYDUR>
<DELAYSTATUS>OPEN </DELAYSTATUS>
<DELAYREASON>          NO REASON </DELAYREASON>
</EAST>
<WEST>
<HEAT_NO>100632</HEAT_NO>
<GRADE>EA174  </GRADE>
<HEATSTATUS>REF </HEATSTATUS>
<CHARGENUM>2</CHARGENUM>
<CRMTEMP>1529</CRMTEMP>
<CRMC> 0.0418</CRMC>
<CHARGE>178500</CHARGE>
<ENERGY>95010</ENERGY>
<ELECTKWH>54500</ELECTKWH>
<POWERONTIME> 39:06</POWERONTIME>
<POWERSTATUS>OFF</POWERSTATUS>
<DELAYDUR></DELAYDUR>
<DELAYSTATUS></DELAYSTATUS>
<DELAYREASON></DELAYREASON>
</WEST>
<LMF_EAST>
<HEAT_NO>100631</HEAT_NO>
<GRADE>EA719  </GRADE>
<HEATSTATUS>DONE</HEATSTATUS>
<LMF_TIME> 58:48</LMF_TIME>
<TEMP>1546</TEMP>
<WT>163100</WT>
<SAMP>M03</SAMP>
<SAMP_S>0.005760</SAMP_S>
<CAO>0</CAO>
<AL2O3>0</AL2O3>
</LMF_EAST>
<LMF_WEST>
<HEAT_NO>100632</HEAT_NO>
<GRADE>EA174  </GRADE>
<HEATSTATUS>REF </HEATSTATUS>
<LMF_TIME> 47:42</LMF_TIME>
<TEMP>1566</TEMP>
<WT>167500</WT>
<SAMP>M02</SAMP>
<SAMP_S>0.000000</SAMP_S>
<CAO>0</CAO>
<AL2O3>0</AL2O3>
</LMF_WEST>
<CASTER>
<HEATNUM>100631</HEATNUM>
<OUTBOARDHEATNUM>0</OUTBOARDHEATNUM>
<CASTSPEED>1.295000</CASTSPEED>
<CASTWIDTH>1.365312</CASTWIDTH>
<REMAININGWEIGHT>66714</REMAININGWEIGHT>
<NEXTTIME>15:20:13.00</NEXTTIME>
<HEATDUR>55</HEATDUR><LADLESINSERVICE>4</LADLESINSERVICE></CASTER>
</EAFSTATUS>

If anyone has any idea's I'd love to hear them.

8
  • I'm guessing that the XmlTextReader.Read() function is looking for a proper HTTP status code. Commented May 3, 2011 at 19:14
  • 1
    I'd suggest to download the XML with WebClient first and then load it into XmlReader as Stream... Commented May 3, 2011 at 19:20
  • I guess there's more to implementing an HTTP server than just listening on port 80 and waiting to output XML. Commented May 3, 2011 at 19:28
  • @jnpcl what is this? @Shrike WebClient give me the EXACT same error. @ConradFrix Yeah I'd assume so. But we have been serving html, xml plain text with no issues. My problem only occurs when trying to consume the xml with .net. Commented May 3, 2011 at 19:32
  • 1
    What do you mean by It's just a program listening on that port waiting to output XML. What does the program listen for? The XmlTextReader() is probably sending it a proper HTTP request, and is throwing because it isn't getting a proper (valid) HTTP response. You may be able to peek at the message exchange using Fiddler2. (free download, good tool) Commented May 3, 2011 at 20:43

2 Answers 2

2

When you tell a browser to open a file with a url you are leveraging the local file (or even network) system. The browser actually is capable of opening the file and reading it. When you tell an XmlTextReader to open a file with a URL you are telling it to issue an httpRequest and expect an httpResponse in return, and that requires an internet server of some flavor.

You might be able to substitute a filestreamreader and then feed that stream to the XmlTextReader, but I haven't tried that. You are likely better of servicing that file from an web server or accessing it via a UNC instead of a URL.

Sign up to request clarification or add additional context in comments.

6 Comments

The problem is that the data being served up is on a VMS system with no web server.
But you should be able to hang a webserver 'near by' (in virtual space) that can accept the httpRequest and get the stream from the VMS and package it to the httpResponse.
If the URL has a protocol of http://, you're telling the browser to issue an HTTP request too. And since he says this is working, it means there is a working web (HTTP) server on that machine.
@svivk NO.. there is no web server on the machine, I wrote a socket program to listen on port 1234, same could be done for port 80 or 8000 for that matter.
@carny666...when you say 'I wrote a socket program to listen on port 1234' what you are saying is that you created a simple form of a web server. It takes in an httpRequest (albeit on port 1234 rather than 80) and issues as response in the form of creating a stream back the requestor. With that in mind I would guess that XmlTextReader is issuing a request differently (unlikely, but possible) or it is not prepared to handle the response that it gets from your port listener, where a browser is (most likely). If you can log those activities you will probably find your disconnect.
|
0

I had a similar error once, although I don't remember whether it was exactly this. Anyway, you can try the solution that worked for me: setting the following property before you download anything:

ServicePointManager.Expect100Continue = false;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.