Ask a Question related to ASP.NET Web Services, Design and Development.
-
Sandeep #1
HttpWebRequest adding junk characters
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([url]https://blah.blah.com[/url])
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().GetRespons eStream())
Thanks in advance,
Sandeep
Sandeep Guest
-
Contribute Adding Characters to Contact Text
When I edit a web page in Contribute, I notice that at the bottom of the page that I publish, before the copyright information that's on every page... -
XML::Twig parser junk.
Hi, I'm trying to use XML::Twig to insert dates into <unitdate> tags to create an EAD finding aid, but I'm running into a strang XML::Twig parser... -
XML error: junk after document element
I am trying to parse and xml document: <?xml version="1.0"?> <!DOCTYPE PrequalResponse PUBLIC "-//New Edge Networks//DTD Pilot Prequalification... -
One Man's Junk
Some cameras which were rescued from dusty shelves and the junk heap. http://www.oceans-away.com/camera/ -
Junk mail on the list.
I'm getting a lot of junk mail that is addressed to this list. Am I the only one getting this stuff? alex -- To UNSUBSCRIBE, email to... -
Sandeep #2
Re: HttpWebRequest adding junk characters
Problem solved. It was the xmlTextWriter that was creating the problem. I
directly wrote a string out to the server and it worked fine.
"Sandeep" <nojunk@nojunk.com> wrote in message
news:ugpw3VvgFHA.2852@TK2MSFTNGP15.phx.gbl...>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([url]https://blah.blah.com[/url])
> 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().GetRespons eStream())
>
> Thanks in advance,
>
> Sandeep
>
>
>
>
>
>
Sandeep Guest
-
dj_axl@yahoo.com #3
Re: HttpWebRequest adding junk characters
Try using an encoding other than System.Text.Encoding.UTF8.
************************************************** ********************
Sent via Fuzzy Software @ [url]http://www.fuzzysoftware.com/[/url]
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
dj_axl@yahoo.com Guest



Reply With Quote

