.netWCF

Message Contracts in WCF(part-9)

You can use Message contracts in WCF, if and only if you wanted to change the Soap XML message.

For an example, if you wanted to customize the SOAP header or change the wrapper element in SOAP message etc.

If you will open the Messge log, you will see below XML message without Message contracts:
XML Request:

In this request, GetEnterpriseInternetInformation is the method name
XML Response:

In this Response, GetEnterpriseInternetInformation is appended with Response key word and result keyword.
So we can use message contract to change the method names or parameters in the XML message.
Let’s change the GetEnterpriseInternetInformation to GetEnterpriseInternetInfoRequest in XML Request and GetEnterpriseInternetInfoResponse in XML Response.

Implement the GetEnterpriseInternetInfoRequest and GetEnterpriseInternetInfoResponse in IEnterpriseService.cs and Run the service.
You will see the below XML request and response.

© 2015, www.techkatak.com. All rights reserved.