https://github.com/artema/dotamf
.NET serializer and WCF bindings for AMF with full Flex compatibility. Just add AMF endpoints to your existing WCF services and you are ready to go.
https://github.com/artema/dotamf
amf amf3 csharp dotnet flash flex wcf wcf-bindings wcf-service
Last synced: 21 days ago
JSON representation
.NET serializer and WCF bindings for AMF with full Flex compatibility. Just add AMF endpoints to your existing WCF services and you are ready to go.
- Host: GitHub
- URL: https://github.com/artema/dotamf
- Owner: artema
- License: ms-pl
- Created: 2012-03-11T22:18:38.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2015-11-29T14:34:34.000Z (over 9 years ago)
- Last Synced: 2025-04-21T11:07:50.657Z (about 2 months ago)
- Topics: amf, amf3, csharp, dotnet, flash, flex, wcf, wcf-bindings, wcf-service
- Language: C#
- Homepage:
- Size: 2.59 MB
- Stars: 16
- Watchers: 3
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
NuGet packages: [DotAmf](https://www.nuget.org/packages/DotAmf/) (serializer) and [DotAmf.Wcf](https://www.nuget.org/packages/DotAmf.Wcf/) (service layer).
# About #
.NET serializer and WCF bindings for AMF with full Flex remoting support.
> Action Message Format (AMF) is a binary format used to serialize object graphs such as ActionScript objects and XML, or send messages between an Adobe Flash client and a remote service, usually a Flash Media Server or third party alternatives. The Actionscript 3 language provides classes for encoding and decoding from the AMF format.
>
> [http://en.wikipedia.org/wiki/Action\_Message\_Format](http://en.wikipedia.org/wiki/Action_Message_Format)AMF has several advantages over existing serialization formats, including the ability to maintain objects graph, a small footprint when storing a set of identical objects (including strings) or references to the same object, and a wide range of natively supported types (such as `XmlDocument`, `DateTime` and `Dictionary`).
# WCF Configuration #
Consider the following service contracts:
using System;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Xml;namespace ExampleService
{
[ServiceContract]
public interface IMyService
{
[OperationContract]
ProductVo[] GetAllProducts();[OperationContract(Name = "GetUser")] //Custom procedure name
User GetUserDataContract(int id);[OperationContract]
int AddUser(User user);[OperationContract]
Content SendContent(Content content);[OperationContract]
User[] SendGraph(User[] users);[OperationContract]
void DoStuff();[OperationContract]
[FaultContract(typeof(CustomFault))]
void DoFault();
}[DataContract] //Will have the "ExampleService.User" alias
public class User
{
[DataMember(Name = "id")] //Custom field name
public int Id { get; set; }[DataMember(Name = "is_active")]
public bool IsActive { get; set; }[DataMember] //Use explicit name
public string name { get; set; }[DataMember(Name = "products")]
public ProductVo[] Products { get; set; }
}[DataContract(Name = "Product")] //Custom alias
public class ProductVo
{
[DataMember(Name = "id")]
public int Id { get; set; }
}[DataContract]
public class CustomFault
{
[DataMember(Name = "date")]
public DateTime Date { get; set; }[DataMember(Name = "message")]
public string Message { get; set; }
}[DataContract]
public class Content
{
[DataMember(Name = "data")]
public byte[] Data { get; set; }[DataMember(Name = "xml")]
public XmlDocument Xml { get; set; }
}
}To add an AMF support to a service, you only need to update your configuration:
See the `Examples` folder for a complete service and client implementations.
# Serialization #
You can use `DataContractAmfSerializer` to serialize and deserialize from binary AMF data outside of the WCF.
CustomType objectToWrite;
var knownTypes = new[] {
typeof(KnownType1),
typeof(KnownType2)
};
var serializer = new DataContractAmfSerializer(typeof(CustomType), knownTypes);using (var stream = new MemoryStream())
serializer.WriteObject(stream, objectToWrite);