I need to build a web service in C# which will receive a SOAP 1.1 message where the <Envelope><Header>
and <Envelope><Body>
will contain only complex XML data.
In WSE (according to this Microsoft page), creating a SOAP web service to handle this type of message seems fairly straight forward :
class MyReceiver : SoapReceiver
{
protected override void Receive(SoapEnvelope message)
{
// Do something with the message
// such as display its contents.
}
}
But, since WSE is being depreciated, I would like to build this service using WCF.
The WCF examples I find, though, seem to be of the variety where a specific set of parameters are passed to a specific method.
[OperationContract]
string GetData(int value);
Is there a way using WCF to create a web service which can receive raw SOAP 1.1 messages and provide access to the <Envelope><Header>
and <Envelope><Body>
sections as XML elements or XML streams?
To process raw SOAP messages you should use
Message
class, which represents raw message. Simply create your operation contract that accepts and returns it:then you will have
Message.Headers
orMessage.GetBody
methods. There is also aMessage.Version
if you want to check if it is whether SOAP 1.1 or 1.2.