Ask a Question related to Macromedia Flex General Discussion, Design and Development.
-
KapiPatel #1
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
-
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... -
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... -
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... -
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... -
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... -
Dave Wolf #2
Re: HTTP Service give me error.......
KapiPatel wrote:
Have you hit the chUser.asp page to see if the XML looks well formed?> 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>
>
--
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
-
ntsiii #3
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
-
KapiPatel #4
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
-
ntsiii #5
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
-
ntsiii #6
Re: HTTP Service give me error.......
Obviously you need to change the url to match you IIS site.
ntsiii Guest
-
KapiPatel #7
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
-
ntsiii #8
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
-
KapiPatel #9
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



Reply With Quote

