nihavend commented on pull request #876:
URL: https://github.com/apache/royale-asjs/pull/876#issuecomment-650505958


   > Are you sure that's what Flex is doing? I thought you said Flex sent 
something like <> (for an empty XML). 
   > Won't this set paramsToSend to null? 
   
   I am sure this is not what Flex is doing, I described below step by step 
what Flex is doing. Flex setting value to "<>" it is true 
   and also it is true that  this will set paramsToSend to null. If it is 
better to to set it to "<>" than null I can do it.
   
   > I also thought you said that sometimes parameters were passed in. Do you 
want to handle that case as well? 
   
   If parameters were passed than it is not null and than it is xml or string 
and handled correctly. Am I missing something ?
   
   > What does Flex output for null and if there are some parameters?
   
   If there are parameters than it can not be null. Am I missing something ?
   
   Here is what flex is doing : 
   
   This is what my app function calls when my internal variable parameter is 
null : 
   
    ```
                        if(parameter == null) {
                                return service.operations[operationName].send();
                        }
                        
                        return 
service.operations[operationName].send(parameter);
   ```
   Here the function called is  (Operation.as):
   
   `override public function send(... args:Array):AsyncToken`
   
   the value of args : 
   
   
![image](https://user-images.githubusercontent.com/5983818/85916068-b19feb00-b855-11ea-9a79-5a7f876fead7.png)
   
   and this is also the value of "param" which is internal parameter of 
Operation.
   
   
![image](https://user-images.githubusercontent.com/5983818/85916106-08a5c000-b856-11ea-9af0-e270e4de4767.png)
   
   The methods returns with `return sendBody(params);` 
   
   sendBody is method of mx.rpc.http.AbstractOperation and the below part of 
the function is executed : 
   
   ```
                       var encoder:SimpleXMLEncoder = new 
SimpleXMLEncoder(null);                    
                       var xmlDoc:XMLDocument = new XMLDocument();
                       
                       //right now there is a wasted <encoded> wrapper tag
                       //call.appendChild(encoder.encodeValue(parameters));
                       var childNodes:Array = encoder.encodeValue(parameters, 
new QName(null, "encoded"), new XMLNode(1, "top")).childNodes.concat();         
           
                       for (var i:int = 0; i < childNodes.length; ++i)
                           xmlDoc.appendChild(childNodes[i]);
   
                       paramsToSend = xmlDoc.toString();
   ```
   paramsToSend becomes "<>" here.
   
   
![image](https://user-images.githubusercontent.com/5983818/85916180-d6489280-b856-11ea-9edd-3b5821da7ec9.png)
   
   and the rest of the code creates message object and calls invoke : 
   
   ```
           message.contentType = ctype;
           message.method = method.toUpperCase();
           if (ctype == CONTENT_TYPE_XML && message.method == 
HTTPRequestMessage.GET_METHOD)
               message.method = HTTPRequestMessage.POST_METHOD;
           message.body = paramsToSend;
           message.httpHeaders = getHeaders();
           return invoke(message);
   ```
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to