wcf architecture nagaraj - wcf - wordpress.comweb services that enables http cookies to be used to...

61
WCF Architecture

Upload: others

Post on 21-May-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

WCF Architecture

Nagaraj - WCF

Page 2: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Nagaraj - WCF

Page 3: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Nagaraj - WCF

Page 4: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Messaging layer for the WCF Exchange Server mail transport

Nagaraj - WCF

Page 5: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

WCF messaging layer on the .NET Compact Framework

Nagaraj - WCF

Page 6: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Messaging layer for the WCF Exchange Server mail transport

Nagaraj - WCF

Page 7: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Nagaraj - WCF

Page 8: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Binding Configuration Element Description BasicHttpBinding <basicHttpBinding> A binding that is suitable for communicating with WS-Basic Profile conformant

Web services, for example, ASP.NET Web services (ASMX)-based services. This binding uses HTTP as the transport and text/XML as the default message encoding.

WSHttpBinding <wsHttpBinding> A secure and interoperable binding that is suitable for non-duplex service contracts.

WSDualHttpBinding <wsDualHttpBinding> A secure and interoperable binding that is suitable for duplex service contracts or communication through SOAP intermediaries.

WSFederationHttpBinding

<wsFederationHttpBinding> A secure and interoperable binding that supports the WS-Federation protocol that enables organizations that are in a federation to efficiently authenticate and authorize users.

NetTcpBinding <netTcpBinding> A secure and optimized binding suitable for cross-machine communication between WCF applications.

NetNamedPipeBinding <netNamedPipeBinding> A secure, reliable, optimized binding that is suitable for on-machine communication between WCF applications.

NetMsmqBinding <netMsmqBinding> A queued binding that is suitable for cross-machine communication between WCF applications.

NetPeerTcpBinding <netPeerTcpBinding> A binding that enables secure, multiple machine communication.MsmqIntegrationBinding <msmqIntegrationBinding> A binding that is suitable for cross-machine communication between a WCF

application and existing Message Queuing applications.

BasicHttpContextBinding <basicHttpContextBinding> A binding that is suitable for communicating with WS-Basic Profile conformant Web services that enables HTTP cookies to be used to exchange context.

NetTcpContextBinding <netTcpContextBinding> A secure and optimized binding suitable for cross-machine communication between WCF applications that enables SOAP headers to be used to exchange context.

WebHttpBinding <webHttpBinding> A binding used to configure endpoints for WCF Web services that are exposed through HTTP requests instead of SOAP messages.

WSHttpContextBinding <wsHttpContextBinding> A secure and interoperable binding that is suitable for non-duplex service contracts that enables SOAP headers to be used to exchange context.

The following bindings ship with WCF

Nagaraj - WCF

Page 9: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Binding Interoperability

Security (Default) Session (Default) Transactions Duplex Encoding (Default)

Streaming (Default)

BasicHttpBinding Basic Profile 1.1 (None), Transport, Message, Mixed

(None) (None) n/a Text, (MTOM) Yes

(buffered)

WSHttpBinding WS Transport, (Message), Mixed

(None), Reliable Session, Security Session

(None), Yes n/a (Text), MTOM No

WSDualHttpBinding

WS (Message), None (Reliable Session), Security Session

(None), Yes Yes (Text), MTOM No

WSFederationHttpBinding

WS-Federation (Message), Mixed, None

(None), Reliable Session, Security Session

(None), Yes No (Text), MTOM No

NetTcpBinding .NET (Transport), Message, None, Mixed

(Transport), Reliable Session, Security Session

(None), Yes Yes Binary Yes

(buffered)

NetNamedPipeBinding

.NET (Transport), None None, (Transport) (None), Yes Yes Binary Yes

(buffered)

NetMsmqBinding .NET Message, (Transport), None

(None), Transport None, (Yes) No Binary No

NetPeerTcpBinding

Peer (Transport) (None) (None) Yes No

MsmqIntegrationBinding

MSMQ (Transport) (None) None, (Yes) n/a n/a No

BasicHttpContextBinding

Basic Profile 1.1 (None), Transport, Message, Mixed

(None) (None) n/a Text, (MTOM) Yes

(buffered)

NetTcpContextBinding

.NET (Transport), Message, None, Mixed

(Transport), Reliable Session, Security Session

(None), Yes Yes Binary Yes

(buffered)

WebHttpBinding .NET (None), Transport, TransportCredentialOnly

(None) (None), No No (Text) No

WSHttpContextBinding

WS Transport, (Message), Mixed

(None), Reliable Session, Security Session

(None), Yes n/a Text, (MTOM)

The following table shows the features of each of the system-provided bindings.

Nagaraj - WCF

Page 10: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Setting Features

Transport

Server authenticationClient authenticationPoint-to-point securityInteroperabilityHardware accelerationHigh throughputSecure firewallHigh-latency applicationsRe-encryption across multiple hops

Message

Server authenticationClient authenticationEnd-to-end securityInteroperabilityRich claimsFederationMultifactor authenticationCustom tokensNotary/timestamp serviceHigh-latency applicationsPersistence of message signatures

TransportWithMessageCredential

Server authentication Client authentication Point-to-point security InteroperabilityHardware accelerationHigh throughputRich client claimsFederationMultifactor authenticationCustom tokensSecure firewallHigh-latency applicationsRe-encryption across multiple hops

Binding Choices

Use this table to helpyou find the securityfeatures yourapplication requires.

Nagaraj - WCF

Page 11: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Binding Transport mode support

Message mode support TransportWithMessageCredential support

BasicHttpBinding Yes Yes Yes

WSHttpBinding Yes Yes Yes

WSDualHttpBinding No Yes No

NetTcpBinding Yes Yes Yes

NetNamedPipeBinding Yes No No

NetMsmqBinding Yes Yes No

MsmqIntegrationBinding Yes No No

wsFederationHttpBinding No Yes Yes

Nagaraj - WCF

Page 12: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Nagaraj - WCF

Page 13: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

InstanceContextModevalue

Required Allowed NotAllowed

PerCall Behavior with sessionful channel: A session and InstanceContext for each call.

Behavior with sessionless channel: An exception is thrown.

Behavior with sessionful channel: A session and InstanceContext for each call.

Behavior with sessionless channel: An InstanceContext for each call.

Behavior with sessionfulchannel: An exception is thrown.

Behavior with sessionlesschannel: An InstanceContext for each call.

PerSession Behavior with sessionful channel: A session and InstanceContext for each channel.

Behavior with sessionless channel: An exception is thrown.

Behavior with sessionful channel: A session and InstanceContext for each channel.

Behavior with sessionless channel: An InstanceContext for each call.

Behavior with sessionful channel: An exception is thrown.

Behavior with sessionless channel: An InstanceContext for each call.

Single Behavior with sessionful channel: A session and one InstanceContext for all calls.

Behavior with sessionless channel: An exception is thrown.

Behavior with sessionful channel: A session and InstanceContext for the created or user-specified singleton.

Behavior with sessionless channel: An InstanceContext for the created or user-specified singleton.

Behavior with sessionfulchannel: An exception is thrown.

Behavior with sessionlesschannel: An InstanceContext for each created singleton or for the user-specified singleton.Nagaraj -

WCF

Page 14: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Nagaraj - WCF

Page 15: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Attribute Description Favored transports Diagnostics Diagnostics allow you to automatically detect transport connectivity problems. All transports support the

ability to send back fault information that describes connectivity. However, WCF does not include diagnostic tools for investigating network issues.

None

Hosting All WCF endpoints must be hosted inside an application. IIS 6.0 and earlier support only hosting applications that use the HTTP transport. On Windows Vista, support is added for hosting all WCF transports, including TCP and named pipes. For more information, see Hosting in Internet Information Services and Hosting in Windows Process Activation Service.

HTTP

Inspection Inspection is the ability to extract and process information from messages during transmission. The HTTP protocol separates routing and control information from data, making it easier to build tools that inspect and analyze messages. Transports that are easy to inspect may also require less processing power in network appliances. The level of security used impacts whether messages can be inspected.

HTTP

Latency Latency is the minimum amount of time required to complete an exchange of messages. All network operations have more or less latency depending on the choice of transport. Using duplex or one-way communication with a transport whose native message exchange pattern is request-reply, such as HTTP, can cause additional latency due to the forced correlation of messages. In this situation, consider using a transport whose native message exchange pattern is duplex, such as TCP.

TCP, Named

Pipe

Reach The reach of a transport reflects how capable the transport is at connecting with other systems. The named pipe transport has very little reach; it can only connect to services running on the same machine. The TCP and HTTP transports both have excellent reach and can penetrate some NAT and firewall configurations. For more information, see Working with NATs and Firewalls.

HTTP, TCP

Security Security is the ability to protect messages during transfer by supplying confidentiality, integrity, or authentication. Confidentiality protects a message from being examined, integrity protects a message from being modified, and authentication gives assurances about the sender or receiver of the message.

WCF supports transfer security both at the message level and transport level. Message security composes with a transport if the transport supports a buffered transfer mode. Support for transport security varies depending on the chosen transport. The HTTP, TCP, and named pipe transports have reasonable parity in their support for transport security.

All

Throughput Throughput measures the amount of data that can be transmitted and processed in a specified period of time. Like latency, the chosen transport can affect the throughput for service operations. Maximizing throughput for a transport requires minimizing both the overhead of transmitting content as well as minimizing the time spent waiting for message exchanges to complete. Both the TCP and named pipe transports add little overhead to the message body and support a native duplex shape that reduces the wait for message replies.

TCP, named pipe

Tooling Tooling represents third-party application support for a protocol for development, diagnosis, hosting, and other activities. Developing tools and software to work with the HTTP protocol signifies a particularly large investment.

HTTP

Choosing a transport

Nagaraj - WCF

Page 16: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Factor DescriptionEncoders that support this factor

Supported Character Sets

TextMessageEncodingBindingElement and MtomMessageEncodingBindingElement support only the UTF8 and UTF16 Unicode (big-endian and little-endian) encodings. If other encodings are required, such as UTF7, ASCII, etc. a custom encoder must be used. For a sample custom encoder, see http://go.microsoft.com/fwlink/?LinkId=119857.

Text

Inspection

Inspection is the ability to examine messages during transmission. Text encodings, either with or without the use of SOAP, allow messages to be inspected and analyzed by many applications without the use of specialized tools. Note that the use of transfer security, at either the message or transport level, affects your ability to inspect messages. Confidentiality protects a message from being examined and integrity protects a message from being modified.

Text

Reliability

Reliability is the resiliency of an encoder to transmission errors. Reliability can also be provided at the message, transport, or application layer. All of the standard WCF encoders assume that another layer is providing reliability. The encoder has little ability to recover from a transmission error.

None

SimplicitySimplicity represents the ease with which you can create encoders and decoders for an encoding specification. Text encodings are particularly advantageous for simplicity, and the POX text encoding has the additional advantage of not requiring support for processing SOAP.

Text (POX)

Size

The encoding determines the amount of overhead imposed on content. The size of encoded messages is directly related to the maximum throughput of service operations. Binary encodings are generally more compact than text encodings. When message size is at a premium, consider also compressing the message contents during encoding. However, compression adds processing costs for both the message sender and receiver.

Binary

Streaming

Streaming allows applications to begin processing a message before the entire message has arrived. Effectively using streaming requires that the important data for a message be available at the beginning of the message so that the receiving application is not required to wait for it to arrive. Moreover, applications that use streamed transfer must organize data in the message incrementally so that the content does not have forward dependencies. In many cases, you must compromise between streaming content and having the smallest possible transfer size for that content.

None

3rd Party Tool SupportSupport areas for an encoding include development and diagnosis. Third-party developers have made a large investment in libraries and toolkits for handling messages encoded in the POX format.

Text (POX)

Interoperability This factor refers to the ability of a WCF encoder to interoperate with non-WCF services.TextMTOM (partial)

How to Choose a Message Encoder

Nagaraj - WCF

Page 17: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Setting Description

None Specifies that the client does not need to present any credential. This translates to an anonymous client.

Basic Specifies basic authentication. For additional information, see RFC2617, "HTTP Authentication: Basic and Digest Authentication."

Digest Specifies digest authentication. For additional information, see RFC2617, "HTTP Authentication: Basic and Digest Authentication."

Ntlm Specifies Windows authentication using SSPI negotiation on a Windows domain.

SSPI negotiation results in using either the Kerberos protocol or NT LanMan (NTLM).

Windows Specifies Windows authentication using SSPI on a Windows domain. SSPI picks from either the Kerberos protocol or NTLM as authentication service.

SSPI tries Kerberos protocol first; if that fails, it then uses NTLM.

Certificate Performs client authentication using a certificate, typically X.509.

Transport Client Credential Types

Nagaraj - WCF

Page 18: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Mode Description None No security is provided at the transport layer or at the message

layer. None of the predefined bindings use this mode by default except the <basicHttpBinding> element or, when using code, the BasicHttpBinding class.

Transport Uses a secure transport such as HTTPS for integrity, confidentiality, and mutual authentication.

Message Uses SOAP-message security for integrity, confidentiality, and mutual authentication. SOAP messages are secured according to the WS-Security standards.

Mixed Mode

Uses transport security for integrity, confidentiality, and server authentication. Uses message security (WS-Security and other standards) for client authentication.

(This enumeration for this mode is TransportWithMessageCredential.)

Both Performs protection and authentication at both levels. This mode is available only in the <netMsmqBinding> element.

Transport Security Modes

Nagaraj - WCF

Page 19: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Nagaraj - WCF

Page 20: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Internet Unsecured Client and Service

The following illustration shows an example of a public, unsecured Windows Communication Foundation (WCF) client and service.

Nagaraj - WCF

Page 21: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Intranet Unsecured Client and Service

The following illustration depicts a simple Windows Communication Foundation (WCF) service developed to provide information on a secure private network to a WCF application.

Nagaraj - WCF

Page 22: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Transport Security with Basic Authentication

The following illustration shows a Windows Communication Foundation (WCF) service and client.

Nagaraj - WCF

Page 23: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Transport Security with Windows Authentication

The following scenario shows a Windows Communication Foundation (WCF) client and service secured by Windows security.

Nagaraj - WCF

Page 24: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Transport Security with an Anonymous Client

Nagaraj - WCF

Page 25: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Transport Security with Certificate Authentication

Nagaraj - WCF

Page 26: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Message Security with an Anonymous Client

Nagaraj - WCF

Page 27: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Message Security with a User Name Client

The following illustration shows an Windows Communication Foundation (WCF) service and client secured using message-level security. The service is authenticated with an X.509 certificate. The client authenticates using a user name and password.

Nagaraj - WCF

Page 28: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Message Security with a Certificate Client

Nagaraj - WCF

Page 29: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Message Security with a Windows Client

Nagaraj - WCF

Page 30: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Message Security with a Windows Client without Credential Negotiation

Nagaraj - WCF

Page 31: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Message Security with Mutual Certificates

Nagaraj - WCF

Page 32: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Nagaraj - WCF

Page 33: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Trusted Subsystem

Nagaraj - WCF

Page 34: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Protocol Specification and usage WSDL 1.1 Web Services Description Language (WSDL) 1.1

WCF uses Web Services Description Language (WSDL) to describe services.

XML Schema XML Schema Part 2: Datatypes Second Edition and XML Schema Part 1: Structures Second Edition

WCF uses the XML Schema to describe data types used in messages.WS Policy Web Services Policy 1.2 - Framework (WS-Policy)

Web Services Policy 1.5 - Framework

WCF uses the WS-Policy 1.2 or 1.5 specifications with domain-specific assertions to describe service requirements and capabilities.

WS Policy Attachments Web Services Policy 1.2 - Attachment (WS-PolicyAttachment)

WCF implements WS-Policy Attachments to attach policy expressions at various scopes in WSDL.

WS Metadata Exchange Web Services Metadata Exchange (WS-MetadataExchange) version 1.1

WCF implements WS-MetadataExchange to retrieve XML Schema, WSDL, and WS-Policy.

WS Addressing Binding for WSDL

Web Services Addressing 1.0 - WSDL Binding

WCF implements WS-Addressing Binding for WSDL to attach addressing information in WSDL.

Metadata Specifications and Usage

Nagaraj - WCF

Page 35: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

ClientCredential Property Description Notes

ClientCertificate Returns an X509CertificateInitiatorClientCredential

Represents an X.509 certificate provided by the client to authenticate itself to the service.

HttpDigest Returns an HttpDigestClientCredential

Represents an HTTP digest credential. The credential is a hash of the user name and password.

IssuedToken Returns an IssuedTokenClientCredential

Represents a custom security token issued by a Security Token Service, commonly used in federation scenarios.

Peer Returns a PeerCredential Represents a Peer credential for participation in a Peer mesh on a Windows domain.

ServiceCertificate Returns an X509CertificateRecipientClientCredential

Represents an X.509 certificate provided by the service in an out-of-band negotiation.

UserName Returns a UserNamePasswordClientCredential

Represents a user name and password pair.

Windows Returns a WindowsClientCredential Represents a Windows client credential (a Kerberos credential). The properties of the class are read-only.

Setting a <clientCredentials> Value in Code

Nagaraj - WCF

Page 36: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Scenario Site bindings Application path Base application URIs

HTTP Only http: *:80:* /appTwo http://localhost/appTwo/

Both HTTP and Non-HTTP

http: *:80:*

net.tcp: 808:*

/appTwo http://localhost/appTwo/net.tcp://localhost/appTwo/

Non-HTTP only net.pipe: * /appThree net.pipe://appThree/

The following table illustrates several possible addressing scenarios for WAS sites with both HTTP and non-HTTP site bindings

Nagaraj - WCF

Page 37: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Nagaraj - WCF

Page 38: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Queued communication conceptual model

Queued communication in a typical deployment scenario

Nagaraj - WCF

Page 39: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Queued communication showing separate transactions for capture and delivery

Nagaraj - WCF

Page 40: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

COM+ attribute WCF attributes

RequiresNew TransactionFlowAttribute is set to NotAllowed.TransactionScopeRequired is true.

The TransactionFlow attribute in the binding element is false.

Required TransactionFlowAttribute is set to Allowed.TransactionScopeRequired is true.

The TransactionFlow attribute in the binding element is true.

Supported There is no direct equivalent. In general, you should adopt the behavior specified for Required instead.

NotSupported TransactionScopeRequired is false.The TransactionFlow attribute in the binding element is false.

Disabled There is no direct equivalent. In general, you should adopt the behavior specified for NotSupported instead.

Comparing Transactions in COM+ and ServiceModel

Nagaraj - WCF

Page 41: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Nagaraj - WCF

Page 42: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Category of Differences DataContractJsonSerializer ASP.NET AJAX JavaScriptSerializer

Deserializing the empty buffer (new byte[0]) into Object (or Uri, or some other classes).

SerializationException null

Serialization of Value {} (or {"__type":"#System"}) Null

Serialization of the private members of [Serializable] types.

serialized not serialized

Serialization of the public properties of ISerializable types.

not serialized serialized

"Extensions" of JSON Adheres to the JSON specification, which requires quotes on object member names ({"a":"hello"}).

Supports the names of object members without quotes ({a:"hello"}).

DateTime Coordinated Universal Time (UTC)

Does not support format "\/Date(123456789U)\/" or "\/Date\(\d+(U|(\+\-[\d{4}]))?\)\\/)".

Supports format "\/Date(123456789U)\/" and "\/Date\(\d+(U|(\+\-[\d{4}]))?\)\\/)" as DateTime values.

Representation of dictionaries An array of KeyValuePair<K,V>, handles key types that are not strings.

As actual JSON objects - but only handles key types that are strings.

Escaped characters Always with an escape forward slash (/); never allows un-escaped invalid JSON characters, such as "\n".

With an escape forward slash (/) for DateTime values.

The significant differences between different serializers are summarized in the following table

Nagaraj - WCF

Page 43: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

NET Types JSON/Javascript Notes

All numeric types, for example Int32, Decimal or Double

Number Special values such as Double.NaN, Double.PositiveInfinity and Double.NegativeInfinityare not supported and result in invalid JSON.

Enum Number See "Enumerations and JSON" later in this topic.

Boolean Boolean --

String, Char String --

Timespan, Guid, Uri String The format of these types in JSON is the same as in XML (essentially, TimeSpan in the ISO 8601 Duration format, GUID in the "12345678-ABCD-ABCD-ABCD-1234567890AB" format and URI in its natural string form like "http://www.example.com"). For precise information, see Data Contract Schema Reference.

XmlQualifiedName String The format is "name:namespace" (anything before the first colon is the name). Either the name or the namespace can be missing. If there is no namespace the colon can be omitted as well.

Array of type Byte Array of numbers Each number represents the value of one byte.

Datetime DateTime or String

See Dates/Times and JSON later in this topic.

DatetimeOffset Complex type See Dates/Times and JSON later in this topic.

XML and ADO.NET types (XmlElement, XElement. Arrays of XmlNode,

ISerializable,

DataSet).

String See the XML Types and JSON section of this topic.

DBNull Empty complex type

--

Collections, dictionaries, and arrays Array See the Collections, Dictionaries, and Arrays section of this topic.

Complex types (with the DataContractAttribute or SerializableAttribute applied)

Complex type Data members become members of the Javascript complex type.

Complex types implementing the ISerializable interface)

Complex type Same as other complex types but some ISerializable types are not supported – see the ISerializable Support part of the Advanced Information section of this topic.

Null value for any type Null Nullable types are also supported and map to JSON in the same way as non-nullable types.

Mapping .NET types to JSON Types

Nagaraj - WCF

Page 44: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Nagaraj - WCF

Page 45: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

The following illustration shows how a message is secured on the client when using the Message security mode

Nagaraj - WCF

Page 46: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

The following illustration shows the processes that occur when a secure message is extracted from the wire and verified on the receiving side:

Nagaraj - WCF

Page 47: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Nagaraj - WCF

Page 48: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Nagaraj - WCF

Page 49: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

The following diagram compares the channel stack with other communication stacks, for example TCP/IP.

Nagaraj - WCF

Page 50: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

The Channel Object Model

Nagaraj - WCF

Page 51: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Nagaraj - WCF

Page 52: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Dispatchers

Nagaraj - WCF

Page 53: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Nagaraj - WCF

Page 54: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

The following diagram shows the main classes used, the classes they inherit from (shown by an upward-pointing arrow), and the return types of certain methods and properties.

Nagaraj - WCF

Page 55: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

The following diagram shows the classes involved in the custom binding, and how the custom identity verifier is linked

Nagaraj - WCF

Page 56: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Resource Description

Microsoft Distributed Transaction Coordinator (MSDTC)

Required to support OleTx transactions.

Message Queuing (MSMQ) Required to support reliable messaging.

Internet Information Services (IIS)

Required if you want to use IIS to host your application.

Windows Process Activation Service (WAS)

Required if you want to use WAS to host your application.

Operating System Resources Required by WCF

Nagaraj - WCF

Page 57: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Tool Description

ServiceModel Metadata Utility Tool (Svcutil.exe) Generates service model code from metadata documents and metadata documents from service model code.

Find Private Key Tool (FindPrivateKey.exe) Retrieves the private key from a specified store.

ServiceModel Registration Tool (ServiceModelReg.exe) Manages the registration and un-registration of ServiceModel on a single machine.

COM+ Service Model Configuration Tool (ComSvcConfig.exe)

Configures COM+ interfaces to be exposed as Web services.

Configuration Editor Tool (SvcConfigEditor.exe) Creates and modifies configuration settings for WCF services.

Service Trace Viewer Tool (SvcTraceViewer.exe) Helps you view, group, and filter trace messages so that you can diagnose, repair, and verify issues with WCF services.

WS-AtomicTransaction Configuration Utility (wsatConfig.exe)

Configures basic WS-AtomicTransaction support settings using a command line tool.

WS-AtomicTransaction Configuration MMC Snap-in Configures basic WS-AtomicTransaction support settings using a MMC snap-in.

WorkFlow Service Registration Tool (WFServicesReg.exe) Registers a Windows Workflow service.

WCF Service Auto Host Hosts WCF services contained in libraries (*.dll) files

WCF Test Client A GUI tool that allows you to input parameters of arbitrary types, submit that input to the service, and view the response the service sends back.

The following table lists some tools and provides their brief description.

Nagaraj - WCF

Page 58: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Element Description

<behaviors> This element defines two child collections named endpointBehaviors and serviceBehaviors. Each collection defines behavior elements consumed by endpoints and services respectively. Each behavior element is identified by its unique name attribute.

<bindings> This element holds a collection of standard and custom bindings. Each entry is identified by its unique name. Services use bindings by linking them using the name.

<client> This element contains a list of endpoints a client uses to connect to a service.

<comContracts> This element defines COM contracts enabled for WCF and COM interop.

<commonBehaviors> This element can only be defined in the machine.config file. It defines two child collections named endpointBehaviors and serviceBehaviors. Each collection defines behavior elements consumed by all WCF endpoints and services on the machine respectively. If a behavior is defined in both <commonBehaviors> and <behaviors> sections, the behavior in the <behaviors> section is given preference.

<extensions> section This element contains a collection of extensions, which enable the user to create user-defined bindings, behaviors, and other aspects of extensions.

<diagnostics> This element contains settings for the diagnostics features of WCF. The user can enable/disable tracing, performance counters, and the WMI provider, and can add custom message filters.

<serviceHostingEnvironment> This element defines what type the service hosting environment instantiates for a particular transport. If this section is empty, the default type is used.

<services> The element contains a collection of services. For each service defined in the assembly, this element contains a service element specifying settings for the service.

<system.serviceModel> Child Elements

Nagaraj - WCF

Page 59: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Nagaraj - WCF

Page 60: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

The following table summarizes some of the key benefits and scenarios associated with each of the hosting options.

Hosting Environment Common Scenarios Key Benefits and Limitations

Managed Application ("Self-Hosted") Console applications used during development.

Rich WinForm and WPF client applications accessing services.

Flexible. Easy to deploy. Not an enterprise solution for services.

Windows Services (formerly known as NT services)

A long-running WCF service hosted outside of IIS.

Service process lifetime controlled by the operating system, not message-activated.

Supported by all versions of Windows. Secure environment.

IIS 5.1, IIS 6.0 Running a WCF service side-by-side with ASP.NET content on the Internet using the HTTP protocol.

Process recycling. Idle shutdown. Process health monitoring. Message-based activation. HTTP only.

Windows Process Activation Service (WAS) Running a WCF service without installing IIS on the Internet using various transport protocols.

IIS is not required. Process recycling. Idle shutdown. Process health monitoring. Message-based activation. Works with HTTP, TCP, named pipes, and

MSMQ.

IIS 7.0 Running a WCF service with ASP.NET content.

Running a WCF service on the Internet using various transport protocols.

WAS benefits. Integrated with ASP.NET and IIS content.Nagaraj - WCF

Page 61: WCF Architecture Nagaraj - WCF - WordPress.comWeb services that enables HTTP cookies to be used to exchange context. NetTcpContextBinding  A secure and

Hosting Environment Platform Availability Transports Supported Process and AppDomain Recycling

Managed Applications ("Self-Hosted")

Windows XP, Windows Server 2003, Windows Vista,Windows Server 2008

HTTP, net.tcp, net.pipe, net.msmq

No

Windows Services (formerly known as NT services)

Windows XP, Windows Server 2003, Windows Vista,Windows Server 2008

HTTP, net.tcp, net.pipe, net.msmq

No

IIS 5.1 Windows XP HTTP Yes

IIS 6.0 Windows Server 2003 HTTP Yes

Windows Process Activation Service (WAS)

Windows Vista, Windows Server 2008

HTTP, net.tcp, net.pipe, net.msmq

Yes

Nagaraj - WCF