Apache flex 当我对WebService参数使用动态类时,不包括公共属性

Apache flex 当我对WebService参数使用动态类时,不包括公共属性,apache-flex,actionscript-3,web-services,class,actionscript,Apache Flex,Actionscript 3,Web Services,Class,Actionscript,我有一个动态类,它是一个值对象,用于向Web服务传递参数。它有两个公共属性: package { [Bindable] public dynamic class WebServiceCriteria { public var property1:String; public var property2:String; } } 我在应用程序的一部分中设置了这两个属性: var myCriteria:WebServiceCriter

我有一个动态类,它是一个值对象,用于向Web服务传递参数。它有两个公共属性:

package
{
    [Bindable]
    public dynamic class WebServiceCriteria
    {
        public var property1:String;

        public var property2:String;
    }
}
我在应用程序的一部分中设置了这两个属性:

var myCriteria:WebServiceCriteria = new WebServiceCriteria();

myCriteria.property1 = "x";

myCriteria.property2 = "y";
myCriteria.property3 = "z";
然后,我在应用程序的另一个点添加了其他-动态-属性:

var myCriteria:WebServiceCriteria = new WebServiceCriteria();

myCriteria.property1 = "x";

myCriteria.property2 = "y";
myCriteria.property3 = "z";
但是,当我将实例作为参数传递给WebService时,原始的两个公共属性不会被发送(正如我在Fiddler中看到的),即使它们有值。但是,我可以在send()之前的调试器中将它们视为类实例的属性

为什么不发送这两个属性

以下是发送到Web服务的SOAP请求的示例:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <intf:webservice_controller xmlns:intf="http://childDir.parentDir">
      <args xsi:type="apachesoap:Map" xmlns:apachesoap="http://xml.apache.org/xml-soap">
        <item>
          <key xsi:type="xsd:string">property1</key>
          <value xsi:type="xsd:string"></value>
        </item>
        <item>
          <key xsi:type="xsd:string">property2</key>
          <value xsi:type="xsd:string"></value>
        </item>
        <item>
          <key xsi:type="xsd:string">property3</key>
          <value xsi:type="xsd:string">z</value>
        </item>
      </args>
    </intf:webservice_controller>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

物业1
物业2
财产3
Z

尝试将其添加到构造函数中:

package
{
    [Bindable]
    public dynamic class WebServiceCriteria
    {
        public var property1:String;
        public var property2:String;

        function WebServiceCriteria()
        {
             prototype.property1 = null;
             prototype.property2 = null;
        }
    }
}

。。。由于似乎只有
对象
的属性是可枚举的

请尝试将其添加到构造函数中:

package
{
    [Bindable]
    public dynamic class WebServiceCriteria
    {
        public var property1:String;
        public var property2:String;

        function WebServiceCriteria()
        {
             prototype.property1 = null;
             prototype.property2 = null;
        }
    }
}

。。。由于似乎只有
对象
s属性是可枚举的

,因此Flex 3.0手册中记录了此行为。有关更多信息,请参阅。直接引用:

但是,以这种方式创建的[…]方法无权访问[example]类的任何私有属性或方法。此外,即使对[example]类的公共属性或方法的引用也必须使用this关键字或类名限定


Flex 3.0手册中记录了这种行为。有关更多信息,请参阅。直接引用:

但是,以这种方式创建的[…]方法无权访问[example]类的任何私有属性或方法。此外,即使对[example]类的公共属性或方法的引用也必须使用this关键字或类名限定


我不相信您将能够向Web服务发送对象。如果要发送对象,则需要使用远程对象。要使用Web服务,您需要将对象转换为某种xml或soap请求。像


var myCriteria:WebServiceCriteria=新的WebServiceCriteria()

myCriteria.property1=“x”

myCriteria.property2=“y”

发送操作( {myCriteria.property1} {myCriteria.property2} );


我认为您无法向Web服务发送对象。如果要发送对象,则需要使用远程对象。要使用Web服务,您需要将对象转换为某种xml或soap请求。像


var myCriteria:WebServiceCriteria=新的WebServiceCriteria()

myCriteria.property1=“x”

myCriteria.property2=“y”

发送操作( {myCriteria.property1} {myCriteria.property2} );


如果添加一个forth属性,会发生什么情况?是只发送4,还是发送3和4?是的。这是我正在做的一个非常简化的版本。当我添加“动态”属性时,我添加了任意数量的属性,它们都会被毫无问题地发送。如果添加第四个属性,会发生什么情况,是只发送4个,还是发送3和4个?是的。这是我正在做的一个非常简化的版本。当我添加“动态”属性时,我添加了任意数量的属性,它们都会被毫无问题地发送。真的吗?我已经这样做过很多次了。Flex在SOAP请求中将其转换为关联数组,而我的CFC将其作为结构接受(参见上面的示例)。真的吗?我已经这样做过很多次了。Flex将其转换为SOAP请求中的关联数组,而我的CFC将其作为结构接受(参见上面的示例)。