0

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?

Shion
  • 1,499
  • 2
  • 14
  • 29

2 Answers2

2

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.

naro
  • 416
  • 7
  • 16
  • Thank you! Since the Class is only used to send data from client to server I take it that with your explanation the client can still use the service even if no wsdl update was made? – Shion Aug 31 '15 at 13:36
  • If you send data from client to server, with the object “MyClient”, you have to fill the Object into the client. Isn’t the client set the MessageBodyMember “B”? – naro Aug 31 '15 at 14:19
  • Of course the client will still fill "B" and pass it to the server, the client hasn't updated the wsdl. The question is: Will the server be able to handle this and take on the request? – Shion Aug 31 '15 at 14:26
  • What happend when you have an object inside an object? Can you use the Order attribute for other the inside properties? – Luis.Andrade Oct 14 '16 at 17:33
0

Adding to @naro's answer:

It is not a breaking change for the following frameworks:

  • .NET (C#, 4.5)
  • Java 8

I did not test anything else as it doesn't matter for our scenario.

This means every client still works (without regenerating the client) even after updating the web service definition.

Shion
  • 1,499
  • 2
  • 14
  • 29