Sending SOAPRequest in HttpService

Hi,
I am trying to call a HttpService in ActionScript. Here is my
code snippet,
var parameters:Object = {};
parameters["SOAPRequest"]="<![CDATA[<SOAPRequest><Execute
xmlns='urn:schemas-microsoft-com:xml-analysis'><Command><Statement>WITH
MEMBER Measures.SPEED_RANGE1 AS
'AGGREGATE({[DRIVING_SPEED].[102]:[DRIVING_SPEED].[124]})' MEMBER
Measures.SPEED_RANGE2 AS
'AGGREGATE({[DRIVING_SPEED].[125]:[DRIVING_SPEED].[135]})' MEMBER
Measures.SPEED_RANGE3 AS
'AGGREGATE({[DRIVING_SPEED].[136]:[DRIVING_SPEED].[212]})' select
{Measures.SPEED_RANGE1,Measures.SPEED_RANGE2,Measures.SPEED_RANGE3}
ON COLUMNS,
{[TIME].[2008].[9].[1],[TIME].[2008].[9].[2],[TIME].[2008].[9].[3],[TIME].[2008].[9].[4], [TIME].[2008].[9].[5]}
on ROWS FROM SPEED WHERE
[CLIENTS].[ExpTestJay]</Statement></Command></Execute>]</SOAPRequest>]>";
service = new HTTPService();
service.url = "10.40.13.154";
service.method = "POST";
service.addEventListener(ResultEvent.RESULT, httpResult);
service.addEventListener(FaultEvent.FAULT, httpFault);
service.send(parameters);
I am getting this error,
HTTP request error->Error: [IOErrorEvent type="ioError"
bubbles=false cancelable=false eventPhase=2 text="Error #2032"].
URL: 10.40.13.154
I was able to successfully do it through the
<mx:HttpService>
<mx:HTTPService id="httpService" url="
http://10.40.13.154:8080/mondrian/xmla.jsp"
method="POST" result="displayData(event)"
resultFormat="e4x">
<mx:request>
<SOAPRequest>
{query}
</SOAPRequest>
</mx:request>
</mx:HTTPService>
I am just wondering what am I missing when I call the
HttpService through the action script ?
Any sample of how to send a SOAPRequest in a HttpService call
using ActionScript will be appreciated.

I figured out the issue of why the service is not called.
Basically the url needs to be the address of the jsp that process
the request wherein in the above snippet it was just the URL
Now I am getting a different error stating that the
SOAPRequest request parameter value is invalid.
Basically the value is taken as a String object address like
below,
[STDOUT] Parameter =SOAPRequest Value =
[Ljava.lang.String;@7d6a33
how can I pass the SOAPRequest correctly?

Similar Messages

  • If I send ArrayCollection using HTTPService to PHP

    Is it viewed in the PHP script as an array or what???
    I am using an ArrayCollection as dataProvider for DataGrid
    and need to send back to my PHP script after mods.

    Did you find out how to do this?

  • Better to call HTTPService send() in creationComplete or initialize event handler???

    I'm wondering if, in general, it is better to call the send()
    method for HTTPService in the creationComplete event handler, or if
    there is any advantage to calling send() in the initialize event
    handler.

    "Greg Lafrance" <[email protected]> wrote in
    message
    news:gm80e7$n6c$[email protected]..
    > I'm wondering if, in general, it is better to call the
    send() method for
    > HTTPService in the creationComplete event handler, or if
    there is any
    > advantage
    > to calling send() in the initialize event handler.
    I think that depends on how much stuff your program has to
    build, and
    whether you're doing anything in the result handler that
    might depend on
    having things ready (and if your HTTPService is set up in
    MXML, it's
    probably not ready for you to be able to send anyway).

  • Creating tree from HTTPService

    Hi, I'm new under flex builder and I have a simple (?)
    problem :
    I would like to generate a tree from a XML file generate by
    PHP. I can display items (source) in tree but not subitems
    (playlist)...
    Here my XML file generated by PHP :
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <sourcelist>
    <source id="3" nom="WarholinDaMix">
    <playlist id="0" nom="Tous les
    fichiers"></playlist>
    </source>
    <source id="2" nom="YoyesGirl">
    <playlist id="0" nom="Tous les
    fichiers"></playlist>
    <playlist id="2" nom="Yo la liste
    Girly"></playlist>
    </source>
    <source id="1" nom="Yoyesman">
    <playlist id="0" nom="Tous les
    fichiers"></playlist>
    <playlist id="1" nom="Yo ma liste 1"></playlist>
    <playlist id="3" nom="Yo ma liste 2"></playlist>
    </source>
    </sourcelist>
    Here the code I use :
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" creationComplete="GetSource.send(null);">
    <mx:HTTPService id="GetSource" url="
    http://127.0.0.1/SchmittTunes/bin/music.php?gettype=source"
    useProxy="false"/>
    <mx:Panel layout="absolute" left="10" right="10">
    <mx:Tree labelField="nom"
    dataProvider="{GetSource.lastResult.sourcelist.source}"
    width="100%" x="0" height="100%" y="0"
    showRoot="false"></mx:Tree>
    </mx:Panel>
    </mx:Application>
    How I said, I have 3 items displaying the 'source' on my
    tree, but I can't expand them. There is no arrow on the left side.
    So subitems like 'playlist' are not display.
    Does anyone know why or have an idea ?
    Thanks for your help
    Mika

    Thanks ! it's working with resultFormat="e4x" tag in my
    HTTPService, but with some adaptations :
    I change the following :
    <mx:Tree labelField="nom"
    dataProvider="{GetSource.lastResult.sourcelist.source}"
    width="100%" x="0" height="100%" y="0"
    showRoot="false"></mx:Tree>
    By :
    <mx:Tree labelField="@nom"
    dataProvider="{GetSource.lastResult}" width="100%" x="0"
    height="100%" y="0" showRoot="false"></mx:Tree>
    Changes are about labelfield and dataprovider.
    Thanks for your help !

  • URL Loader / HTTPService using ASPX calls

    I would like to know if someone could help me or point me in the right direction … here is a test site and source view (https://studentdb.projectcadd.org/test.html) of what I am trying to do (all I want is a guarantee that the XML generated from ASPX will go to the correct dropdown 100% of the time.
    As you will see on this test site, the ASPX will go to whatever dropdown it wants, but those read from stactic XML files read correctly into the proper dropdown.
    The first set of 3 are read from SQL thru ASPX files using URLLoader, and the next 3 are read from static XML files, using URLLoader, the final 3 are using HTTPService  calls … the single dropdown above the final 3 is reading an XML file also. The URLLoaders reading XML are 100%, the others may come up correctly the 1st time, but if I refresh or recall the page the setup is not correct!! I am using a random number in the querystring but that doesn’t work either – handle any cashe problems!!! (all sets should have the same pattern in them – 1st classnumber, then course numbers, then paygrades).
    thanks, rehoover

    hi,
       you need to explicitly call MyHTTPService.send() from actionScript httpService dosent sends Data automatically and also at dataProvider="{ChatXML.root.object}" you will need to ommit parentNode in XMl ->dataProvider="{ChatXML.object}"

  • Specify 'GET' parameters in HTTPService in ActionScript?

    Hi,
    I was wondering if there is a way to specify variables and values in Actionscript to send in an HTTPService.  Say I wanted to send a request like:
    http://mydomain.com/?user=test
    In AS3, I have this:
    private function init():void {
      service = new HTTPService();
      service.destination = "http://mydomain.com";
      service.method = "GET";
      service.addEventListener("result", httpResult);
      service.addEventListener("fault", httpFault);
    Is there a way to use a function to specify GET variables (user=test)?  Because otherwise it become more cumbersome to keep changing the destination screen and worry about escaping variables, etc, etc.

    Yes, I see that.  I just wasn't sure how to specify the parameters.  I am trying this:
    var params:Object = new Object();
    params.user = "test";
    service.send(params);
    That seems to have done it (actually, I realized I need to set the 'url' property, not the 'destination' property as well)
    So I can just call this 'send' with different parameters on the same object over and over right?  Do people generally put logic in the eventlistener to differentiate the type of responses that come back, or is it more common to add different event listeners for each type of request?  In case it's not obvious, I'm making a RESTful php server that can respond to various methods in the request, modeled after the flikr API.

  • HTTPService Limitation Help

    I'm writing a complex application in which users will be
    submitting a large amount of information through a http request
    back to a coldfusion application of mine.
    Is there an alternative method to putting the information in
    the url and sending it using HTTPService, without leaving the
    environment i've created (for example, can i do an asynch post?) Or
    do i need to continue putting the content of my text inputs into
    urls and grabbing them at the coldfusion level?
    If I do have to continue using the url vars, is there any
    limitation in url length?
    I know ie6 can only handle 2083 chars, but does that include
    asynch server requests?
    I know apache server only handles 4000char lengths, 8000 for
    iis (i think)...

    private function sendFormdata():void {
    var myobj:Object = new Object();
    myobj.username = username.text;
    myobj.emailaddress = emailaddress.text;
    userRequest.send(myobj);

  • HTTPService request problem

    Hi,
    I've faced a problem with HTTPService. I want to send a
    parameter with a <request> markup to the jsp page and get
    data based on this parameter. The service populate an
    ArrayCollection.
    I've used a button to execute the httpserv.send() method but
    it doesn't work as I want it to.
    The problem is, proper data appears after the second click on
    the button. After the first click, ArrayCollection doesn't
    populate, after second it populates right. The same thing happens
    with changing parameter - after change and click, array is still
    populated with the data representing previous prameter. After
    second click, everything show as it should. Another parameter
    change works the same.
    Any ideas how to get data AFTER sending request? HttpService
    code below.
    Thanks in advance.
    Best regards,
    Wojtek
    <mx:HTTPService
    id="getPermissions"
    url="
    http://.../getPermissions.jsp"
    method="POST"
    useProxy="false"
    result="permissionsArray=ArrayCollection(getPermissions.lastResult.permissions.permission );"
    fault="handleFault(event)"
    >
    <mx:request xmlns="">
    <contr_nr>{dataGrid1.selectedItem.contr_nr}</contr_nr>
    </mx:request>
    </mx:HTTPService>

    The problem has been solved. I figured out that it had
    nothing to do with HTTPService, the service was ok (as it looks :).
    The problem was with data binding. Thanks anyway.

  • Timestamp server authentication issues

    I'm using Adobe Reader XI and when using http timeStamp server that requires basic authentication is always tried without the needed BasicAuth field set.
    That's the request adobe send
    POST /cdie/HttpService HTTP/1.1
    accept: */*
    content-type: application/timestamp-query
    content-length: 69
    character-encoding: binary
    user-agent: PPKHandler
    connection: Keep-Alive
    cache-control: no-cache
    The reply is a simply HTTP/1.1 401 Unauthorized because the request hasn't the authentication field.
    I've tried using Windows and Macintosh
    Why didn't send the basic authentication?

    What exactly are you trying to do? Are you signing a PDF with a certificate-based digital signature? You cannot sign in Adobe Reader unless your PDF is Reader-extended with permissions to sign.
    If your PDF is Reader-extended or you're signing with Acrobat Pro, and you want your signature to be timestamped you need to set up the timestamp server in Acrobat/Reader. If your timestamp server requires authentication, you need to provide authentication information in the Acrobat's timestamp server setup. Some signing credentials (Digital IDs) have timestamp server information embedded in the certificate. In this case Acrobat will use this timestamp server to timestamp the signature and you do not need to set up this timestamp in Acrobat's timestamp servers list unless this timestamp server requires authentication. If it requires authentication, you need to set it up in Acrobat/Reader providing authentication info.
    You should never access timestamp server if you just open a signed PDF.

  • Image Coming from URLRequest Not Displaying?

    Hi,
      I have a main app here with a subclass that is supposed to "send images" based on the "parameters" that sends to a HTTPService.
      However, even though the url seems to be generating correctly, I could not see the image. Since my PHP is working fine with the url as shown in the trace statements from my app, I am assuming that there has to be something else that I am missing here.
      Below is the code that generates the image, is there something here I am missing?
    package map
         import colorize.*;    
         import com.zavoo.svg.*;    
         import flash.display.Sprite;
         import flash.events.Event;
         import flash.net.URLLoader;
         import flash.net.URLRequest;
         import flash.net.URLVariables;    
         import mx.containers.Canvas;
         import mx.core.UIComponent;
        public class SvgMap extends UIComponent {
            public var canvas:Sprite;
            [Embed(source="USA_Counties_with_FIPS_and_names.svg")]
            public var usaMap:Class;
            public var paths:SvgPaths;                 
            private var patient_from:Array;   
            private var drive_time:Array;
            private var drive_distance:Array;
            private var college:Array;
            private var high_school:Array;
            private var income:Array;
            private var population:Array; 
            private var countyName:XMLList;
            private var stateColors:Array;
            private var horizontal_bar:Canvas;
        public function SvgMap():void {
                    canvas = new usaMap();
                    canvas.width = 650;
                    canvas.height = 500;
                    addChild(canvas);
                    trace("Canvas Parent: " + canvas.parent);                            
        public function passBox(passedBox:Canvas):void{
            horizontal_bar = passedBox;       
         public function setParameters(passedArray:Array,passedArray7:Array):void {
                from = passedArray;          
                stateColors= passedArray7;   
                changeMap(from,stateColors);           
            public function changeMap(passedArray:Array,passedArray7:Array):void{   
            removeChild(this.canvas);              
            canvas = new Sprite();
            canvas.width = 600;
            canvas.height = 500;
            addChild(canvas);     
            var from_string:String = from.join("-");
            var state_colors_string:String = stateColors.join("-");       
            var loader:URLLoader = new URLLoader();          
            var url:String = "http://tdc-queuing/test/generic.php?from=" + from_string + "&state_colors=" + state_colors_string;
            var variables:URLVariables = new URLVariables();
            variables.patient_from= patient_from_string;
            variables.state_colors = state_colors_string;
            var encode:String= encodeURI(url);   
            var pattern:RegExp = /#/g;
            var decode:String = encode.replace(pattern,"%23");   
            var request:URLRequest = new URLRequest(decode);       
            request.method = "GET";       
            loader.load(request);       
            loader.addEventListener(Event.COMPLETE, onLoadComplete);
            public function onLoadComplete(event:Event):void {
                    var loader:URLLoader = URLLoader(event.target);              
                    paths = new SvgPaths(loader.data);      //the canvas exists
                    paths.drawToGraphics(this.canvas.graphics, 2, 10, 10);
    Thanks for your help. Anything is appreciated.
    Alice

    Hi,
    For testing purposes, here is the package:
    package map
         import colorize.*;   
         import com.zavoo.svg.*;   
         import flash.display.Sprite;
         import flash.events.Event;
         import flash.net.URLLoader;
         import flash.net.URLRequest;
         import flash.net.URLVariables;   
         import mx.containers.Canvas;
         import mx.core.UIComponent;
        public class SvgMap extends UIComponent {
            public var canvas:Sprite;
            [Embed(source="USA_Counties_with_FIPS_and_names.svg")]
            public var usaMap:Class;
            public var paths:SvgPaths;                
            private var from:Array;  
            private var stateColors:Array;
            private var horizontal_bar:Canvas;
        public function SvgMap():void {
                    canvas = new usaMap();
                    canvas.width = 650;
                    canvas.height = 500;
                    addChild(canvas);
                    trace("Canvas Parent: " + canvas.parent);                           
        public function passBox(passedBox:Canvas):void{
            horizontal_bar = passedBox;      
         public function setParameters(passedArray:Array,passedArray7:Array):void {
                from = passedArray;         
                stateColors= passedArray7;  
                changeMap(from,stateColors);          
            public function changeMap(passedArray:Array,passedArray7:Array):void{  
            removeChild(this.canvas);             
            canvas = new Sprite();
            canvas.width = 600;
            canvas.height = 500;
            addChild(canvas);    
            var from_string:String = from.join("-");
            var state_colors_string:String = stateColors.join("-");      
            var loader:URLLoader = new URLLoader();         
            var url:String = "http://localhost/test/generic.php?from=" + from_string + "&state_colors=" + state_colors_string;
            var variables:URLVariables = new URLVariables();
            variables.from= from_string;
            variables.state_colors = state_colors_string;
            var encode:String= encodeURI(url);  
            var pattern:RegExp = /#/g;
            var decode:String = encode.replace(pattern,"%23");  
            var request:URLRequest = new URLRequest(decode);      
            request.method = "GET";      
            loader.load(request);      
            loader.addEventListener(Event.COMPLETE, onLoadComplete);
            public function onLoadComplete(event:Event):void {
                    var loader:URLLoader = URLLoader(event.target);             
                    paths = new SvgPaths(loader.data);      //the canvas exists
                    paths.drawToGraphics(this.canvas.graphics, 2, 10, 10);
    And, this is the PHP:
    <?php
    header("Content-type: image/svg+xml"); //Outputting an SVG
    $from = $_GET['from'];
    $state_colors= $_GET['state_colors'];
    $from = explode("-", $from);
    $state_colors= explode("-", $state_colors);
    #Load the Map
    $ourFileName= "USA_Counties_with_FIPS_and_names.svg";
    $fh = fopen($ourFileName, "r") or die("Can't open file");
    $contents = fread($fh,filesize($ourFileName));
    $lines2= file($ourFileName);
    foreach ($lines2 as $line_num => $line2) {
    $style_line_num = $line_num+3;
    $line2 = trim($line2);
          if(preg_match("/^style/",$line2)) {
           $rest = substr($line2,0,-1);        
           for ($j=$line_num;$j<=$style_line_num;$j++){
             if(preg_match("/inkscape:label/",$lines2[$j])) { 
                $location = explode("=",$lines2[$j]);
                $location2 = substr($location[1],1,-6); 
                if(in_array($location2, $from)) {
                 $key= array_search($location2,$from); //Find out the position of the index in the array
                 $colors_style = ";fill:" . $state_colors[$key];  //Use the index from array_search to apply to the color index
                 $rest2 = substr($line2,0,-1). $colors_style . "\"";           
                 echo $rest2 . "\n";
                else echo $line2 . "\n";           
             } //end preg_match inkscape       
         } //end for loop
       }  //If preg_match style
         else echo $line2 . "\n"; //else if preg_match style    
    } //end for each  
    fclose($fh);
    ?>
    Thanks for your help.

  • Flex 2 email!

    Hello all,
    I've searched for how to do this on the forums already, but
    nothing was especially helpful. I'm trying to build an application
    that consists of multiple forms and a two trees. Also, there is a
    button labeled "send email".
    How can it be set up so that once the button is clicked, the
    user-inputted data in the forms(one of the forms asking for the
    user's e-mail address) AND the currently selected items in both
    trees are sent to both: 1. the user's inputted email & 2. a
    specified e-mail address of the application builder's choosing?
    Can this be done? Would it use PHP? or perhaps CGI/Perl? I
    do not have ColdFusion as an option.
    Any help on this problem would be greatly appreciated. I'm
    sure the community would love to hear a solution as well.

    If you can use PHP, then it is fairly simple to do:
    <?php
    //send_email.php
    $recipient1 = $_POST['recipient1'];
    $subject = $_POST['subject'];
    $message = $_POST['message'];
    $headers = 'From:'. $_POST['sender']. "\r\n" .
    'Reply-To: '.$_POST['reply'] . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
    $recipient2 = $_POST['recipient2'];
    mail($recipient1, $subject, $message, $headers);
    mail($recipient2, $subject, $message, $headers);
    ?>
    Then in your Flex app, send the form data using a HTTPService
    call.
    private function send_email():void {
    var params:Object = new Object();
    params.recipient1 = recipient1.text;
    params.recipient2 = recipient2.text;
    params.message = message.text;
    email_http.send(params);
    <mx:HTTPService
    id="email_http"
    method="POST"
    url="
    http://www.yourserver.com/send_email.php"
    useProxy="false"/>
    I think this will work for you, but post back if you need
    something different.
    Vygo

  • Datagridcolumn visible=false acting weird

    Hi everybody!
    I have problems with a few columns that shows up again when I
    do send to the httpService that is the dataProvider to the
    datagrid. The stay hidden if I use a repeater, but not when I use
    the httpService. I downloaded the hotfix hoping for a solution, but
    that didn't not solve it.
    Is there a work around, or do I have to wait for next
    hotfix?

    I have experienced several issues with this issue. Although
    the latest version addressed most of them, there seems to be
    certain instances where it still happens.
    Try this.
    Create a function like.
    public function setHiddenColumns():void {
    LastActivityDate.visible = false;
    OwnerName.visible = false;
    Then call the function on CreationComplete and after your
    remote object result.
    Also, I have noticed some different results with how your
    DataGrid columns are ordered in your code. Try putting a field that
    is always visible as the last column. So, make sure you don't have
    a hidden column as your last column. It fixed my issue.

  • How to send JSON data in HTTPService to PHP web service question

    I'm using Flex 4 and a mx:HTTPService to send a JSON request to a php web service. I'm not sure if I'm sending the request correctly. Could someone look at the code below to see what I'm doing wrong?
    thanks
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   width="100%" height="100%">
        <fx:Declarations>
            <mx:HTTPService id="service" url="https://my web service url/"
                            method="POST" resultFormat="text" result="onResult(event)" fault="onFault(event)">
            </mx:HTTPService>
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import com.adobe.serialization.json.JSON;
                import mx.collections.ArrayCollection;
                import mx.rpc.events.FaultEvent;
                import mx.rpc.events.ResultEvent;
                import mx.utils.Base64Encoder;
                [Bindable]private var username:String = "[email protected]";
                [Bindable]private var password:String = "the password";
                [Bindable]private var accountNumber:String = "49055";
                [Bindable]private var anticipatedDeliveryDate:Number = 20101115;
                [Bindable]private var purchaseOrder:String = "#123 for retailer";
                [Bindable]private var detailRecords:Array = new Array();
                [Bindable]private var key:String = "abc123";
                private function populateService():void {
                    populateProducts();   
                    setRequestHeader();
                    setRequestData();
                    service.send();   
                private function setRequestHeader():void {
                    var encoder:Base64Encoder = new Base64Encoder();
                    encoder.insertNewLines = false;
                    encoder.encode(key);               
                    service.headers["Authorization"] = "VIP " + key;
                    service.headers["Content-Type"] = "application/json";
                private function setRequestData():void {
                    service.request.username = username;
                    service.request.password = password;
                    service.request.accountNumber = accountNumber;
                    service.request.anticipatedDeliveryDate = anticipatedDeliveryDate;
                    service.request.purchaseOrder = purchaseOrder;
                    service.request.detailRecords = detailRecords;
                    // caching test
                    var rnd : Number = Math.round(Math.random()*1000);
                    service.request.cacheOff = rnd;
                private function populateProducts():void {
                    var prod1:Object = new Object();
                    prod1.itemCodeOrUPC = "00241";
                    prod1.itemDescription = "Budweiser Keg 1/2 BBL";
                    prod1.quantityOrdered = 2;
                    prod1.orderUOM = "Keg";
                    var prod2:Object = new Object();
                    prod2.itemCodeOrUPC = "00219";
                    prod2.itemDescription = "Budweiser 24/12 OZ CAN";
                    prod2.quantityOrdered = 4;
                    prod2.orderUOM = "Case";
                    detailRecords.push(prod1);
                    detailRecords.push(prod2);
                private function onResult(event:ResultEvent):void
                    var json:Object = JSON.decode(event.result as String);
                private function onFault(event:FaultEvent):void
                    trace("Fault: " + event.fault.faultString);
            ]]>
        </fx:Script>
        <mx:Panel width="95%" height="100%" color="#000000">
            <mx:HBox width="100%">
                <mx:Button label="Submit" click="{populateService()}"/>
            </mx:HBox>   
        </mx:Panel>
    </s:Application>

    Have you think abut using ActionScript in your Flex application? Or, you can write javascript to be proxy between your flash app and backend PHP web service?
    Also, it seems that you will allow every customer's flash player to have a copy of secret code. I think it is dangerous design because an flv file can be easity decompiled. Therefore, you secret code can be found if it is not input by your end user and it is populated on your serverside script.

  • Multipart/form-data using HTTPService, sending a binary file and some text in the same request.

    Hi There,
             I am new to FLEX and also new to writing a client for a web service.
    My question is more about flex (Flash builder 4.5) APIs, what APIs to use.
    I want to access a web service, that's published here.
    https://build.phonegap.com/docs/write_api
    here is the description of webservice
    ===========
    1) I have to do a post on POST https://build.phonegap.com/api/v1/apps
    2) content type has to be "multipart/form-data"
    3) JSON bodies of requests are expected to have the name 'data'
      data will be someting like this
    'data={"title":"API V1 App","package":"com.alunny.apiv1","version":"0.1.0","create_method":"file"}'
    4) include a zip file in the multipart body of your post, with the parameter name 'file'.
    ===========
    I want to make a 'multipart/form-data' Post and send
    one string and one zip file.
    My first question to self was If i send both string + binary data in the body ...
    how will server understand where string end and where zip file starts?
    Then read on W3.org( http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2 )
    How is text + binary data can be sent through "multipart/form-data" post requst.
    there has to be some boundries.
    After this I read and example in flex and  tried following it.
    http://codeio.wordpress.com/2010/04/03/5-minutes-on-adobe-flex-mimic-file-upload-for-in-me mory-contents/
    but it doesn't seems to be working for me.
                        public function createNewApp(cb:Function , appFile : File):void
                                  var service:HTTPService = new HTTPService();
                                  service.url = ROOT+"apps";
                                  service.showBusyCursor = true;
                                  service.addEventListener(ResultEvent.RESULT, function(e:ResultEvent):void {
                                            //translate JSON
                                            trace(e.result);
                                            var result:String = e.result.toString();
                                            var data:Object = JSON.parse(result);
                                            cb(data.link);
                                  service.addEventListener(FaultEvent.FAULT, defaultFaultHandler); //todo : allow user to add his own as well
                                  authAndUploadNewApp(service,appFile);
                        private function authAndUploadNewApp(service:HTTPService,appFile : File):void {
                                  var encoder:Base64Encoder = new Base64Encoder();
                                  encoder.encode(username + ":"+password);
                                  service.headers = {Accept:"application/json", Authorization:"Basic " + encoder.toString()};
                                  service.method ="POST";
                                  var boundary:String = UIDUtil.createUID();
                                  service.contentType = "multipart/form-data; boundary=—————————" + boundary;
                                  var stream:FileStream = new FileStream();
                                  stream.open(appFile, FileMode.READ);
                                  var binaryData:ByteArray = new ByteArray();
                                  var fileData : String = new String();
                                  stream.readBytes(binaryData);
                                  stream.close();
                                  fileData = binaryData.readUTFBytes(binaryData.bytesAvailable); // I think this is where I have problem.... how do
                           //how do i converrt this bytearray/stream of data to string and send it in my post request's body - i guess if this step work rest should work..  
                                  var params: String = new String();
                                  var content:String = "—————————" + boundary + "nr";
                                  content += 'Content-Disposition: form-data; name="data";' + '{"title":"ELS test app 2","package":"com.elsapp.captivate","version":"12.3.09","create_method":"file"}' + "nr";
                                  content += "—————————" + boundary + "nr";
                                  content += 'Content-Disposition: form-data; name="file";' + fileData  + "nr";
                                  content += "—————————–" + boundary + "–nr";
                                  service.request = content;
                                  service.send();

    In the past I have used URLVariables with URLRequest and URLLoader to achieve this kind of requirement.
    Check out http://livedocs.adobe.com/flex/3/html/help.html?content=17_Networking_and_communications_3 .html which should be useful. My preference has always been to use this style instead of HTTPService objects, giving you a little more control which is what you need here.
    Let me know if you need any more assistance.

  • HTTPService problems while sending a String Variable to Server

    I have an xml in string form..... I want to send it as an http request to the server, which is written in .NET... server wud make its decession on the basis of this xml and wud return me another xml as http response..
    Problem ---->
    this request reaches server but when i look at the request reached at server it has my client infotmation but does not has my variable anywhere...... i iterate through all the parameters in Request.Params... but I don't find my string at all.... any idea why I can't find my sent variable ???
    Actionscript code to send xmlString to .NET Server using HTTPService:
    public function sendRequest(syncXmlString : String, httpResultHandler : Function) : void {
    try {
       var objectParam : Object = {name:PARAM_NAME, value:syncXmlString };
       var params : Object = [objectParam];
       var httpService : HTTPService = new HTTPService();
       httpService.url = serverUrl;
       httpService.method = HTTPRequestMessage.POST_METHOD;
       httpService.contentType =  HTTPService.CONTENT_TYPE_XML;
       httpService.resultFormat = HTTPService.RESULT_FORMAT_XML;
       httpService.addEventListener(ResultEvent.RESULT, httpResultHandler);
       httpService.addEventListener(FaultEvent.FAULT, httpFaultHandler);
       httpService.send(params);
    } catch (err : Error) {
       Alert.show(err.message);
    Thanks and Regards,
    Ahmed.

    No, that is the problem, the request object should not be an indexed array[], it should be an Object{}.  Remove that imtermediate array and pass objectParams in the send()
    Also, don't mess with the contentType without very good reason.
       httpService.contentType =  HTTPService.CONTENT_TYPE_XML;
    that says you are sending XML, but you are not, you are sending the default name=value pairs.  Remove that assignment and leave it at the default "form"
    One more, you do not want that resultFormat, it is the legacy AS2 class.  You want E4X
       httpService.resultFormat = RESULT_FORMAT_E4X;
    Tracy

Maybe you are looking for

  • Create "Object" Type based on columns of a table

    Hi Experts is it possible to create an Object Type based on columns of a table? for example the syntax for creation of type is CREATE OR REPLACE TYPE temp_t AS OBJECT (ID number, code number) can we create a type that is based on columns of an existi

  • How do I open my home page in new tab in firefox 13, like I had been doing for years?

    Since I just updated to firefox 13, I can no longer customize where a new tab opens, thanks to the new 'new tab page' feature. I've had my new tabs open to my home page for years now, it's how I'm accustomed to it, and it's frustrating that I now hav

  • Mac Mini boots to grey screen w/ symbols

    This morning my Mac Mini will not boot to Mac OS - it displays a light grey screen with a thunderbolt and some weird symbol that looks like a wheel/hub with 3 arms - 1 arm is solid and the other 2 are made up of lines perpendicular to the hub. The Ma

  • How do I save a portion of a song to my Itunes library?

    how do I save a portion of a song to my Itunes library?

  • Need Purchase order entry time field

    Hi, I need to know the table and field of the purchase order created time. I found the purchase order creation date field(AEDAT)from EKKO Table. But unable to locate the time field. ( I need to put the timestamp logic). So, i require the time field.