troubleshooting Question

Post to asp/xmlhttp from Aspx and consume xml response

Avatar of pcoppney
pcoppney asked on
27 Comments1 Solution4439 ViewsLast Modified:
I am trying to post xml to an existing asp page from an aspx page and recieve the xml response.  The code executes fine until the "myWriter.Write(strXML)" statement.  Never returns from asp page.  I have tested the asp page and it works with posts from other asp pages.  The problem occurs when posting from .net.

Any Ideas?

here is the code for the aspx call to the asp:

    Function PostToRSXML(ByVal url As String, ByVal strXML As String) As String
        Dim result As String = ""
        Dim myWriter As StreamWriter

        Dim objRequest As HttpWebRequest = WebRequest.Create(url)
        objRequest.Method = "POST"
        objRequest.ContentLength = strXML.Length
        objRequest.ContentType = "application/x-www-form-urlencoded"

            myWriter = New StreamWriter(objRequest.GetRequestStream())
        Catch e As Exception
            Return e.Message
        End Try

        Dim objResponse As HttpWebResponse = objRequest.GetResponse()
        Dim sr As StreamReader
        sr = New StreamReader(objResponse.GetResponseStream())
        result = sr.ReadToEnd()

        Return result
    End Function

Here is the ASP page code:

      Set req = server.CreateObject("MSXML.DOMDocument")
      blnRetVal = req.load(Request)

      if blnRetVal then
                  'Get the XML source
                  set mynode=req.getElementsByTagName("Root")

                  strXML = mynode.item(0).xml
                  ' Create the VB object
                  Set objXML = Server.CreateObject("Objname.Classname")
                  lngRetVal = objXML.buildresponse("", "", strXML, strXMLOutput, True)
                  Set objXML = Nothing

                  Select Case lngRetVal
                        Case 0
                        ' Write the XML
                              Response.Write strXMLOutput

                        ' Now we are done!
                        Case else
                              Response.Write strXMLOutput
                  End Select
      end if
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 27 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 27 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros