Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 2nd, 2004, 01:24 AM
Registered User
 
Join Date: Jun 2004
Location: Mohali, Panjab, India.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default returning XML from ASP page

sir,
i want to return xml document from my ASP page
however this xml page is accessed by a java application

i'm getting a url string with some arguments from that java
application ,and after processing these arguments i return
the results as xml document

however java application is not receiving anything
following is the asp page

plz help
thanx


<%
Response.ContentType="text/xml"

    On Error Resume Next

    Dim AuthenticationKey
    Dim UserName
    Dim Name
    Dim Password
    Dim RecMoNum
    Dim Sms
    Dim DeliveryDate
    Dim myType1
    Dim Confirmation
    Dim myResponse
    Dim myRequest

    Dim myconn
    Dim mappedpath
    Dim myRSCustInfo,MyRSPendMsg,myRSPendConf
    Dim akeyfound,userfound
    Dim myDoc
    Dim curDate
    Dim responsetag,errortag,messagetag,messagetext
    Dim confirmationtag,confmessagetag,confmessagetext
    Dim confmobiletag,confmobiletext
    Dim confDatetag,confDatetext
    Dim confddatetag,confddatetext

    AuthenticationKey = Request.QueryString("AKey")

    UserName = Request.QueryString("UName")
    Password = Request.QueryString("Pass")
    RecMoNum = Request.QueryString("RMNum")
    Sms = Request.QueryString("SMS")
    DeliveryDate = Request.QueryString("DDate")
    myType1 = Request.QueryString("myType")
    Confirmation = Request.QueryString("CR")
    myResponse = Request.QueryString("res")
    myRequest = Request.QueryString("req")

    mappedpath = server.mappath("WebSMS.mdb")


       Set myConn=Server.CreateObject("ADODB.Connection")
    myDoc = server.CreateObject("Microsoft.XMLDOM")
    myDoc.async=false
' myDoc.PreserveWhiteSpace = True


    myconn.Provider="Microsoft.Jet.OLEDB.4.0"
        myConn.Open mappedpath

    responsetag=myDoc.createNode("ResponseTag")
    'myDoc.documentElement=responsetag
    myDoc.appendChild (responsetag)

    Set myRSCustInfo = Server.CreateObject("ADODB.Recordset")

    myRSCustInfo.Open "CustomerInfo", myConn, , adLockOptimistic, adCmdTable

    akeyfound = false
    Do While Not (myRSCustInfo.EOF or akeyfound)
            If (StrComp(myRSCustInfo("AuthenticationKey"),_
        Authenticationkey,vbTextCompare) = 0) Then

            akeyfound = True

        else
            myRSCustInfo.MoveNext
        End If

         Loop


    If Not akeyfound Then
        errortag = myDoc.createElement("Error")
        messagetag = myDoc.createElement("Message")
        messagetext = myDoc.createTextNode("Authentication Key Not Found")
        messagetag.appendchild(messagetext)
        errortag.appendchild(messagetext)
        responsetag.appendchild(errortag)
        Response.Write(myDoc.xml)
        myRSCustInfo.Close
        Set myRSCustInfo = Nothing
        myconn.Close
        Set myconn = Nothing
        Response.end
    End If

    If Not (StrComp(myRSCustInfo("UserName"),_
        UserName,vbTextCompare) = 0) Then
        errortag = myDoc.createElement("Error")
        messagetag = myDoc.createElement("Message")
        messagetext = myDoc.createTextNode("User Name Not Found")
        messagetag.appendchild(messagetext)
        errortag.appendchild(messagetext)
        responsetag.appendchild(errortag)
        Response.Write(myDoc.xml)
        myRSCustInfo.Close
        Set myRSCustInfo = Nothing
        myconn.Close
        Set myconn = Nothing
        Response.end
    End If

    If Not (StrComp(myRSCustInfo("Password"), Password,vbBinaryCompare) = 0) Then

        errortag = myDoc.createElement("Error")
        messagetag = myDoc.createElement("Message")
        messagetext = myDoc.createTextNode("Invalid Password")
        messagetag.appendchild(messagetext)
        errortag.appendchild(messagetext)
        responsetag.appendchild(errortag)
        Response.Write(myDoc.xml)


        myRSCustInfo.Close
              Set myRSCustInfo = Nothing
              myConn.Close
              Set myConn = Nothing
        Response.End
        End If

    Name = myRSCustInfo("Name")

    Set myRSPendMsg = Server.CreateObject("ADODB.Recordset")

    myRSPendMsg.Open "PendingMsg", myConn, , adLockOptimistic, adCmdTable
        curDate = Date()


    myRSPendMsg.AddNew

    myRSPendMsg("AuthenticationKey") = AuthenticationKey
    myRSPendMsg("Name") = Name
    myRSPendMsg("MobileNumber") = RecMoNum
    myRSPendMsg("Message") = Sms
    myRSPendMsg("TypeofMessage") = myType
    myRSPendMsg("ConfirmationRequired") = Confirmation
    myRSPendMsg("MessageDate") = curDate
    myRSPendMsg("DeliveryDate") = DeliveryDate

    myRSPendMsg.Update

    If (Strcomp(myResponse,"yes",vbTextCompare) = 0) Then

    Set myRSPendConf = Server.CreateObject("ADODB.Recordset")

    myRSPendConf.Open "pendConfirmation", myConn, , adLockOptimistic, adCmdTable


    Do while not myRSPendConf.eof
        if (StrComp(myRSPendConf("AuthenticationKey") ,_
        AuthenticationKey ,vbBinaryCompare)=0) Then
            confirmationtag = myDoc.CreateElement("Confirmation")
            confmessagetag = myDoc.createElement("Message")
            confmessagetext=myDoc.createTextNode(myRSPendConf( "ConfirmationMessage"))
            confmessagetag.appendchild(confmessagetext)
            confirmationtag.appendchild(confmessagetag)

            confmobiletag = myDoc.createElement("Mobile")
            confmobiletext=myDoc.createTextNode(myRSPendConf(" MobileNumber"))
            confmobiletag.appendchild(confmobiletext)
            confirmationtag.appendchild(confmobiletag)

            confDatetag = myDoc.createElement("Date")
            confDatetext=myDoc.createTextNode(myRSPendConf("Me ssageDate"))
            confDatetag.appendchild(confDatetext)
            confirmationtag.appendchild(confDatetag)

            confddatetag = myDoc.createElement("dDate")
            confddatetext=myDoc.createTextNode(myRSPendConf("D eliveryDate"))
            confddatetag.appendchild(confddatetext)
            confirmationtag.appendchild(confddatetag)

            responsetag.appendchild(confirmationtag)
        End If
    Loop
' myDoc.save(Server.mappath("myxml.xml"))
    response.write(myDoc.xml)

    myRSPendConf.Close
    Set myRSPendConf = Nothing

    end if

    myRSCustInfo.Close
        Set myRSCustInfo = Nothing
        myRSPendMsg.Close
    Set myRSPendMsg = Nothing
    myConn.Close
        Set myConn = Nothing

%>
  #2 (permalink)  
Old July 6th, 2004, 04:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen N, , Denmark.
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

Remember that StrComp takes strings as arguments. That is you need to put quotation marks (") around the strings.
Code:
 if (StrComp("myRSPendConf("AuthenticationKey")" ,_
        "AuthenticationKey" ,vbBinaryCompare)=0) Then



 - mega
  #3 (permalink)  
Old July 6th, 2004, 01:20 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

But Mega, I am not sure if that would work as expected for amrit_82.

If myRSPendConf("AuthenticationKey") contains "XYZ" as its value, then surrounding this in quotes, would treat that as string itself myRSPendConf("AuthenticationKey") and would not be considered as "XYZ" for comparision as I see them both as variables in amrit_82's code.

Code:
if (StrComp("myRSPendConf("AuthenticationKey")" ,_
        "AuthenticationKey" ,vbBinaryCompare)=0) Then


Cheers!

_________________________
- Vijay G
Strive for Perfection
  #4 (permalink)  
Old July 6th, 2004, 05:35 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen N, , Denmark.
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

Your right.. Unfortunately I didn't take a close at his code. I'll look again..

 - mega
  #5 (permalink)  
Old July 6th, 2004, 05:37 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen N, , Denmark.
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

How does your XML page look like, is it satisfying?

 - mega


Similar Threads
Thread Thread Starter Forum Replies Last Post
Returning an image from an ASP page dkb Classic ASP Basics 4 February 21st, 2008 01:20 AM
ServerXMLHTTP.3.0 problem returning XML JasonSigs XML 2 June 1st, 2007 01:18 AM
Returning XML from aspx page to windows app monuindia2002 .NET Web Services 1 February 10th, 2006 07:18 PM
Returning Stored Procedure Results from ASP page JennaAckerson Classic ASP Basics 0 December 23rd, 2005 11:44 AM
getting datas from asp page by xml salimbasar XML 0 December 23rd, 2004 07:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.