HTTP Service give me error.......

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default HTTP Service give me error.......

    Dear Friends,
    I have posted my query on flex builder, but now i think that this is the right
    place to post it....

    I develop a smaple login applicetion in flex 1.5 but it gives me "XML Data
    Malformated" every time....

    can any one help me where i am doing mistake......


    here is the code for mxml file, and the url file code is right next to it


    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
    backgroundColor="#FFFFFF" cornerRadius="10" height="400" width="620"
    horizontalAlign="center" pageTitle="Developed By Kalpesh Patel">
    <mx:HTTPService method="POST" concurrency="last" showBusyCursor="true"
    useProxy="false" id="logData" url="chUser.asp"
    fault="alert(event.fault.faultstring)" result="logData_result(event)"
    resultFormat="text">
    <mx:request>
    <Uid>{Uid.text}</Uid>
    <Upass>{Upass.text}</Upass>
    </mx:request>
    </mx:HTTPService>
    <mx:Panel title="E-Office Management System" width="100%" height="100%"
    dropShadow="true">
    <mx:Canvas width="100%" height="100%">
    <mx:Form label="Login Form" height="175" width="220" x="172" y="59"
    borderStyle="outset" borderColor="#006666" cornerRadius="10" marginTop="5">
    <mx:Label text="SignIn Please" fontWeight="bold" fontSize="12" x="215"
    y="65" height="30"/>
    <mx:FormItem label="Login ID :" required="true" height="35">
    <mx:TextInput id="Uid" maxChars="10" width="100" text="guest"/>
    </mx:FormItem>
    <mx:FormItem label="Password :" height="39" required="true">
    <mx:TextInput id="Upass" maxChars="10" width="100" password="true"
    text="guest"/>
    </mx:FormItem>
    <mx:Button label="Login" width="177" click="processVals(Uid.text,
    Upass.text);"/>
    </mx:Form>
    <mx:Script>
    <![CDATA[
    function processVals(id, ps)
    {
    if(id=="")
    {
    alert("Enter User ID to SignIn... ","SignIn Error",mx.controls.Alert.OK)
    }
    else if(ps=="")
    {
    alert("Enter Password to SignIn... ","SignIn Error",mx.controls.Alert.OK)
    }
    else
    {
    logData.send();
    }
    }

    public function logData_result( result:Object ):Void
    {
    if(result)
    {
    alert(result.valid)
    }
    if(result.valid == true)
    {
    alert("Login Successfull");
    }
    else
    {
    alert("Login Failed");
    }
    }
    ]]>
    </mx:Script>
    </mx:Canvas>
    <mx:ControlBar width="100%" height="40">
    <mx:Label text="Login Module" />
    <mx:Spacer width="100%"/>
    <mx:Button label="Help"/>
    </mx:ControlBar>
    </mx:Panel>
    </mx:Application>


    chUser.asp file code

    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>

    <%
    Response.ContentType = "text/xml";

    var userid = Request.Form("Uid")
    var password = Request.Form("Upass")
    var flag = false;

    if(userid=="guest" && password=="guest")
    {
    flag=true
    }
    %>
    <valid>
    <%
    =String(flag)
    %>
    </valid>

    KapiPatel Guest

  2. Similar Questions and Discussions

    1. HTTP Service not doing what I want.
      I've used HTTP service before, but why isn't it working now? The code I'm testing is the one found in the Flex Samples Explorer. It feels like...
    2. help on HTTP service
      i want create a page which takes the values like "LOGIN ID" and "PASSWORD" to the another JSP page( this pages validates the loginid from my...
    3. why does ¬ give me an error
      i am trying to edit the "list within a list" example but every time i edit any code i get .... script error: operand expected set record...
    4. response.redirect give error http 404
      Hi All, IIS.4 After I installed the latest windows update MS03- 026, MS03-024, MS03-023, Q811114, Q815021, Q816093, 814078, 811493, q329414 and...
    5. HTTP 503 (Service Unavailable) error when calling a webservice inside the network
      Hello This problem has been driving me mad for the past few days. I am basically writing a generic utility in .NET/C# that can read any WSDL...
  3. #2

    Default Re: HTTP Service give me error.......

    KapiPatel wrote:
    > Dear Friends,
    > I have posted my query on flex builder, but now i think that this is the right
    > place to post it....
    >
    > I develop a smaple login applicetion in flex 1.5 but it gives me "XML Data
    > Malformated" every time....
    >
    > can any one help me where i am doing mistake......
    >
    >
    > here is the code for mxml file, and the url file code is right next to it
    >
    >
    > <?xml version="1.0" encoding="utf-8"?>
    > <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
    > backgroundColor="#FFFFFF" cornerRadius="10" height="400" width="620"
    > horizontalAlign="center" pageTitle="Developed By Kalpesh Patel">
    > <mx:HTTPService method="POST" concurrency="last" showBusyCursor="true"
    > useProxy="false" id="logData" url="chUser.asp"
    > fault="alert(event.fault.faultstring)" result="logData_result(event)"
    > resultFormat="text">
    > <mx:request>
    > <Uid>{Uid.text}</Uid>
    > <Upass>{Upass.text}</Upass>
    > </mx:request>
    > </mx:HTTPService>
    > <mx:Panel title="E-Office Management System" width="100%" height="100%"
    > dropShadow="true">
    > <mx:Canvas width="100%" height="100%">
    > <mx:Form label="Login Form" height="175" width="220" x="172" y="59"
    > borderStyle="outset" borderColor="#006666" cornerRadius="10" marginTop="5">
    > <mx:Label text="SignIn Please" fontWeight="bold" fontSize="12" x="215"
    > y="65" height="30"/>
    > <mx:FormItem label="Login ID :" required="true" height="35">
    > <mx:TextInput id="Uid" maxChars="10" width="100" text="guest"/>
    > </mx:FormItem>
    > <mx:FormItem label="Password :" height="39" required="true">
    > <mx:TextInput id="Upass" maxChars="10" width="100" password="true"
    > text="guest"/>
    > </mx:FormItem>
    > <mx:Button label="Login" width="177" click="processVals(Uid.text,
    > Upass.text);"/>
    > </mx:Form>
    > <mx:Script>
    > <![CDATA[
    > function processVals(id, ps)
    > {
    > if(id=="")
    > {
    > alert("Enter User ID to SignIn... ","SignIn Error",mx.controls.Alert.OK)
    > }
    > else if(ps=="")
    > {
    > alert("Enter Password to SignIn... ","SignIn Error",mx.controls.Alert.OK)
    > }
    > else
    > {
    > logData.send();
    > }
    > }
    >
    > public function logData_result( result:Object ):Void
    > {
    > if(result)
    > {
    > alert(result.valid)
    > }
    > if(result.valid == true)
    > {
    > alert("Login Successfull");
    > }
    > else
    > {
    > alert("Login Failed");
    > }
    > }
    > ]]>
    > </mx:Script>
    > </mx:Canvas>
    > <mx:ControlBar width="100%" height="40">
    > <mx:Label text="Login Module" />
    > <mx:Spacer width="100%"/>
    > <mx:Button label="Help"/>
    > </mx:ControlBar>
    > </mx:Panel>
    > </mx:Application>
    >
    >
    > chUser.asp file code
    >
    > <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    >
    > <%
    > Response.ContentType = "text/xml";
    >
    > var userid = Request.Form("Uid")
    > var password = Request.Form("Upass")
    > var flag = false;
    >
    > if(userid=="guest" && password=="guest")
    > {
    > flag=true
    > }
    > %>
    > <valid>
    > <%
    > =String(flag)
    > %>
    > </valid>
    >
    Have you hit the chUser.asp page to see if the XML looks well formed?

    --
    Dave Wolf
    Cynergy Systems, Inc.
    Macromedia Flex Alliance Partner
    [url]http://www.cynergysystems.com[/url]

    Email: [email]dave.wolf@cynergysystems.com[/email]
    Office: 866-CYNERGY
    Dave Wolf Guest

  4. #3

    Default Re: HTTP Service give me error.......

    Repost your sample app using the "Attach Code" function and I will run it to see what is the matter.
    Tracy
    ntsiii Guest

  5. #4

    Default Re: HTTP Service give me error.......

    Hi Tracy,

    Thank you for taking interest in my prob, herewith I am attaching the code for
    MXML file and chUser.asp file

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
    backgroundColor="#FFFFFF" cornerRadius="10" height="400" width="620"
    horizontalAlign="center" pageTitle="Developed By Kalpesh Patel">
    <mx:HTTPService method="POST" concurrency="last" showBusyCursor="true"
    useProxy="false" id="logData" url="chUser.asp"
    fault="alert(event.fault.faultstring)" result="logData_result(event)"
    resultFormat="xml">
    <mx:request>
    <Uid>{Uid.text}</Uid>
    <Upass>{Upass.text}</Upass>
    </mx:request>
    </mx:HTTPService>
    <mx:Panel title="E-Office Management System" width="100%" height="100%"
    dropShadow="true">
    <mx:Canvas width="100%" height="100%">
    <mx:Form label="Login Form" height="175" width="220" x="172" y="59"
    borderStyle="outset" borderColor="#006666" cornerRadius="10" marginTop="5">
    <mx:Label text="SignIn Please" fontWeight="bold" fontSize="12" x="215"
    y="65" height="30"/>
    <mx:FormItem label="Login ID :" required="true" height="35">
    <mx:TextInput id="Uid" maxChars="10" width="100" text="guest"/>
    </mx:FormItem>
    <mx:FormItem label="Password :" height="39" required="true">
    <mx:TextInput id="Upass" maxChars="10" width="100" password="true"
    text="guest"/>
    </mx:FormItem>
    <mx:Button label="Login" width="177" click="processVals(Uid.text,
    Upass.text);"/>
    </mx:Form>
    <mx:Script>
    <![CDATA[
    function processVals(id, ps)
    {
    if(id=="")
    {
    alert("Enter User ID to SignIn... ","SignIn Error",mx.controls.Alert.OK)
    }
    else if(ps=="")
    {
    alert("Enter Password to SignIn... ","SignIn Error",mx.controls.Alert.OK)
    }
    else
    {
    logData.send();
    }
    }

    public function logData_result( result:Object ):Void
    {
    if(result.valid == "true")
    {
    alert("Login Successfull");
    }
    else
    {
    alert("Login Failed");
    }
    }
    ]]>
    </mx:Script>
    </mx:Canvas>
    <mx:ControlBar width="100%" height="40">
    <mx:Label text="Login Module" />
    <mx:Spacer width="100%"/>
    <mx:Button label="Help"/>
    </mx:ControlBar>
    </mx:Panel>
    </mx:Application>


    following is the code for chUser.asp


    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>

    <%
    Response.ContentType = "text/xml";

    var userid = Request.Form("Uid")
    var password = Request.Form("Upass")
    var flag = false;

    if(userid=="guest" && password=="guest")
    {
    flag=true
    }
    %>
    <valid>
    String(flag)
    </valid>

    KapiPatel Guest

  6. #5

    Default Re: HTTP Service give me error.......

    Ok, you had several problems.
    First, use the asp I modified but change the output line to this:
    <valid><%=String(flag)%></valid>

    When the string is output on several lines there will be embedded carriage
    returns and tabs and such that will make the value of the valid node something
    like \r\ntrue\n\r, which will make your conditional not work

    Second, The url in the HTTPService is not correct. the asp file must be served
    from an IIS site, so there is no way the filename will work for a url, you need
    the full url to the asp file:
    url="http://localhost/MyIISApp/chUser.asp"

    Third, there were problems in your result handler. You were passing in the
    event object but treating it like it was the result object. Since you specified
    resultFormat="xml" your result object is an XML document. You were trying to
    access it using dot notation which will not work with an xml node.

    Here is the modified mxml app:


    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
    backgroundColor="#FFFFFF" cornerRadius="10" height="400" width="620"
    horizontalAlign="center" pageTitle="Developed By Kalpesh Patel">
    <mx:HTTPService method="POST" concurrency="last" showBusyCursor="true"
    useProxy="false" id="logData"
    url="http://localhost/TwelveData/chUser.asp"
    fault="alert(event.fault.faultstring)"
    result="logData_result(event)"
    resultFormat="xml">
    <mx:request>
    <Uid>{Uid.text}</Uid>
    <Upass>{Upass.text}</Upass>
    </mx:request>
    </mx:HTTPService>
    <mx:Panel title="E-Office Management System" width="100%" height="100%"
    dropShadow="true">
    <mx:Canvas width="100%" height="100%">
    <mx:Form label="Login Form" height="175" width="220" x="172" y="59"
    borderStyle="outset" borderColor="#006666" cornerRadius="10" marginTop="5">
    <mx:Label text="SignIn Please" fontWeight="bold" fontSize="12" x="215"
    y="65" height="30"/>
    <mx:FormItem label="Login ID :" required="true" height="35">
    <mx:TextInput id="Uid" maxChars="10" width="100" text="guest"/>
    </mx:FormItem>
    <mx:FormItem label="Password :" height="39" required="true">
    <mx:TextInput id="Upass" maxChars="10" width="100" password="true"
    text="guest"/>
    </mx:FormItem>
    <mx:Button label="Login" width="177" click="processVals(Uid.text,
    Upass.text);"/>
    </mx:Form>
    <mx:Script>
    <![CDATA[
    function processVals(id, ps)
    {
    if(id=="")
    {
    alert("Enter User ID to SignIn... ","SignIn Error",mx.controls.Alert.OK)
    }
    else if(ps=="")
    {
    alert("Enter Password to SignIn... ","SignIn Error",mx.controls.Alert.OK)
    }
    else
    {
    logData.send();
    }
    }

    public function logData_result( oEvent:Object ):Void
    {
    var xmlResult:XML = oEvent.result;
    //alert(xmlResult.toString())
    var nodeValid:XMLNode = xmlResult.firstChild;
    //alert(nodeValid.toString())
    var sValid:String = nodeValid.toString();
    if(sValid == "true")
    {
    alert("Login Successfull");
    }
    else
    {
    alert("Login Failed");
    }
    }
    ]]>
    </mx:Script>
    </mx:Canvas>
    <mx:ControlBar width="100%" height="40">
    <mx:Label text="Login Module" />
    <mx:Spacer width="100%"/>
    <mx:Button label="Help"/>
    </mx:ControlBar>
    </mx:Panel>
    </mx:Application>

    ntsiii Guest

  7. #6

    Default Re: HTTP Service give me error.......

    Obviously you need to change the url to match you IIS site.
    ntsiii Guest

  8. #7

    Default Re: HTTP Service give me error.......

    Dear Tracy,
    I am really thankful to you, the code you give me is really works and now i
    know that where i am wrong.....

    i need one more help from you is,

    i logged in sucessfull then i want to how I can show a new form to user?
    should I Hide the login Form and visible a new form or is there any other
    way.... please I am new to this field, so help me..

    Thanking you,

    kalpesh patel

    KapiPatel Guest

  9. #8

    Default Re: HTTP Service give me error.......

    Typically, this is done with a mx:ViewStack. Put the login form at the "0"
    index of the ViewStack, and when the login is successful, set the
    ViewStack.selectedIndex to whatever view you want.

    Tracy

    ntsiii Guest

  10. #9

    Default Re: HTTP Service give me error.......

    Hi Tracy,
    Thank you,
    Now my application is work properly, I post a new Topic under title "Tree and HDividedBox how to handle ?"
    Please if u can help me I will be thankful to you,

    Kalpesh patel
    KapiPatel Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139