SOAP Headers

Hi,

In classic web services I could define services like this:

[WebMethod]
[SoapHeader("SessionHeader", Direction = SoapHeaderDirection
.Out)]
public bool Logon(string user, string password)

To achieve the same thing (including the SOAP header) with WCF, it would appear that I have to do this:

[OperationContract]
LogonResponse Logon(LogonRequest request);

As such I have to define LogonResponse and LogonRequest myself, which is easy but a little tedious. It also imposes on the way the service is used at the client. Similarly, I used to be able to do this:

[WebMethod]
[SoapHeader("SessionHeader", Direction = SoapHeaderDirection
.In)]
public byte[] Synchronize(byte[] data, ref DateTime timestamp)

But now have to resort to:

[OperationContract]
SynchronizeResponse Synchronize(SynchronizeRequest request);

Is there any way I can make things easier for myself Can I attach a SOAP header / use MTOM etcetera without needing to define separate Request / Response classes

Thanks,
Kent



Answer this question

SOAP Headers