[Mono-list] WCF MessageContract soap namespace serialization issue
Marc Bettex
bettex at epsitec.ch
Thu Oct 27 09:24:09 EDT 2011
Hi,
I am porting a windows application using WCF running on .Net so that it can
run on Mono (2.10.6) on windows and I have a problem with the serialization
of the soap messages. I use message contracts with the xml serializer and
the c# code for the objects is generated by the svcutil.exe program from
microsoft (from a wsdl and xsd files given by a third party).
My program works fine when running on .Net but when I run it on Mono, the
fields of the class tagged with [MessageContract] that are tagged with
[MessageBodyMember] are serialized with the xml namespace of the enclosing
class and not with the one declared in the [MessageBodyMember] attribute of
the field. Here is the code that I think is relevant, but the file generated
by svcutil is something like 12000 lines long and I might have missed
something.
The part with the message contract is this :
[MessageContract (WrapperName="DeclareSalary",
WrapperNamespace="http://www.swissdec.ch/schema/sd/20090803/SalaryDeclarationServiceTypes",
IsWrapped=true)]
public partial class DeclareSalaryRequest
{
[MessageBodyMember
(Namespace="http://www.swissdec.ch/schema/sd/20090803/SalaryDeclarationContainer",
Order=0)]
public RequestContextType RequestContext;
[... Other field decorated as the previous one ...]
}
The part with the relevant RequestContextType is this :
[Serializable]
[XmlType
(Namespace="http://www.swissdec.ch/schema/sd/20090803/SalaryDeclarationContainer")]
public partial class RequestContextType
{
[XmlElement (Order=0)]
public UserAgentType UserAgent
{
get
{
return this.userAgentField;
}
set
{
this.userAgentField = value;
}
}
[... Other properties decorated as the previous one ...]
}
The part with the relevant UserAgentType is this :
[Serializable]
[XmlType
(Namespace="http://www.swissdec.ch/schema/sd/20090803/SalaryDeclarationContainer")]
public partial class UserAgentType
{
[...]
}
The result of the serialization on .Net (which is correct) is this :
<DeclareSalary
xmlns="http://www.swissdec.ch/schema/sd/20090803/SalaryDeclarationServiceTypes">
<RequestContext
xmlns="http://www.swissdec.ch/schema/sd/20090803/SalaryDeclarationContainer">
<UserAgent>
[...]
</UserAgent>
</RequestContext>
[...]
</DeclareSalary>
The result of the serialization on Mono (which is incorrect) is this :
<DeclareSalary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.swissdec.ch/schema/sd/20090803/SalaryDeclarationServiceTypes">
<RequestContext>
<UserAgent
xmlns="http://www.swissdec.ch/schema/sd/20090803/SalaryDeclarationContainer">
[...]
</UserAgent>
</RequestContext>
[...]
</DeclareSalary>
As you can see, the <RequestContext> tag should be in the namespace
[...]SalaryDeclarationContainer as given in the MessageBodyMember and in the
XmlType attributes. But on Mono it is in the namespace of the enclosing
element ([...]SalaryDeclarationServiceTypes) and its children is in the
right namespace. There are other elements at the same level as
<RequestContext> and they all have the exact same problem, they are in the
namespace of their enclosing element and their children are in the correct
namespace.
Any help on this issue would be greatly appreciated. I'm not sure if this is
a bug in Mono or if I'm using a feature that is not supported in Mono or if
I'm doing something wrong. Thanks in advance.
--
View this message in context: http://mono.1490590.n4.nabble.com/WCF-MessageContract-soap-namespace-serialization-issue-tp3944420p3944420.html
Sent from the Mono - General mailing list archive at Nabble.com.
More information about the Mono-list
mailing list