FluorineFx.NET

Calling Web Services from Flex using Remoting

To invoke web services from your ActionScript code

  • Use the Services Description Language tool (Wsdl.exe) to generate proxy classes, compile a .NET assembly with these classes and place the assembly file into the local assembly cache of your ASP.NET application
    The services from the proxy assembly can be invoked as described in the Calling .NET assemblies from Flash section
  • Dynamic proxy generation  

  • Provide the name of the Web service file (.asmx file extension)

    <mx:RemoteObject id="fluorineRo" destination="fluorine" source="DataWebService.asmx">
      <mx:method name="GetDataSet" result="onResult(event)" fault="onFault(event)" />
    </mx:RemoteObject>
  •  

    Configurations controlling proxy generation

    When the gateway first time receives a web service remote call it will generate a proxy assembly for the web service. One should be aware how the Web Services Description Language tool / the ServiceDescriptionImporter generates proxy code for XML Web services. The generated types that are used in the proxy class are based on the contents of the WSDL document that describes the XML Web service. However, the generated types might not be what you want nor what you expect.

    Q326790 HOW TO: Change Types Used in Proxy Classes That Are Generated with Wsdl.exe

     

    The following flags may be specified in the configuration file:

  • wsdlProxyNamespace (defaults to "FluorineFx.Proxy")

    The namespace used for the generated proxy code.

  • wsdlGenerateProxyClasses (defaults to true)

    If set to false removes all the generated types that aren't the proxy itself. This is required if you want to share several types from your code.

    To avoid namespace problems you must specify the namespaces to import into the proxy code by using the importNamespaces configuration section. Please note that in the current version the "assembly" attribute should be set to an empty string.

     

    Sample:

    This is our shared type's definition
    namespace com.ariaware.pizza.vo
    {
        public class OrderVO
        {
            string _name;

            public OrderVO()
            {
            }

            public string name
            {
                get{ return _name; }
                set{ _name = value; }
            }
            ...
        }
    }

    The web service definition:
    using com.ariaware.pizza.vo;
    namespace MyWebAppNamespace
    {
        public class MyWebService : System.Web.Services.WebService
        {

            [WebMethod]
            public void PlaceOrder(OrderVO order)
            {
                ...
            }
        }
    }

    In the above sample if proxy class generation is allowed (wsdlGenerateProxyClasses=true) then a new OrderVO type will be generated. Its fully qualified class name will be FluorineFx.Proxy.OrderVO.
    (This class will not map to com.ariaware.pizza.vo.OrderVO objects sent from Flash)

    To avoid generating these proxy classes set wsdlGenerateProxyClasses=false. Also specify in the importNamespaces configuration section the namespaces to import to the proxy code (in this sample the com.ariaware.pizza.vo namespace is required).

    <importNamespaces>
       <add namespace="com.ariaware.pizza.vo" assembly=""/>
    </importNamespaces>