Solution Visual Studio 2008
Contrat de données
<ServiceContract()> _
Public Interface IDeveloppeurService
<OperationContract()> _
Sub Add(ByVal dev As Sample.KnownTypes.DataContracts.Developpeur)
End Interface
Public Class DeveloppeurService
Implements KnownTypes.ServiceContracts.IDeveloppeurService
Public Sub Add(ByVal dev As DataContracts.Developpeur) Implements ServiceContracts.IDeveloppeurService.Add
' Implémenter un métier quelconque !
Console.WriteLine(String.Format("Type : {0}", dev.GetType().FullName))
End Sub
End Class
Sub Main()
Dim factory = New ChannelFactory(Of ServiceContracts.IDeveloppeurService)("MyEndPoint")
Dim proxy = factory.CreateChannel()
Console.WriteLine("Appuyez sur entrée pour l'appel")
Console.ReadLine()
proxy.Add( _
New KnownTypes.DataContracts.DeveloppeurPointNet _
With {.Nom = "Colin", .Prenom = "Frédéric", .EstCertifieCSharp = True})
New KnownTypes.DataContracts.DeveloppeurJava _
With {.Nom = "Nom", .Prenom = "Prénom", .EstCertifieJava = False})
factory.Close()
<system.runtime.serialization>
<dataContractSerializer>
<declaredTypes>
<add type="Sample.KnownTypes.DataContracts.Developpeur, Sample.KnownTypes.DataContracts">
<knownType
type="Sample.KnownTypes.DataContracts.DeveloppeurPointNet, Sample.KnownTypes.DataContracts" />
type="Sample.KnownTypes.DataContracts.DeveloppeurJava, Sample.KnownTypes.DataContracts" />
</add>
</declaredTypes>
</dataContractSerializer>
</system.runtime.serialization>