Simply no Alex, i do not want rewrite xml classes.

I am going to prepare a fix and create pr than we can discuss on that.

Thanks,
Serkan.

Android için Outlook<https://aka.ms/ghei36>'u edinin

________________________________
From: Alex Harui <[email protected]>
Sent: Friday, June 26, 2020 11:14:24 AM
To: serkan <[email protected]>; [email protected] 
<[email protected]>
Subject: Re: empty object is being behaved as if an xml


I’m out of time for tonight.  I’m still confused because I thought we were 
discussing handling an empty array but now it appears the array is not empty.



If I understand correctly, you want AbstractOperation to use SimpleXMLEncoder 
to convert an array of values to XML.  That sounds like a lot of work because 
it sounds like it would require emulating Flash classes like XMLNode and 
XMLDocument, so depending on how complex the XML needs to be, I’d recommend a 
hopefully simpler array to string conversion.



HTH,

-Alex



From: serkan <[email protected]>
Date: Friday, June 26, 2020 at 12:43 AM
To: Alex Harui <[email protected]>, "[email protected]" 
<[email protected]>
Subject: Re: empty object is being behaved as if an xml



Hi Alex,

26.06.2020 10:10 tarihinde Alex Harui yazdı:

Parameters is null upon entry into AbstractOperation.sendBody?

Yes it is null.


I would think you would get a different exception.  I don’t have a test case to 
debug, but the code looks like if you call Operation.send() with no args, then 
sendBody would get an empty array and you would get the exception you posted.

Exactly.




If parameters is null on entry, then it is probably worth figuring out why it 
is null and not an empty array.

The issue not the "parameters" to be null Alex, flex works with this way.

The signature of method :

    override public function send(... args:Array):AsyncToken

and in this method :

   override public function send(... args:Array):AsyncToken
    {
        if (_multiService != null)
            _multiService.initialize();

        if (operationManager != null)
            return operationManager(args);

        var params:Object;

        var filter:SerializationFilter = getSerializationFilter();
        if (filter != null)
        {
 ===>           params = filter.serializeParameters(this, args);
        }

The marked line creates array for params in both Royale and Flex.

Things changes from here the

sendBody(parameters:Object):AsyncToken

of AbstractOperations of Flex, can handle the new array but Royale can not.

In flex,

        if (ctype == CONTENT_TYPE_XML)
        {
            if (parameters is String && xmlEncode == null)
            {
                paramsToSend = parameters as String;
            }
            else if (!(parameters is XMLNode) && !(parameters is XML))
            {
                if (xmlEncode != null)
                {
                    var funcEncoded:Object = xmlEncode(parameters);
                    if (null == funcEncoded)
                    {
                        token = new AsyncToken(null);
                        msg = resourceManager.getString(
                            "rpc", "xmlEncodeReturnNull");
                        fault = new Fault(ERROR_ENCODING, msg);
                        faultEvent = FaultEvent.createEvent(fault, token);
                        new AsyncDispatcher(dispatchRpcEvent, [faultEvent], 10);
                        return token;
                    }
                    else if (!(funcEncoded is XMLNode))
                    {
                        token = new AsyncToken(null);
                        msg = resourceManager.getString(
                            "rpc", "xmlEncodeReturnNoXMLNode");
                        fault = new Fault(ERROR_ENCODING, msg);
                        faultEvent = FaultEvent.createEvent(fault, token);
                        new AsyncDispatcher(dispatchRpcEvent, [faultEvent], 10);
                        return token;
                    }
                    else
                    {
                        paramsToSend = XMLNode(funcEncoded).toString();
                    }
                }
                else
                {
                    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 = xmlDoc.toString(); is return value.

 In royale ;

if (ctype == CONTENT_TYPE_XML)
            {

                if (parameters is String && xmlEncode == null)
                {
                    paramsToSend = parameters as String;
                } else {
   ===>             paramsToSend = parameters.toXMLString();
                }

paramsToSend = parameters.toXMLString();    is called which throws exception.

checking parameters for if an empty array and than returning

paramsToSend = parameters as String;

may remove exception.

Thanks,
Serkan




-Alex



From: serkan <[email protected]><mailto:[email protected]>
Date: Thursday, June 25, 2020 at 11:31 PM
To: "[email protected]"<mailto:[email protected]> 
<[email protected]><mailto:[email protected]>, Alex Harui 
<[email protected]><mailto:[email protected]>
Subject: Re: empty object is being behaved as if an xml



Actually "parameters" is null but converted to something in AbstractOperations.

Checking the object if array and size is my first choice, I wanted to discuss 
if we need different approach .

Than if we agree I can create PR.

Thanks,
Serkan

26.06.2020 09:14 tarihinde Alex Harui yazdı:

It is unlikely that XMLNode is a factor.  More people used e4x than flash.xml.



I’m confused because the screenshots indicate that parameters is not null or an 
array but rather, some string that begins with “user



Assuming there is no “request” or “argumentNames” property, then it looks like 
Operation will pass sendBody an empty array as params so maybe check for params 
is Array and params.length = 0;



HTH,

-Alex



From: serkan <[email protected]><mailto:[email protected]>
Reply-To: "[email protected]"<mailto:[email protected]> 
<[email protected]><mailto:[email protected]>
Date: Thursday, June 25, 2020 at 12:40 PM
To: "[email protected]"<mailto:[email protected]> 
<[email protected]><mailto:[email protected]>, Alex Harui 
<[email protected]><mailto:[email protected]>
Subject: Re: empty object is being behaved as if an xml



+

The problem is not about "parameters" to be null but the handling of the null 
valued parameter by Royale.

25.06.2020 20:26 tarihinde serkan yazdı:

If we consider authAndCall of BasicAuthenticationHandler at line 69, send() is 
called.

  if (parameter == null) {
    return /* implicit cast */ 
org.apache.royale.utils.Language.as(service.operations[operationName].send(), 
mx.rpc.AsyncToken, true);
  }
  return /* implicit cast */ 
org.apache.royale.utils.Language.as(service.operations[operationName].send(parameter),
 mx.rpc.AsyncToken, true);

For here, the function being called is "mx.rpc.http.Operation.prototype.send()"

The suspendapp method of menubar :

            private function suspendApp(eventObj:CloseEvent):void {
                if(eventObj.detail == Alert.OK) {
                    suspendAppResult.token = 
BasicAuthenticationHandler.authAndCall(jobManagerService, "suspendapp");
                }
            }


I can share the sources for com.likya.pinara.utils.BasicAuthenticationHandler 
and com.likya.pinara.comps.MenuBar if you prefer.

Thanks,
Serkan




25.06.2020 20:14 tarihinde Alex Harui yazdı:

I have no idea where “parameters” came from and what it is.  Which method in 
the call stack created what is “parameters”?  Maybe suspendApp?  Or authAndCall?



I think we need to understand why Flex has null at some point but Royale 
doesn’t.



-Alex



From: "[email protected]"<mailto:[email protected]> 
<[email protected]><mailto:[email protected]>
Reply-To: "[email protected]"<mailto:[email protected]> 
<[email protected]><mailto:[email protected]>
Date: Thursday, June 25, 2020 at 9:51 AM
To: "[email protected]"<mailto:[email protected]> 
<[email protected]><mailto:[email protected]>
Subject: Re: empty object is being behaved as if an xml



Which part you want to look Alex ?

Android için 
Outlook<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Faka.ms%2Fghei36&data=02%7C01%7Caharui%40adobe.com%7C6c0be6f938ad454909c608d819a48fa0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637287541882401178&sdata=NOCpzDgFEZBImjlU5eCNKKbLG%2BD7GUFjD8wk3znnnkA%3D&reserved=0>'u
 edinin



________________________________

From: Alex Harui <[email protected]><mailto:[email protected]>
Sent: Thursday, June 25, 2020 7:47:13 PM
To: [email protected]<mailto:[email protected]> 
<[email protected]><mailto:[email protected]>
Subject: Re: empty object is being behaved as if an xml



What does the code look like that calls this?



From: serkan <[email protected]><mailto:[email protected]>
Reply-To: "[email protected]"<mailto:[email protected]> 
<[email protected]><mailto:[email protected]>
Date: Wednesday, June 24, 2020 at 11:53 PM
To: "[email protected]"<mailto:[email protected]> 
<[email protected]><mailto:[email protected]>
Subject: empty object is being behaved as if an xml



Hi,

Regarding the exception :

[cid:[email protected]]

When the "parameters" is null it is being behaved like an xml node by 
AbstractOperation with the code piece below :

            if (ctype == CONTENT_TYPE_XML)
            {

                if (parameters is String && xmlEncode == null)
                {
                    paramsToSend = parameters as String;
                } else {
                    paramsToSend = parameters.toXMLString();
                }

In fact Flex version checks if it is XMLNode or not than creates some kind of 
empty XML "<>"

How can I check if "parameters" is not an xml string and convert it to empty 
xml string ? Checking null is not working because it is not null in royale bu 
an empty Array, which is an object according to the code below :

[cid:[email protected]]

Thanks,
Serkan











Reply via email to