This project is read-only.

1. Create your Contract

We're using a very basic contract for this example:
    [ServiceContract(Namespace = "urn:WcfFlashRemoting:Examples:Example1")]
    public interface IHelloWorldContract
        string HelloWorld();

In our example projects we actually split out the Contract from the Implementation in two separate DLLs, but this isn't necessary. We made the interface public as a result.

2. Implement your Contract

A simple contract leads to a simple service implementation:
    [ServiceBehavior(Namespace = "urn:WcfFlashRemoting:Examples:Example1")]
    class HelloWorldService : Contract.IHelloWorldContract
        public string HelloWorld()
            return "Hello, World!";

Notice that you don't need to declare this class public for WCF.

3. Create your Web Project (using ASP.Net Development Server)

4. Add a reference to your implementation and to WcfFlashRemoting

5. Set up your Service (using ASP.Net Development Server)

Your service file only needs a ServiceHost directive that includes a reference to your implementation class:
<%@ ServiceHost Language="C#" Debug="true" Service="WcfFlashRemoting.Example1.Implementation.HelloWorldService, WcfFlashRemoting.Example1.Implementation" %>

6. Modify your web.config

First, add the amf extension elements to your web config. It should look something like this when you're done:
        <add name="amfExtensions" type="WcfFlashRemoting.ServiceModel.Configuration.AmfEnablingElement, WcfFlashRemoting, Version=, Culture=neutral, PublicKeyToken=null"/>
        <add name="amfMessageEncoding" type="WcfFlashRemoting.ServiceModel.Configuration.AmfBindingElementExtensionElement, WcfFlashRemoting, Version=, Culture=neutral, PublicKeyToken=null"/>
        <behavior name="amfBehave">
          <amfExtensions />
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        <binding name="amfBinding">
          <amfMessageEncoding />
          <httpTransport manualAddressing="true" />


Make sure you leave the serviceBehaviors element for your existing services. Then, for each service you want to enable amf for, add the amf endpoint. It should look something like this when you're done:
      <service behaviorConfiguration="ServiceBehavior" name="WcfFlashRemoting.Example1.Implementation.HelloWorldService">
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <endpoint address="amf"

The AMF binding needs both the bindingConfiguration and the behaviorConfiguration. Remember to add the bindingNamespace attributes based on your implementation/contract to both the standard binding and to the amf binding to ensure the wsdl does not include the tempuri namespace.

7. Create your Client

C# Client

1. Create your Client Project

2. Add a reference to WcfFlashRemoting

3. Add the Service Reference

4. Modify your app.config

Since the "Add Service Reference" dialog does not know about AMF, it screws up some of the bindings for you. To correct your app.config:

5. Strip out the binding with the textMessageEncoding element the customBinding element.

6. Add in the amf extensions just like with the server config above

7. Modify the endpoint with /amf in the address - the set behaviorConfiguration to "amfBehave" and set bindingConfiguration to "amfBinding"

8. Call your service

    class Program
        static void Main(string[] args)
            Example1Service.IHelloWorldContract svc = new Example1Service.HelloWorldContractClient("AmfBinding_IHelloWorldContract");

Last edited Oct 20, 2009 at 10:35 PM by mdekrey, version 2


No comments yet.