Share via


Messaging in the .NET Compact Framework

The subset of Windows Communication Foundation (WCF) that is implemented in the .NET Compact Framework provides a unified programming model for building message-oriented applications. It enables developers to build secure messaging applications that work across platforms and that support interaction with existing WCF services on the desktop.

Note

WCF is supported in the .NET Compact Framework version 3.5 and later versions.

Architecture

The WCF messaging layer for the .NET Compact Framework is modeled after the standard desktop WCF architecture. The messaging layer is supported on the device and enables the device to connect to an existing WCF service on the desktop. The service run-time layer is not present on the device.

The following illustration shows the channel stack, associated protocols, and WCF binding elements.

WCF messaging layer on the .NET Compact Framework

Messaging layer for WCF in .NET Compact Framework

Support for the WS-Security version 1.0 specification includes SOAP message security using X.509 certificates.

The Message class is built on the WS-Addressing standard.

Differences with the Desktop Implementation

The .NET Compact Framework does not support the full set of protocols and bindings that are supported on the desktop. See the architecture diagram in the previous section for more information about specific protocols and bindings that are supported.

The service run-time layer is not supported on the .NET Compact Framework. As a result, if you want to connect to an existing WCF service on the desktop, the following considerations apply:

  • Some settings in the Web.config file must be changed. For more information, see How to: Use the HTTP Transport.

  • If you want to add device support for System.ServiceModel contracts, you can use the .NET Compact Framework ServiceModel Utility tool (NetCFSvcUtil.exe) to generate a WCF client proxy. This tool implements support for many contract parameters in the .NET Compact Framework. NetCFSvcUtil.exe is included in the Power Toys for .NET Compact Framework. For more information, see Power Toys for .NET Compact Framework.

  • If you do not use NetCFSvcUtil, you can use the WCF ServiceModel Desktop Utility tool (SvcUtil.exe) and post-process the generated code. In this scenario, you have to remove the unsupported System.ServiceModel attributes from the generated code. For more information about these modifications and an example, see How to: Use the HTTP Transport.

Additionally, a subset of the WCF messaging types and members in the full .NET Framework are supported.

The next section describes the differences that are specific to WCF security features.

Security

WCF messaging in the .NET Compact Framework supports SOAP message security, which corresponds to a subset of the WS-Security features and is based on X.509 certificates. WS-Security is an application layer you can place on top of any supported transport. The security binding elements that are supported in WCF messaging are SecurityBindingElement and AsymmetricSecurityBindingElement. To implement security features, you must pass the X.509 certificates inside a ClientCredentials object as a parameter in the constructor for the WCF client proxy.

Transport-level security is also supported for WCF in the .NET Compact Framework. This includes support for HttpsTransportBindingElement and BasicHttpSecurity.

The implementation of WCF security in the .NET Compact Framework differs from the implementation on the desktop in the following ways:

Note

During the extended daylight saving times, outgoing messages that use message security will fail because of a timestamp validation error when the default timestamp validation of five minutes is in effect. The extended daylight saving times occur between the second Sunday in March and the first Sunday in April, and also between the last Sunday in October and the first Sunday in November. To resolve this issue, install the Daylight Saving Time (DST) 2007 Update. This does not apply to devices that are running Windows Mobile 5.0 build 15096.3.0 and later, or Windows Mobile 6.0 and later.

Deployment

The WCF messaging DLLs are delivered in the .NET Compact Framework CAB files. The managed assemblies are installed in the global assembly cache.

The WCF messaging DLLs for the device include the following:

  • System.ServiceModel.dll

  • System.Runtime.Serialization.dll

Deployment also includes the deployment of the WCF Exchange Server mail transport. For more information about device and desktop deployment, see WCF Exchange Server Mail Transport.

Logging

WCF on the desktop .NET Framework supports three types of logging: trace, messaging, and event logging. WCF on the .NET Compact Framework supports only trace logging to track code exceptions, but it does not log warning and error messages. A registry key is used to configure logging.

To log WCF information, you must first enable logging for the .NET Compact Framework. For more information about how to enable logging and how to enable the WCF trace log, see How to: Create Log Files.

See Also

Concepts

Log File Information

Other Resources

Windows Communication Foundation (WCF) Development and the .NET Compact Framework