HTTPService URL

I am working on my first Flex and CF Project. The project
works when I run it locally and on a remote CF server. The problem
I have is with coding.
I currently have variables defined for running locally and
for running on the server. I am using comments to manually change
which variables will be used for local and which ones to use for
deploying to a remote server.
For example,
the server needs a full path (d:\home\name\wwwroot\...)
locally I use (c:\coldfusion8\wwwroot\...).
Local code uses the local CF server
<mx:HTTPService id="getDataFile"
url="
http://localhost:8500/com/xml/movieData.xml"
resultFormat= "object"
result="onResult(event)">
</mx:HTTPService>
remote code uses the full url
<mx:HTTPService id="getDataFile"
url="
http://www.somesite.com/com/xml/movieData.xml"
resultFormat= "object"
result="onResult(event)">
</mx:HTTPService>
I was thinking I should have the code detect if its running
locally or remotely and then select the appropriate variables for
remote or local operation. I would appreciate some feedback on the
best way to make this work.
BTW, I don't like conditional compiles to solve this.
Brad Carvey

Hello,
I am not shure, but I think you have to use a webserver, with
a folder directing to your desktop. Then you can use something like
that:
http://localhost/Desktop.
Otherwise you can try file:///C://Documents and
Settings/[username]/Desktop/flex/...xml
I hope this will help

Similar Messages

  • Dynamic HTTPService URL

    How about when i wanted my HTTPService url to become dynamic
    that it gets from an external text file or xml file. Here is an
    exampl...
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    xmlns:remoting="com.oreilly.
    programmingflex.rpc.*" layout="absolute"
    initialize="initializeHandler(event)">
    <mx:Script>
    <![CDATA[
    private function initializeHandler(event:Event):void {
    textService.send( );
    private function resultHandler(event:Event):void {
    textArea.text = String(textService.lastResult);
    ]]>
    </mx:Script>
    <!--<mx:HTTPService id="feedRequest" url="ip.txt"
    result="resultHandler(event)" useProxy="false"/>-->
    <mx:HTTPService id="textService" url="
    http://yourdomainname.com/ip.xml"
    result="resultHandler(event)" />
    <mx:TextArea id="textArea" width="500"/>
    <mx:VideoDisplay id="vid"
    source="{textService.lastResult.subscribers.thevideo}" width="450"
    height="338" x="20" y="75" />
    </mx:Application>
    As you can see my HTTPService URL points to a file named
    ip.txt, the file includes my database URL where i will get my files
    to be played in my VideoDisplay. Is there anybody who can help me
    with this stuff. any reply would be very much appreciated.
    thanks!!!

    Are you asking if you can make the URL property of the
    HTTPService that points to the textService dynamic?
    You can bind the property to some local variable that is
    dynamically built:
    <mx:HTTPService id="textService" url="{someXMLFilePath}"
    result="resultHandler(event)" />
    The someXMLFilePath variable can be built in the
    initializeHandler ( or where ever you want).

  • Httpservice url property problem

    hello everyone
    I need to include non latin characters in my httpservice url property. It points to a file. (http://www.myurl.com/nonLatinCharactersInFilename.xml)And its giving me errors.
    When I check the error, the url appears like so: http://www.myurl.com/??????????????????.xml
    Im using these character set everywhere in the code and there are no problems except when im sending the httpservice call.
    I also have same characters in the result event. and theres no prpblem with that.
    Any ideas how I can include these file names in the url property? or is there another way?
    In my app the user clicks a list (of file names with non latin characters) and an http service is sent to load the corresponding file to a richEditableText component.
    every thing except the non latin character part works fine
    any help in the right direction will be appreciated.
    thanx

    Hello,
    I am not shure, but I think you have to use a webserver, with
    a folder directing to your desktop. Then you can use something like
    that:
    http://localhost/Desktop.
    Otherwise you can try file:///C://Documents and
    Settings/[username]/Desktop/flex/...xml
    I hope this will help

  • Insert variables from script into HTTPService url

    I'm trying to insert values from script into a HTTPService
    url. How do I go about doing this? I tried the code below, but it
    gives an error. Can anybody help?
    <mx:HTTPService
    id="httpCall"
    url="
    http://api.service.com/user/{userName}/list?count={apiCount}&offset={(apiOffset)}&sort={ap iSort}&appkey=1234"
    resultFormat="e4x"
    result="callHandler(event);"
    fault="httpFaultHandler(event);"
    showBusyCursor="true"
    />
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    [Bindable]
    private var userName:String = "myName";
    private var apiCount:uint = 10;
    private var apiOffset:uint = 0;
    private var apiSort:String = "desc";

    Set the HTTPService properties in an AS function.
    <mx:HTTPService id="httpCall" resultFormat="e4x" ...
    result="callHandler(event);" ...../>
    private function getUserData():void
    var sURL:String = "
    http://api.service.com/user/"
    _ userName + "/list:;
    var oRequest:Object = {count:apiCount,offset:apiOffset,
    sort:apiSort, appkey:"1234" }
    httpCall.url = sURL;
    httpCall.send(oRequest);
    Tracy

  • Using a Variable in HttpService url attribute

    I have a dynamic url defined below
    public var forecastURL:String = "
    http://www.weather.gov/forecasts/xml/SOAP_server/ndfdSOAPclientByDay.php?lat="
    + latitude + "&lon=" + longitude +
    "&format=12+hourly&startDate=" + todaysDate +
    "&numDays=" + numberDays + ""
    I would like to use the var without the {} bind. The compiler
    complains if the url is not surrounded in quotes. This should be
    simple? How can I use a var within the url attribute without the
    bind brackets?
    <mx:HTTPService
    id="forecastRequest"
    url = "{forecastURL}" result="resultHandler(event)"
    />

    Not Possible..why don't you use the subtitle box instead of help url?

  • Best practice to configure HTTPService url

    I try to find the best way to set up the url attribute of a
    large number of httpService in an application that use different
    servlet as data provider.
    My idea is to read an external XML file and use the text of
    nodes to find the settings for the url attribute.
    For example:
    External file config.xml contains a node like this
    <service1>
    http://achille:8080/dbfw/DBSERVICE</service1>
    In my <mx:Application> on creationComplete I read the
    config.xml file and put the content in a Bindable variable that I
    will refer in every component of my application by the syntax
    XML(parentApplication.config).service1 and use the text value of
    the node to set the url attribut of an httpService.
    This is very important because when I install the application
    at a customer the service1 url change and I have to set up the
    application data provider through the external XML file.
    Is there an esier way to do obtain a behavior like that ?
    Thank you at all

    Hi Louis,
    you need to setup a service with clusterware. On both sides: primary and standby.
    On primary you start them. On standby the services are also configured but stopped.
    In case of switchover or failover, data guard will notice clusterware to bring them up.
    You need to use this service name in your clients tnsnames.
    Another issue are TCP timeouts, to protect against them you use
    outbount_connect_timeout in your sqlnet.ora
    Also have a look at
    http://www.oracle.com/technology/deploy/availability/pdf/MAA_WP_10gR2_SwitchoverFailoverBestPractices.pdf
    HTH Mathias

  • HTTPService URL from configuration file?

    Hello,
    I have a need/requirement to use some type of configuration file for my FLEX builds. Right now I manually build my FLEX app.
    It would be nice to configure the URL for all HTTPService objects in an XML file, but I am unsure where that file would reside or what the XML structure should look like.
    I have looked at Flashbuilder4 Bible book but it doesnt cover much.
    Does anybody know of any good examples, tutorials, books, code links, demos, etc that show how to configure data access for a FLEX project?? Preferably in XML?
    I am a little lost in this area and any help or direction is appreciated.
    Thank you!

    What I need is a way to rebuild my application to point to a different server. Easily.
    I have solutioned this using an XML file.
    I ended up doing something similar to this guy:
    http://vatsalad.wordpress.com/2010/08/15/how-to-deploy-your-flex-app-to-different-servers- without-hardcoding-the-url/
    I created a folder, outside of the "src" folder, called "settings". In it, there is an XML file, I named it "webserviceconfig.xml".
    "webserviceconfig.xml" looks like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <webserviceconfig>
    <url>http://subdomain.domain.com:8080/BusinessLayer/MyDataServiceWSDL.asmx/</url>
    </webserviceconfig>
    When my application initializes, it sets a FLEXGlobal variable to store my server URL, like so:
    //set the dynamic server URL address, read  XML settings file for server URL
    FlexGlobals.topLevelApplication.serverURL = webserviceconfig.url;
    <fx:XML id="webserviceconfig" source="settings/webserviceconfig.xml" />
    Now I am able to reference this all over my application:
    myHTTPService.url = FlexGlobals.topLevelApplication.serverURL + "myWebServiceNameHere";
    Now my application server URL is configurable and I no longer need to hardcode that anywhere in my application, except my XML configuration file.
    I am glad to finally get this monkey off my back.
    Thank you for your help and consideration, Caludiu Ursica.

  • Capture full httpservice url?

    is there a simple way to capture the full url (parameters included) when a httpservice is sent?  I'd like to put the url in a variable for later use.

    You could look at the url and body properties on the corresponding HTTPRequestMessage and reconstruct the URL (assuming method="GET"). You can get this message from either the asynchronous completion token returned from calling httpService.send(), or via an InvokeEvent's message property by registering an invoke="invokeHandler(event)" listener on <mx:HTTPService>.
    If you're not using a server side gateway / proxy, the client-side mx.messaging.channels.DirectHTTPChannel is the class that manages the HTTP request. It sets up the query parameters to append to the url in its mx_internal::createURLRequest() method around line 234:
                var urlVariables:URLVariables = new URLVariables();
                var body:Object = httpMsg.body;
                for (var p:String in body)
                    urlVariables[p] = httpMsg.body[p];
                params = urlVariables.toString();

  • Make HTTPService url 'dynamic'?

    What's the best way to pass a parameter to the HTTPService in
    the URL? For example, a SessionID or other standard http/url
    params.
    This would be run-time determined, of course, and couldn't be
    hard-coded in the mxml or action-script (though the root of the URL
    could).
    Thanks in advance,
    AJ

    Yes (I'm going to mark that as the answer).
    The key to me was setting that var as bindable and using the
    HTTPUtil class to retrieve the value from the parameters on the
    html (owner) page's url. Then the creationComplete() function
    actually does some work
    before doing the HTTPService.send().
    Thanks for taking the time to reply. I've posted a few things
    (that I don't see totally out of the ordinary), and it seems to be
    a bit of a "cold" forum at times. :(

  • Insert control text property inside httpservice url

    I am trying to insert a DateField.text property inside of the
    url field for HTTPService in the script portion. I have
    successfully tested with setting the url field with a location and
    calling the .send() for results with a button. How do I base the
    url off of a variable? Here is my code I am using to call the
    HTTPService and this works if I set the full line.
    public function changeDate():void {
    srv.url = "
    http://mydomain.com/temp/2008-03-21.xml";
    srv.send();
    I am trying to pull the text property from a DateField with
    an id of dF. This fails though.What do I need to correct?
    public function changeDate():void {
    srv.url = "'
    http://mydomain.com/temp/' +
    {dF.text} + '.xml'";
    srv.send();

    Ok, thank you for the help. I got it working!
    Here was the final function.
    public function changeDate():void {
    srv.url = "
    http://mydomain.com/temp/" +
    dF.text + ".xml";
    srv.send();
    }

  • HTTPService url property

    Hi,
    I have a folder on the desktop named flex which has an xml
    file .
    I am trying to use HTTPService and wanted to specify the url
    property so that I can access the xml file.
    Could someone plz help me with this.

    Hello,
    I am not shure, but I think you have to use a webserver, with
    a folder directing to your desktop. Then you can use something like
    that:
    http://localhost/Desktop.
    Otherwise you can try file:///C://Documents and
    Settings/[username]/Desktop/flex/...xml
    I hope this will help

  • Dynamic URLs for the mx:HTTPService component

    I am looking to make the url property of an mx:HTTPService
    component dynamic.
    <mx:HTTPService
    id="srvDivision"
    url="
    http://prodserver/prod/get_division.jsp"
    useProxy="false" method="POST">
    </mx:HTTPService>
    I would just like to have an environment property or some
    other way where the value is not compiled into the code but derived
    at runtime. I am sure this quesiton has been asked before but I
    couldn't find a direct answer. I currently use a ResourceBundle
    (and properties file) but this is done at compile time. I would
    like to change the value of the "
    http://prodserver/prod" on the
    fly, depending on what environment I am working in...dev or test or
    whatever. I am not necessarily looking for the fastest way to do
    this, but the right way to do this. Is Data Services the way to
    go?

    How about when i wanted my HTTPService url to become dynamic
    that it gets from an external text file or xml file. Here is an
    exampl...
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    xmlns:remoting="com.oreilly.
    programmingflex.rpc.*" layout="absolute"
    initialize="initializeHandler(event)">
    <mx:Script>
    <![CDATA[
    private function initializeHandler(event:Event):void {
    textService.send( );
    private function resultHandler(event:Event):void {
    textArea.text = String(textService.lastResult);
    ]]>
    </mx:Script>
    <!--<mx:HTTPService id="feedRequest" url="ip.txt"
    result="resultHandler(event)" useProxy="false"/>-->
    <mx:HTTPService id="textService" url="
    http://123.136.72.41/mashupdemo/ip.xml"
    result="resultHandler(event)" />
    <mx:TextArea id="textArea" width="500"/>
    <mx:VideoDisplay id="vid"
    source="{textService.lastResult.subscribers.thevideo}" width="450"
    height="338" x="20" y="75" />
    </mx:Application>
    As you can see my HTTPService URL points to a file named
    ip.txt, the file includes my database URL where i will get my files
    to be played in my VideoDisplay. Is there anybody who can help me
    with this stuff. any reply would be very much appreciated.
    thanks!!!

  • How to add arraycollection to the httpservice's url property??

    hi all..,
    i want to add arraycollection data to the httpservice url
    property...
    how can i add it
    can anybody explain with bit syntax??????//
    thank u...
    vijay kotha

    Try this URL :
    http://www2.gol.com/users/tame/swing/examples/JTableExamples2.html
    and look the two last examples, I think it would solve your problem and it's a very good work.

  • HttpService : Erreur de flux. URL

    Hello all,
    I have servlet named "registrationSubmitFlex" that i call
    with my file "register.mxml" when i validate my form(in
    register.mxml) i get this error.
    Sorry for my bad english.
    [RPC Fault faultString="HTTP request error"
    faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent
    type="ioError" bubbles=false cancelable=false eventPhase=2
    text="Error #2032: Erreur de flux. URL:
    http://localhost:8083/registrationSubmitFlex.do?email=d&lastName=d&phone=d&firstName=d"
    URL: /registrationSubmitFlex.do"]
    at mx.rpc::AbstractInvoker/
    http://www.adobe.com/2006/flex/mx/internal::faultHandler()
    at mx.rpc::Responder/fault()
    at mx.rpc::AsyncRequest/fault()
    at ::DirectHTTPMessageResponder/errorHandler()
    at
    flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at
    flash.net::URLLoader/flash.net:URLLoader::redirectEvent()

    What happens if you call the HTTPService url directly from a
    browser? (not from Flex)
    Tracy

  • Using HTTPService to import data from a XML file

    Hello there!
    I'm having some problem's with this import... If anyone can
    help, I would appreciate it!
    I'm using this type of information as data source:
    public var dataCollection:ArrayCollection =
    new ArrayCollection([
    { id: "P1", name: "Porto", type: "team", children: [
    { id: "R1", name: "Dr Silva", location: "Bloco 1", type:
    "member" },
    { id: "R2", name: "Dra Neto", location: "Gabinete", type:
    "member"
    { id: "P2", name: "Braga", type: "team", children: [
    { id: "R3", name: "Dr Santos", location: "Bloco 2", type:
    "member" },
    { id: "R4", name: "Dra Sonia", location: "Piso 1", type:
    "member"
    But I want to import it from a XML file like this:
    <?xml version="1.0" encoding="utf-8"?>
    <items>
    <item id="P1" name="Porto" type="team">
    <children id="R1" name="Dr Silva" location="Bloco 1"
    type="member" />
    <children id="R2" name="Dra Neto" location="Gabinete"
    type="member" />
    </item>
    <item id="P2" name="Braga" type="team">
    <children id="R3" name="Dr Santos" location="Bloco 2"
    type="member" />
    <children id="R4" name="Dra Sonia" location="Piso 1"
    type="member" />
    </item>
    </items>
    I already import the file, but can not translate the data
    into a array collection.
    private function initApp():void {
    var httpService:HTTPService = new HTTPService();
    httpService.url = "dataprovider.xml";
    httpService.resultFormat = "e4x";
    httpService.addEventListener(FaultEvent.FAULT,
    onFaultHttpService);
    httpService.addEventListener(ResultEvent.RESULT,
    onResultHttpService);
    httpService.send();
    private function onFaultHttpService(e:FaultEvent):void
    Alert.show("Error reading data file.");
    private function onResultHttpService(e:ResultEvent):void
    //Convert the xml data to a array collection
    Thank you

    Hello Peter, and thank you for your reply's.
    My problem is that I'm receiving the data from the external
    file and I don't know how to get the children in place... I mean, I
    also have some data being received form a file that I can convert
    into an array collection, but the thing is, that file doesn't have
    children structure...
    It's something like this:
    <?xml version="1.0" encoding="utf-8"?>
    <items>
    <item id="T1" resourceId="R1" name="Cardiologia"
    startTime="25-3-09 8:0:0" endTime="25-3-09 8:30:0" />
    <item id="T2" resourceId="R2" name="Raio-X"
    startTime="25-3-09 9:0:0" endTime="25-3-09 9:15:0" />
    <item id="T3" resourceId="R3" name="Analises"
    startTime="25-3-09 12:0:0" endTime="25-3-09 12:45:0" />
    <item id="T4" resourceId="R4" name="Consulta"
    startTime="26-3-09 8:0:0" endTime="26-3-09 9:0:0" />
    </items>
    And I solve it with this (don't know if is the best):
    private function onResultHttpServiceTask(e:ResultEvent):void
    var a:Array = xmlListToObjectArray(e.result.item);
    tasks = new ArrayCollection(a);
    protected function
    xmlListToObjectArray(xmlList:XMLList):Array
    var a:Array = new Array();
    for each(var xml:XML in xmlList)
    var attributes:XMLList = xml.attributes();
    var o:Object = new Object();
    for each (var attribute:XML in attributes)
    var nodeName:String = attribute.name().toString();
    var value:*;
    value = attribute.toString();
    o[nodeName] = value;
    a.push(new ObjectProxy(o));
    return a;
    But when the children "enter in action" I don't know how to
    bring them to the array...
    This code you send it's preaty much the thing I need, but the
    thing is that I don't know how to call the children with data as
    e:ResultEvent...
    If you can help a bit more, I would really appreciate...
    Thank You

Maybe you are looking for