HttpWebRequest adding junk characters
- From: "Sandeep" <nojunk@xxxxxxxxxx>
- Date: Thu, 7 Jul 2005 09:12:01 -0400
I am trying to invoke a remote Web Service that accepts XML data over https
but the server is returning a "The data at the root level is invalid. Line
1, position 1." error. I checked with the provider and he said that they
were receiving following on their server... Notice the weird junk characters
at the front...
<?xml version="1.0" encoding="utf-8"?>
<request><name>blah</blah><address>blah blah</address></request>
I checked the XML I am sending by writing it to a file instead of sending
over http and it was fine. I then created an ASP.NET web application that
took a request and wrote it out to a file. This also worked fine and there
were no junk characters in it. So I think the XML is being created correctly
and the only time there is a problem is when I am invoking a remote service
over https. Does anyone why the remote server is getting those junk
characters? Any suggestions are welcome...
I am using the following code to create my httpWebRequest
httpWebRequest = System.Net.WebRequest.Create(https://blah.blah.com)
httpWebRequest.Method = "POST"
httpWebRequest.ContentType = "text/xml"
Dim oProxy As WebProxy = WebProxy.GetDefaultProxy()
oProxy.Credentials = CredentialCache.DefaultCredentials
httpWebRequest.Proxy = oProxy
httpWebRequest.KeepAlive = False
httpWebRequest.ProtocolVersion = New System.Version("1.0")
httpWebRequest.Timeout = 12000
and following code to invoke the Web service
xmlWriter = New XmlTextWriter(httpRequest.GetRequestStream(),
System.Text.Encoding.UTF8)
With xmlWriter
..WriteStartDocument()
..WriteStartElement("request")
..WriteElementString("name", "blah")
..WriteElementString("address", "blah blah")
..WriteEndElement()
..WriteEndDocument()
..Flush()
..Close()
End With
xmlReader = New XmlTextReader(httpRequest.GetResponse().GetResponseStream())
Thanks in advance,
Sandeep
.
- Follow-Ups:
- Re: HttpWebRequest adding junk characters
- From: Sandeep
- Re: HttpWebRequest adding junk characters
- Prev by Date: How to stop the webservice once invoked
- Next by Date: Re: HttpWebRequest adding junk characters
- Previous by thread: How to stop the webservice once invoked
- Next by thread: Re: HttpWebRequest adding junk characters
- Index(es):
Relevant Pages
|