Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 01-21-2009, 11:57 AM   #1
sethu
Registered User
 
Join Date: Jan 2009
Posts: 8
Default How to use HTTPService

Hi,

I'm new in Flex Builder.

My Question is How do i use HTTPService in MSXML application.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="userRequest.send()">
<mx:HTTPService id="userRequest" url="http://192.168.0.10/index.asp" useProxy="false" method="POST">

</mx:HTTPService>
<mx:Form x="49" y="74" width="493" height="293">
<mx:FormItem label="Username" id="Username">
<mx:TextInput/>
</mx:FormItem>
<mx:FormItem label="Label">
<mx:Button label="Button" click="userRequest.send()"/>
</mx:FormItem>

</mx:Form>
<mxataGrid id="dgUserRequest" dataProvider="{userRequest.lastResult.users.user" width="268">
<mx:columns>
<mxataGridColumn headerText="User Name" dataField="username"/>

</mx:columns>

</mxataGrid>
</mx:Application>

in my server i have a asp page and build XML Output.

I am not able to run this page when i click Run icon in Flex Builder.

Pls help me out

Sethu
sethu is offline   Reply With Quote
Old 01-21-2009, 12:24 PM   #2
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw
Default

This is because your HTTPService does nothing, you have to define handlers for result and fault events.
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it
wvxvw is offline   Reply With Quote
Old 01-21-2009, 12:30 PM   #3
sethu
Registered User
 
Join Date: Jan 2009
Posts: 8
Default HTTP Service

Hi,

Thanks for your reply.

Actually i got this code from website.

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” xmlns=”*”
layout=”absolute” creationComplete=”userRequest.send()”>

<mx:HTTPService
id=”userRequest”
url=”http://www.myurl.com/flex/request.asp”
useProxy=”false”
method=”POST”>
<mx:request xmlns=”">
<username>{username.text}
</username></mx:request>
</mx:HTTPService>

<mx:Form x=”22″ y=”10″ width=”493″>
<mx:HBox><mx:Label text=”Username”/><mx:TextInput id=”username”/></mx:HBox>
<mx:Button label=”Submit” click=”userRequest.send()”/>
</mx:Form>

<mx ataGrid id=”dgUserRequest” x=”22″ y=”140″
dataProvider=”{userRequest.lastResult.users.user}”
width=”493″ height=”125″>
<mx:columns>
<mx ataGridColumn headerText=”User ID” dataField=”userid”/>
<mx ataGridColumn headerText=”User Name” dataField=”username”/>
<mx ataGridColumn headerText=”E-Mail” dataField=”emailaddress”/>
</mx:columns>
</mx ataGrid>

<mx:TextInput x=”355″ y=”273″ id=”selectedemailaddress”
text=”{dgUserRequest.selectedItem.emailaddress}”/>

</mx:Application>

in my asp page contains

<%



mxmlStr = “<users>”
mxmlStr = mxmlStr & “<user><userid>121</userid><username>Obama</username><emailaddress>[email protected]</emailaddress></user>” & vbcrlf
mxmlStr = mxmlStr & “<user><userid>122</userid><username>Bush</username><emailaddress>[email protected]</emailaddress></user>” & vbcrlf
mxmlStr = mxmlStr & “<user><userid>123</userid><username>Bill</username><emailaddress>[email protected]</emailaddress></user>” & vbcrlf
mxmlStr = mxmlStr & “</users>”

Response.write mxmlStr
%>

asp page resides in another machine. flex running different machine.

help me out
sethu is offline   Reply With Quote
Old 01-21-2009, 01:46 PM   #4
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw
Default

Oh, sorry, I haven't seen this:
Code:
dataProvider="{userRequest.lastResult.users.user"
Firstly, add closing brace, secondly, what is vbcrlf anyway? It doesn't seem to me the ASP code would output a valid XML anyway... what happens when you try to view it in browser?

BTW, wrapping code in the [ code ][ /code ] tags would help a lot.

EDIT: Just tried this (found out that's vbcrlf is a windows style double line break). And it looks OK, meaning, that if there's no mistake in the URL, then this test should work. Few recommendations: convert the output to UTF-8, because this is the format Flash expects the XML to be. And if these [“”] ware the original quotes in your ASP file, - change them to regular quotes [""] instead of "wordpress quotes".
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it

Last edited by wvxvw; 01-21-2009 at 02:02 PM.
wvxvw is offline   Reply With Quote
Old 01-22-2009, 03:33 AM   #5
sethu
Registered User
 
Join Date: Jan 2009
Posts: 8
Default Use HTTPService

MXML Page
========
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="userRequest.send()">
<mx:HTTPService id="userRequest" url="http://192.168.0.10/index.asp" useProxy="false" method="POST">

</mx:HTTPService>
<mx:Form x="49" y="74" width="493" height="293">

<mx:FormItem label="Label">
<mx:Button label="Button" click="userRequest.send()"/>
</mx:FormItem>

</mx:Form>
<mxataGrid id="dgUserRequest" dataProvider="{userRequest.lastResult.users.user}" width="268">
<mx:columns>
<mxataGridColumn headerText="User Name" dataField="username"/>

</mx:columns>

</mxataGrid>
</mx:Application>

================



When i tried to run this page got below error

[RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://192.168.0.10/index.asp"]. URL: http://192.168.0.10/index.asp"]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\ rpc\AbstractInvoker.as:220]
at mx.rpc::Responder/fault()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\ rpc\Responder.as:53]
at mx.rpc::AsyncRequest/fault()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\ rpc\AsyncRequest.as:103]
at DirectHTTPMessageResponder/errorHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\ messaging\channels\DirectHTTPChannel.as:362]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/redirectEvent()


Sethu
sethu is offline   Reply With Quote
Old 01-22-2009, 08:12 AM   #6
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw
Default

IOErrorEvent means that the page isn't there.
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it
wvxvw is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
HTTPService + XML Load + Memory Leak ljonny18 Flex 2, 3 & 4 1 02-26-2010 10:41 AM
HTTPService and PHP tilahc Flex 2, 3 & 4 1 09-07-2008 05:53 AM
fetching SWF files from server using HTTPService and saving the SWF file on local mac ask4avinash ActionScript 3.0 0 04-25-2008 02:18 PM
HTTPService and faultEvent blu3 Flex 2, 3 & 4 2 11-30-2007 06:20 PM
HTTPService error handling question blu3 Flex 2, 3 & 4 2 11-29-2007 10:22 AM


All times are GMT. The time now is 06:49 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.