I've WCF service operation defined in a simple way like
[ServiceContract(Namespace = "http://contoso.com")]
interface ICalculator
{
[OperationContract]
AddResp Add(AddRqst addRequestDummyName);
}
where AddRqst is defined as
[DataContract]
class AddRqst
{
[DataMember]
public decimal A { get; set; }
[DataMember]
public decimal B { get; set; }
}
and the problem I see is that the way WCF serializes and the way it expects requests are wrapped by the parameter name like so (this is from memory)
<Add>
<addRequestDummyName>
<A>1</A>
<B>1.5</B>
</addRequestDummyName>
</Add>
I can't distribute a schema for this file because WCF likes to add and expects that extra wrapper for the parameters. It should look like I designed to be, like so
<Add>
<A>1</A>
<B>1.5</B>
</Add>
I'm aware of MessageContract and I've tested that by changing AddRqst (and also AddResp) to the following removes the wrapping because by using messagecontracts you assume just 1 contract.
[DataContract]
[MessageContract]
class AddRqst
{
[DataMember]
[MessageBodyMember]
public decimal A { get; set; }
[DataMember]
[MessageBodyMember]
public decimal B { get; set; }
}
My question is the following. Is there way to do this just with datacontracts? All my operations have 1 parameter. If not, is the way I modified AddRqst the best way to do this?