Which code segment should you use?

You are developing a client that sends several types of SOAP messages to a Windows Communication Foundation (WCF)
service method named PostData. PostData is currently defined as follows:

[OperationContract]
void PostData(Order data);

You need to modify PostData so that it can receive any SOAP message. Which code segment should you use?

You are developing a client that sends several types of SOAP messages to a Windows Communication Foundation (WCF)
service method named PostData. PostData is currently defined as follows:

[OperationContract]
void PostData(Order data);

You need to modify PostData so that it can receive any SOAP message. Which code segment should you use?

A.
[OperationContract(IsOneWay=true, Action=”*”, ReplyAction=”*”)]
void PostData(Order data);

B.
[OperationContract(IsOneWay=true, Action=”*”, ReplyAction = “*”)]
void PostData(BodyWriter data);

C.
[OperationContract]
void PostData(BodyWriter data);

D.
[OperationContract]
void PostData(Message data);

Explanation:
The Message class is fundamental to Windows Communication Foundation (WCF).
All communication between clients and services ultimately results in Message instances being sent and received.

You would not usually interact with the Message class directly. Instead, WCF service model constructs,
such as data contracts, message contracts, and operation contracts, are used to describe incoming and outgoing messages.
However, in some advanced scenarios you can program using the Message class directly.
For example, you might want to use the Message class:
* When you need an alternative way of creating outgoing message contents (for example, creating a message directly from a file on disk) instead of serializing .NET Framework objects.
* When you need an alternative way of using incoming message contents (for example, when you want to apply an XSLT transformation to the raw XML contents) instead of deserializing into .NET Framework objects.
* When you need to deal with messages in a general way regardless of message contents (for example, when routing or forwarding messages when building a router, load-balancer, or a publish-subscribe system).

How to: Send and Receive a SOAP Message By Using the SoapClient and SoapService Classes
(http://msdn.microsoft.com/en-us/library/aa529276.aspx)

How to: Send and Receive a SOAP Message By Using the SoapSender and SoapReceiver Classes
(http://msdn.microsoft.com/en-us/library/aa528828.aspx)



Leave a Reply 1

Your email address will not be published. Required fields are marked *