473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Receive HTTPS Post

I am currently developing an app that will post an XML file (1 to
100MB+ in size) to an outside vendor application via HTTPS Post (doing
this in a vb.net windows app). The vendor will then at some later date
post an updated return XML file to my webserver (asp.net). The primary
problem I'm having is getting the posted stream to load in an
XMLDocument object. When trying to read the posted stream into the
XMLDocument the following error is kicked back from my webserver (seen
by the vendor), "The remote server returned an error: (500) Internal
Server Error." At minimum I want to make sure that the XML they're
posting to me is well-formed so I don't need to load it into an
XMLDocument object if there's another way to do it.
Also they're expecting to post their info to me via HTTPS, how can I
set up my page so it's looking for credentials to be passed along with
the XML stream? I see how to send credentials to them using
System.Net.NetworkCredential, but I don't see how accept credentials
from the vendor when they post to me.
Code used to accept HTTP post from Vendor:
Dim str As Stream
Dim strmContent As String
Dim strLen As Integer
Dim strRead As Integer
'Request input stream from the poster
str = Request.InputStream
'Get the length of incoming string
strLen = str.Length
'make a Byte array the size of the stream
Dim strArr(strLen) As Byte
'read the stream into the array
strRead = str.Read(strArr, 0, strLen)
'the stream will be ASCII encoded
Dim ascii As ASCIIEncoding = New ASCIIEncoding
'Get ASCII into reg. string here
strmContent = ascii.GetString(strArr)
Dim doc As XmlDocument = New XmlDocument
doc.LoadXml(strmContent)
doc.Save("D:\temp\test5.xml")
'Return Response to poster.
Response.Write("some response")
Any suggestions on what I can do to fix this or possible resources that
might help me out?
Thanks!

Nov 19 '05 #1
2 6893
you need a little more research. often when a site post an xml, they are
doing a form post and the xml is stored in a field value. sometimes the xml
is a file attachement (file post), or the body is xml.

check what the content header is, and dump the body to see what they are
sending. you will proably need to send in the same format.

-- bruce (sqlwork.com)
"Amoril" <am****@gmail.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
| I am currently developing an app that will post an XML file (1 to
| 100MB+ in size) to an outside vendor application via HTTPS Post (doing
| this in a vb.net windows app). The vendor will then at some later date
| post an updated return XML file to my webserver (asp.net). The primary
| problem I'm having is getting the posted stream to load in an
| XMLDocument object. When trying to read the posted stream into the
| XMLDocument the following error is kicked back from my webserver (seen
| by the vendor), "The remote server returned an error: (500) Internal
| Server Error." At minimum I want to make sure that the XML they're
| posting to me is well-formed so I don't need to load it into an
| XMLDocument object if there's another way to do it.
|
|
| Also they're expecting to post their info to me via HTTPS, how can I
| set up my page so it's looking for credentials to be passed along with
| the XML stream? I see how to send credentials to them using
| System.Net.NetworkCredential, but I don't see how accept credentials
| from the vendor when they post to me.
|
|
| Code used to accept HTTP post from Vendor:
|
|
| Dim str As Stream
| Dim strmContent As String
| Dim strLen As Integer
| Dim strRead As Integer
|
|
| 'Request input stream from the poster
| str = Request.InputStream
|
|
| 'Get the length of incoming string
| strLen = str.Length
|
|
| 'make a Byte array the size of the stream
| Dim strArr(strLen) As Byte
|
|
| 'read the stream into the array
| strRead = str.Read(strArr, 0, strLen)
|
|
| 'the stream will be ASCII encoded
| Dim ascii As ASCIIEncoding = New ASCIIEncoding
|
|
| 'Get ASCII into reg. string here
| strmContent = ascii.GetString(strArr)
|
|
| Dim doc As XmlDocument = New XmlDocument
| doc.LoadXml(strmContent)
| doc.Save("D:\temp\test5.xml")
|
|
| 'Return Response to poster.
| Response.Write("some response")
|
|
| Any suggestions on what I can do to fix this or possible resources that
| might help me out?
|
|
| Thanks!
|
Nov 19 '05 #2
When doing my research here on google and other dev sites, this was the
only method I could find on how to do it. Is there some more specific
information you can give me such as examples or perhaps a link to where
I can read more on your suggestions?

The code attached below (built for testing the above) will post an XML
stream to a webserver running the code I entered above and will display
the remote servers response, which was the only way I could find
described by other people. My question is specifically how do I get
this code to work for HTTPS posts, since I'm sure you need to send
credientals if you're posting to a server with https (I need to know
how to do it for when I post to other servers, and other people post
back to my servers). If there are better ways of doing this please let
me know where/what I need to look at so I can improve this. Thank you!

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim sr As StreamReader = New StreamReader("c:\test.xml")
Dim XMLRead As String = sr.ReadToEnd
Dim stXML As String
stXML = XMLRead
sr.Close()

Try

Dim results As String

Dim request As WebRequest =
WebRequest.Create("http://Localhost/GetPost.aspx")

request.Method = "POST"
request.ContentType = "text/xml; charset=utf-8" 'look for
other content types to see if this is appropriate. Check for headers as
well
results = WriteToURL(request, stXML)

Dim Response As String

Response = RetrieveFromURL(request)

MessageBox.Show(Response, "", MessageBoxButtons.OK)

Catch ex As Exception
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK)
Exit Sub
End Try

End Sub

Private Function WriteToURL(ByVal Request As WebRequest, ByVal data
As String) As String

Try
Dim bytes = System.Text.Encoding.ASCII.GetBytes(data)
Request.ContentLength = bytes.Length

Dim OutPutStream As Stream = Request.GetRequestStream
OutPutStream.Write(bytes, 0, bytes.length)
OutPutStream.Close()
Catch ex As Exception
MessageBox.Show(ex.Message & " - Write To URL", "error",
MessageBoxButtons.OK)
Exit Function
End Try

End Function

Private Function RetrieveFromURL(ByVal Request As WebRequest) As
String

Try
Dim response As WebResponse = Request.GetResponse
Dim stream As Stream = response.GetResponseStream
Dim sr As StreamReader = New StreamReader(stream)
Return sr.ReadToEnd
Catch ex As Exception
MessageBox.Show(ex.Message & " - Retrieve From URL", "",
MessageBoxButtons.OK)
Exit Function
End Try

End Function

Nov 19 '05 #3

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

Similar topics

0
by: Ing. Angel León | last post by:
http://wedoit4you.com/forums4you/display_message.php?Msg_pk_id=628 /** Author: Ing. Angel Leon Function: postHttps($url,$params) Given the full URL of the Target and The Params it will...
0
by: Terence Parker | last post by:
I am trying to connect an e-commerce system to a payment gateway (located in Hong Kong). The gateway takes values in the form of a simple form submit - however, the results (i.e. authorisation...
16
by: Paul Sweeney | last post by:
Does anyone know of a working (python) https proxy which allows viewing of unencrypted data being sent from my browser to an https site? I've worked my way through most on the list at...
0
by: Amoril | last post by:
I am currently developing an app that will post an XML file ­(1 to 100MB+ in size) to an outside vendor application via HTTPS P­ost (doing this in a vb.net windows app). The vendor will then at...
1
by: dave | last post by:
Hello I have one simple form (myform.asp) and it posts to query.asp I had put below code in both file on top of the page to redirect this two pages in https:// so any one can access it thru http...
7
by: Masahiro Ito | last post by:
I need to be login to several websites and download files that are https connections. I just tried IPWorks demo, but it does not seem to offer https. Does anyone know an https capable product,...
0
by: David Mediavilla | last post by:
I am writing a client for an HTTPS web service using WSE 1.0 but I always get an error like "The underlying connection was closed: An unexpected error occurred on a send." Sometimes the error...
0
by: mahesh anasuri | last post by:
Hi all, I am new to this mailing list. Thankful if any one is using curl/linux version to and worked on Https. I have created certificates (PEM format) for client and server using openSSL. I...
2
by: Arti | last post by:
Hi, I am trying to access a servlet hosted on Tomcat server using HTTPS Post protocol. I am getting the exception: "The underlying connection was closed: Could not establish trust relationship...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.