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

SOAP Headers
Rihaz
Please check these two samples also
http://windowssdk.msdn.microsoft.com/library/en-us/WCF_samples/html/4b39c439-3d27-4fb6-9f74-1893c7a89c6b.asp frame=true
http://windowssdk.msdn.microsoft.com/library/en-us/WCF_samples/html/5a200b78-1a46-4104-b7fb-da6dbab33893.asp frame=true
Matt Goswell
You can use the MessageContract as described or you can add the headers manually. I've got sample on that if you want it.
smason@microsoft.com
Thanks!
Scott
AsOne
Hi Kent,
Have you looked at the MessageContract attribute It give you greater control and flexibility in defining your headers and body in the soap packet.
FYI: For your first scenario, you could define a security binding that automatically puts the usernametoken into the header and sends it over via transport or message security.
HTH.
Dot Net Guy
Sent.. ;>
Thanks!
Scott
Xena Systems Limited
Thanks for the replies guys. Sorry I took a while to get back to you but I've been away from work for a while (but not long enough).
OK, so yes I've seen and tried the MessageContract approach. Indeed it works, but it requires the definition of the extra request / response classes. And it therefore complicates the client code because it has to construct and populate the request object instead of just calling the service method.
I have asked Scott for his samples so hopefully they will help me out. Other than that, I've just ordered a book on WCF because the MSDN "doco" is driving me crazy.
Thanks,
Kent