Navigation:  Code Generation > Remoting/RPC > Code Generation Features >

Namespaces for Complex Types

Previous pageReturn to chapter overviewNext page

All built-in code generators create complete mapping of the client-side (ActionScript or Silverlight) classes with the packages and namespaces corresponding to the server-side complex types. Consider the following code:

using System;
using System.Collections.Generic;
using com.bar;
using com.baz;
 
namespace com.foo
{
 public class PersonService
 {
   public Person getPerson()
   {
     return new Person();
   }
 }
 
 public class Person
 {
   public String Name { get; set; }
   public List<Address> Addresses { get; set;}
   public List<Job> WorkHistory { get; set; }
 }
}
 
namespace com.bar
{
 public class Address
 {
   public String StreetAddress { get; set; }
   public String City { get; set; }
   public String PostalCode { get; set; }
 }
}
 
namespace com.baz
{
 public class Job
 {
   public DateTime From { get; set; }
   public DateTime To { get; set; }
   public String Position { get; set; }
 }
}

The code example consists of a service class (PersonService) and three complex types (Person, Address, Job). Notice that all three types are placed in different namespaces. When the code generators create client-side code for the PersonService class, they will generate corresponding client classes in the packages/namespaces matching the server's class. For example, below is the layout of the generated code  from the Flex Remoting/AS3 code generator:

packages_in_generated_code

Notice the packages for the Person.as, Address.as and Job.as files - they match the original namespace structure with an addition the ".vo" package.