Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
(My actual question is at end)this is what i have
VB
bll.SendXMLData(ds)
                Dim appstring As String = System.Convert.ToBase64String(app) 'this is pdf i am sending               
                Dim base64 As Integer = 1
                Dim XmlUserInfo As XDocument = XDocument.Load("C:\..location")
                Dim XmlEmailInfo As XDocument = XDocument.Load("C:\..location")
                Dim postDoc As String = [String].Format("&version={0}&sid={1}&docId={2}&docData={3}&userInfo={4}&emailInfo={5}&isBase64={6}", version, mySessionID, applicationID, appstring, XmlUserInfo, XmlEmailInfo, base64)


                Dim baseUrl As String = "https://url"
                Dim input As String = postDoc

                Dim responseString As String
                Dim request As HttpWebRequest
                Dim response As HttpWebResponse = Nothing
                Dim reader As StreamReader

                Dim byteData() As Byte
                Dim postStream As Stream = Nothing

                request = DirectCast(WebRequest.Create(baseUrl), HttpWebRequest)
                request.Method = "POST"
                request.ContentType = "application/x-www-form-urlencoded"
                byteData = UTF8Encoding.UTF8.GetBytes(input)
                request.ContentLength = byteData.Length

                postStream = request.GetRequestStream()
                postStream.Write(byteData, 0, byteData.Length)


                response = DirectCast(request.GetResponse(), HttpWebResponse)
                reader = New StreamReader(response.GetResponseStream())
                responseString = reader.ReadToEnd()
                response.Close()

in business logic :
VB
Sub SendXMLData(ByVal ds As DataSet)

            Dim userID As String = "userid@uuu.com"
            Dim fname As String
            Dim lname As String
            Dim subject As String = " document subject"
            Dim message As String = "This message is sent "

            'Try
            With ds.Tables(0).Rows(0)
                fname = .Item("FirstName")
                lname = .Item("LastName")
            End With

            Dim settings As XmlWriterSettings = New XmlWriterSettings()
            settings.Indent = True

            Using writer As XmlWriter = XmlWriter.Create("C:\userInfo.xml", settings)
                writer.WriteStartDocument()
                writer.WriteStartElement("userInfo")
                writer.WriteStartElement("person")
                writer.WriteElementString("uid", userID)
                writer.WriteElementString("firstname", fname)
                writer.WriteElementString("lastname", lname)
                writer.WriteEndElement()
            End Using

            Using writer As XmlWriter = XmlWriter.Create("C:\emailInfo.xml", settings)
                writer.WriteStartDocument()
                writer.WriteStartElement("emailInfo")
                writer.WriteElementString("subject", subject)
                writer.WriteElementString("message", message)
                writer.WriteEndElement()
            End Using


MY Question: is there any way i can send XML file without saving it in local drive and pulling it out(directly create it and send via POST)??
Posted
Updated 29-Aug-13 7:10am
v2
Comments
Zoltán Zörgő 28-Aug-13 15:57pm    
Why not? XML is just a text.

Use XmlTextWriter[^], than you don't have to change a lot. Here it is how: http://www.vb-helper.com/howto_net_build_memory_xml.html[^]
But you could use XmlDocument[^] also...
 
Share this answer
 
Comments
kj15 29-Aug-13 8:38am    
hi
can you please give me an example with webrequest and sending the created xml. i am new to programming, i am trying to find a example online, but no luck.
thanks great!!
Zoltán Zörgő 29-Aug-13 8:44am    
Than try harder: http://p2p.wrox.com/asp-net-1-0-1-1-professional/57098-c-post-xml-using-httpwebrequest-response.html
kj15 29-Aug-13 11:08am    
i tried that. actually there is simplest way i found, you can send xml messages too, instead of sending whole file.
i just did this and it worked

the method returned a string array


Dim aXMLString(1) As String
XML
aXMLString(0) = "<userInfo>" & _
                                "<person>" & _
                                    "<data uid=""userID"" firstname=""fname"" lastname=""lname""/>" & _
                                "</person>" & _
                            "</userInfo>"

aXMLString(1) = "<emailInfo>" & _
                                    "<subject=""subject"" message=""message""/>" & _
                            "</emailInfo>"


Return aXMLString

in my aspx code:

Dim xmls() As String
VB
Dim XMLUserInfo As String = xmls(0)
Dim XMLEmailInfo As String = xmls(1)



Dim postDoc As String = [String].Format("&version={0}&sid={1}&docId={2}&docData={3}&userInfo={4}&emailInfo={5}&isBase64={6}", version, mySessionID, applicationID, appstring, XMLUserInfo, XMLEmailInfo, base64)

pass it to webrequest
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900