Consider the following ServiceContract-Interface:
[ServiceContract]
public interface ITest
{
[OperationContract]
void MyMethod(MyClass obj);
}
With MyClass beeing:
[MessageContract]
public MyClass
{
[MessageBodyMember(Order = 0)]
public int A { get; set; }
[MessageBodyMember(Order = 1)]
public int B { get; set; }
[MessageBodyMember(Order = 2)]
public int C { get; set; }
}
MyClass
is now changed to look like the following:
[MessageContract]
public MyClass
{
[MessageBodyMember(Order = 0)]
public int A { get; set; }
[MessageBodyMember(Order = 2)]
public int C { get; set; }
}
Would a client consuming this WCF-Service need to make additional changes to work with the new service definition?
Additionaly, what would happen if I were to additionally change C
to have the new Order = 1
?
If the client updates the WSDL File, it gets a syntax error in the code of the client, when the client calls the method.
The order element set on which position in the communication the bodymember sending to the server/client. You can see it into the svc log. Example.:
<ns2: myClass xmlns:ns2="yourNamespace">
<A xmlns=""></A>
<B xmlns=""></B>
<C xmlns=""></C>
</ns2:myClass>
After changed the ordner element:
<ns2: myClass xmlns:ns2="yourNamespace">
<C xmlns=""></C>
<A xmlns=""></A>
<B xmlns=""></B>
</ns2: myClass >
I have tried the example for you. I have used a WCF C# Web service and a C# client with a standard protocol: BasicHttpBinding. And I use the WCF Test client. In this combination I got no error in the client, provided that the client makes no WSDL update. In this case, you can change the order element without errors. But this is not a correct implementation; therefore you can’t assume that everything is working. For other clients see the result might be different. For example, a Java client is much more restrictive.