473,466 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

what's wrong with xml post code?

Hi
Trying to get this code to work for http xml post.
I need the post to be xml (doc.outerxml) sent in single key name as stream.
The following is the post code and code for receiving the request.
When it hits the "myresponse = myrequest.GetResponse()" in the post code -
I'm getting following error:
"The remote server returned an error: (500) Internal Server Error".
I don't know if I have something wrong with the post or receiving it on the
other end.
Right now I'm trying to write it in .net 1.1.
Any help will be greatly appreciated.
Thanks,
Cindy

Dim url As String = "http://someplace.aspx"
Dim myrequest As System.Net.WebRequest = Nothing
Dim myresponse As System.Net.WebResponse = Nothing
Try
' Create a request using a URL that can receive a post.
myrequest = System.Net.WebRequest.Create(url)
' Set the Method property of the request to POST.
myrequest.Method = "POST"
' Set the ContentType property of the WebRequest.
myrequest.ContentType = "application/x-www-form-urlencoded"
' Create POST data and convert it to a byte array.
Dim vxml = "Interface_2=" + HttpUtility.UrlEncode(Doc.OuterXml)
Dim byteArray As Byte() =
System.Text.Encoding.UTF8.GetBytes(vxml)
' Set the ContentLength property of the WebRequest.
myrequest.ContentLength = byteArray.Length
' Get the request stream.
Dim dataStream As System.io.Stream =
myrequest.GetRequestStream()
' Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length)
' Close the Stream object.
dataStream.Close()
' Get the response.
myresponse = myrequest.GetResponse() ' error occurs on this
line
Catch ex As Exception
Throw ex
Finally
' Close streams
If Not myrequest Is Nothing Then
myrequest.GetRequestStream().Close()
If Not myresponse Is Nothing Then
myresponse.GetResponseStream().Close()
End Try

Code for receiving the post:
Dim strReader As System.IO.StringReader = Nothing
Dim Reader As System.Xml.XmlTextReader = Nothing
Response.ContentType = "application/x-www-form-urlencoded"
Response.Clear()
Try
strReader = New
System.IO.StringReader(Request.Form("Interface_2") )
Reader = New System.Xml.XmlTextReader(strReader)
Do While Reader.Read()
Jun 27 '08 #1
2 1456
Hi Cindy,

Did you try to see what are the records in EventLog for ASPNET? Sure it gives
you the answer (or at least nearest envestigation point)?

Regards, Alex

CHi
CTrying to get this code to work for http xml post.
CI need the post to be xml (doc.outerxml) sent in single key name as
Cstream.
CThe following is the post code and code for receiving the request.
CWhen it hits the "myresponse = myrequest.GetResponse()" in the post
Ccode -
CI'm getting following error:
C"The remote server returned an error: (500) Internal Server Error".
CI don't know if I have something wrong with the post or receiving it
Con the
Cother end.
C
Jun 27 '08 #2
I'm using xmlreader, not a xmltextreader and moved it to .net 2.0, but still
no luck.

"CindyH" <ch*******@new.rr.comwrote in message
news:OE**************@TK2MSFTNGP04.phx.gbl...
Hi
Trying to get this code to work for http xml post.
I need the post to be xml (doc.outerxml) sent in single key name as
stream.
The following is the post code and code for receiving the request.
When it hits the "myresponse = myrequest.GetResponse()" in the post code -
I'm getting following error:
"The remote server returned an error: (500) Internal Server Error".
I don't know if I have something wrong with the post or receiving it on
the other end.
Right now I'm trying to write it in .net 1.1.
Any help will be greatly appreciated.
Thanks,
Cindy

Dim url As String = "http://someplace.aspx"
Dim myrequest As System.Net.WebRequest = Nothing
Dim myresponse As System.Net.WebResponse = Nothing
Try
' Create a request using a URL that can receive a post.
myrequest = System.Net.WebRequest.Create(url)
' Set the Method property of the request to POST.
myrequest.Method = "POST"
' Set the ContentType property of the WebRequest.
myrequest.ContentType = "application/x-www-form-urlencoded"
' Create POST data and convert it to a byte array.
Dim vxml = "Interface_2=" + HttpUtility.UrlEncode(Doc.OuterXml)
Dim byteArray As Byte() =
System.Text.Encoding.UTF8.GetBytes(vxml)
' Set the ContentLength property of the WebRequest.
myrequest.ContentLength = byteArray.Length
' Get the request stream.
Dim dataStream As System.io.Stream =
myrequest.GetRequestStream()
' Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length)
' Close the Stream object.
dataStream.Close()
' Get the response.
myresponse = myrequest.GetResponse() ' error occurs on this
line
Catch ex As Exception
Throw ex
Finally
' Close streams
If Not myrequest Is Nothing Then
myrequest.GetRequestStream().Close()
If Not myresponse Is Nothing Then
myresponse.GetResponseStream().Close()
End Try

Code for receiving the post:
Dim strReader As System.IO.StringReader = Nothing
Dim Reader As System.Xml.XmlTextReader = Nothing
Response.ContentType = "application/x-www-form-urlencoded"
Response.Clear()
Try
strReader = New
System.IO.StringReader(Request.Form("Interface_2") )
Reader = New System.Xml.XmlTextReader(strReader)
Do While Reader.Read()

Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
5
by: titan0111 | last post by:
#include<iostream> #include<iomanip> #include<cstring> #include<fstream> using namespace std; class snowfall { private: int ft;
46
by: Keith K | last post by:
Having developed with VB since 1992, I am now VERY interested in C#. I've written several applications with C# and I do enjoy the language. What C# Needs: There are a few things that I do...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
5
by: Joey | last post by:
I am attempting to hook the onChange event for a dropdown list with javascript so that I can do some stuff and then initiate a postback with my code. I have not yet learned about how to do...
28
by: federico_bertola | last post by:
Hi everybody! I have this function: int Scan(char String) { printf("%s", String); } it works but when I try to pass a dotted string o separetad with (" ", "_" , "-" ...ecc)
11
pbmods
by: pbmods | last post by:
A somewhat obscure hack has emerged recently that is an offshoot of the now-infamous XSS. It is known as Cross-Site Request Forgery, or XSRF for short. XSRF is a form of temporary identity theft...
10
by: Enkidu | last post by:
Beginner question, sorry! I am using indexers to access an array of StringBuilders in an instance of a class: Getting: value = board1; Setting: board1 = value1 ;
89
by: Tubular Technician | last post by:
Hello, World! Reading this group for some time I came to the conclusion that people here are split into several fractions regarding size_t, including, but not limited to, * size_t is the...
2
by: CindyH | last post by:
Hi Trying to get this code to work for http xml post. I need the post to be xml (doc.outerxml) sent in single key name as stream. The following is the post code and code for receiving the request....
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.