Okay
well i hope i understand this right ,,, but here is my implementation
Client code ( VB executable )
Imports System.Net
Imports System.Web
Imports System.Xml
Imports System
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim url As String = "
http://localhost/Default.aspx"
Dim objDoc As New System.Xml.XmlDocument
objDoc.Load("c:\sample.xml")
MsgBox(SendAndReceive(url, objDoc.OuterXml))
End Sub
Public Function SendAndReceive(ByVal Url As String, ByVal vxml As
String) As String
Dim ResultHTML As String = String.Empty
Try
Dim myrequest As System.Net.WebRequest =
System.Net.WebRequest.Create(Url)
myrequest.Method = "POST"
myrequest.ContentType = "text/xml"
Dim byteArray As Byte() =
System.Text.Encoding.UTF8.GetBytes(vxml)
myrequest.ContentLength = byteArray.Length
Dim dataStream As System.IO.Stream =
myrequest.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
Dim myresponse As System.Net.WebResponse =
myrequest.GetResponse()
Dim Reader As New
IO.StreamReader(myresponse.GetResponseStream)
ResultHTML = Reader.ReadToEnd()
Catch ex As Exception
End Try
Return ResultHTML
End Function
End Class
Server code ( default.aspx )
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Response.Clear()
Dim Reader As New IO.StreamReader(Request.InputStream)
Dim result As String = Reader.ReadToEnd()
Response.Write(result)
End Sub
End Class
i hope above makes sence
ofcourse in my example i just send the xml file and display the response
of
the default.aspx just to see if the xml had arrived
but i guess this is what you wanted ??
HTH
Michel Posseth [MCP]
:
well the deal is that I need the post sent in key word - like
test=doc.outerxml
Maybe you could explain the task a bit more ?
You want to send XML data with a post command , this you can not do
without encoding the XML data
this task is simple
But then you brought up streaming and i got confused , on HTTP
everything
is text this doens`t mean you cannot send binary`s cause you can with
encoding and decoding ( BASE 64 or ROT 13 or even a custom protocol
as
long as the outcome is a text format that doesn`t interfere with HTML
gs )
hth
Michel
"CindyH" <
[email protected]> schreef in bericht
Hi
I'm not sure whether I should send this as a new message or use the
one
I've been using but...
I'm using vb.net 2.0 -
My problem is I need to send
something like this: 'dim encodedstring = "test=" +
httputility.urlencode(doc.outerxml)' as a http xml post and then need
to
receive it on other end for a test.
It needs to be sent as a stream.
I need some sample code on how to post it and then receive the
request on
other end so I get the information from the xml.
Been playing around with all kinds of code and not getting anywhere.
Thanks,
Cindy