tusharvichare 0 Newbie Poster

Hello Friends,

I am developing one windows application in that application Client sending one XML String using HTTP Post method. it is like,
<Student><ID>415<ID><Name>XYX<Name><Add>MUMBAI<Add><ContactNo>9302154789<ContactNo>
</Student>
For this string I want to develop one web service wich accept this string plz help me.

As well as on client side I am writing the code to send XML string plz reply me it is correct or not.
' Create a Request using a URL that can receive a post.
Dim Request As WebRequest = WebRequest.Create(url)
Request.Method = "POST"

Dim PostData As String = "<Student><ID>415<ID><Name>XYX<Name><Add>MUMBAI<Add><ContactNo>9302154789<ContactNo>
</Student> "
Dim ByteArray As Byte() = Encoding.UTF8.GetBytes(PostData)
Dim Instance As New WebException
Dim Value As WebExceptionStatus
' Set the ContentType property of the WebRequest.
'Request.ContentType = "application/x-www-form-urlencoded"
Request.ContentType = "text"
'Request.ContentType = "XML"
' Set the ContentLength property of the WebRequest.
Request.ContentLength = ByteArray.Length
' Get the Request stream.
Dim dataStream As Stream = Request.GetRequestStream()
' Write the data to the Request stream.
dataStream.Write(ByteArray, 0, ByteArray.Length)
' Close the Stream object.
dataStream.Close()
' Get the response.
Value = Instance.Status
Dim response As WebResponse = Request.GetResponse()
' Display the status.
Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
' Get the stream containing content returned by the server.
dataStream = response.GetResponseStream()
' Open the stream using a StreamReader for easy access.
Dim reader As New StreamReader(dataStream)
' Read the content.
Dim responseFromServer As String = reader.ReadToEnd()

TextBox1.Text += responseFromServer

' Clean up the streams.
reader.Close()
dataStream.Close()
response.Close()

If u have any idea plz send me code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.