Access the Posted XML data from Web Service in ASP.Net

aliyuusman
 
on Feb 02, 2017 07:40 AM
4953 Views

Hello Sir,

I am developing a Web Service That will Communicate With Another Server to Exchange XML Data

The data sent via HTTP Post will be xml, hence the content type is text/xml.   The request message will not be in a parameter but a raw post directly to stream.

I WANT TO READ THE raw stream Data and Read the XML posted for processing . That is where i am stack.

This is the Web Method i have tried

<WebMethod>
    Public Function payment() As String

        Dim reader As StreamReader = New StreamReader(HttpContext.Current.Request.InputStream)
        Dim requestFromPost As String = reader.ReadToEnd
        Return requestFromPost

    End Function

I am New In this forum , ihad from a friend that people in this forum solved almost all problem posted.

Please Help me.

Download FREE API for Word, Excel and PDF in ASP.Net: Download
aliyuusman
 
on Feb 02, 2017 09:29 AM

Hello,

I am sorry i may not put on my question correctly but i do receive the posted data but not in correct format

HTML POST

 <form name="form1" action="http://localhost/prosessor.asmx/payment"  method="post">

        <input name="xml_data" type="hidden" value="<note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>"  />
    </form>
    <script language="javascript">
         document.forms["form1"].submit();
    </script>

XML DATA SENT ON HTTP POST

<note>
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note>

DATA RECEIVED FROM HTTP POST

<string>xml_data=%3Cnote%3E%3Cto%3ETove%3C%2Fto%3E%3Cfrom%3EJani%3C%2Ffrom%3E%3Cheading%3EReminder%3C%2Fheading%3E%3Cbody%3EDon%27t+forget+me+this+weekend%21%0D%0A%3C%21--+Visual+Studio+Browser+Link+--%3E%0D%0A%3Cscript+type%3D</string>

THIS IS EXACTLY WHAT I AM TRYING TO ACHIVE. I WANT TO GET THE ACTUAL XML DATA THAT WAS SENT FROM HTTP POST.

THAnk you

aliyuusman
 
on Feb 03, 2017 08:39 AM

Thank you Very much

This help allot

Thank you