My goal is to loosely connect two applications using XML data transfer.
I can easily serialize and deserialize in XML format. But can I serialize from class in App1
and deserialize in different class (with the same structure as original one) in App2
?
C# or VB, doesn't matter. Structure example in VB:
App1:
Namespace Transmitter
<DataContract>
Public Class DataOut
<DataMember>
Public Header As String
<DataMember>
Public Content As String
End Class
End Namespace
App2:
Namespace Receiver
<DataContract>
Public Class DataIn ' structure actually matches Transmitter.DataOut from App1
<DataMember>
Public Header As String
<DataMember>
Public Content As String
End Class
End Namespace
In App1
, I can serialize instance of Transmitter.DataOut
into XML, but how can I read the produced XML in App2
into instance of Receiver.DataIn
? Am I required to implement Transmitter.DataOut
in App2
? Or can this (I agree that many times useful) feature be worked around? I do not want to be restricted by sharing the same class name.
I'm interesed in how-to ("is it viable?") not necessarily in source code. I can post my source if needed, but it is pretty standard one, using DataContractSerializer
.