Categories

mcts 70-529 notes

Chapter 1 – Creating Web Services

  • Create web service or web application project.
  • Set namespace to something unique. Do not change after go-live.
  • Attributes: WebService, WebServiceBinding, WebMethod, SoapDocumentMethod, SoapRpcMethod.
  • Web method options: EnableSession, CacheDuration, BufferResponse, TransactionOption.
  • Web service help page.
  • Debugging.

Chapter 2 – Extending Web Services

  • Add a web reference to VS project.
  • SOAP 1.1: XML 1.0, only HTTP post, prefix: ‘<soap:’.
  • SOAP 1.2: XML Infoset, HTTP post and get, prefix: ‘<soap12:’.
  • Soap formatting options
    • Style: formats the body of the message – RPC | Document.
    • Use: formatting for the parameters and return values – Literal | Encoded.
  • SoapParameterStyle to format parameters: ?, Default, Wrapped.
  • WebServiceBinding to declar conformity.
  • Use XmlElement attributes to control serializing behaviour of your classes.
  • Soap header is optional when data sent from client to web service. Typically used for user credentials.
  • Custom header is implemented by inheriting from System.Web.Services.Protocols.SoapHeader.
  • Soap extension can modify XML data before being mapped to .NET object or to execute code in general.
  • Inherit System.Web.Protocols.SoapExtension.

ProcessMessage has Stage property: BeforeSerializing, AfterSerialize, BeforeDeserialize, AfterDeserialze.

Chapter 3 – Configuring and Publishing Web Services

  • State management: Application, Session, Cookie.
  • Cookie state requires CookieContainer on client side.
  • webServices section in web.config: Protocls, SoapExtensionImporterTypes, SoapExtensionRefelctionTypes, wsdlHelpGenerator.
  • Session state section: mode, timeout…
  • Call web service with ?Disco to get discovery document.
  • Create your own discovery file or use dynamic discovery.
  • Deployment via xcopy or setup project or copy website from context menu.

Chapter 4 – Creating Remoting Server Applications

  • Remoting is to call objects located on other processes or machines.
  • To implement remoting derive from MarshalByRefObject, host in some .NET application and register a channel.
  • Hosting on IIS can also expose the remoting object as web service.
  • Proxy object.
  • Types: Single call, Singleton, Client-activated.
  • Channels
    • Registered per application domain.
    • Types: TCP, HTTP, IPC.
    • TCP and binary formatter is the fastest.
  • Object is passe by reference unless marked as serializable.
  • RemotingConfiguration and RemotingServices to register a channel.
  • Set application name: RemotingConfiguration.
  • Register object with DLL versin number for versioning.
  • Set channelname property when using more thatn one channel of same type.
  • Remoting can be configurable either in web.config or by explicitly loading the config file: RemotingConfiguration.Configure.
  • Important items: Application, lifetime, channels, service, soapInterop, wellKnown, formatter.

Chapter 5 – Creating Remoting Client Applications

  • MBV: remote object is copied local to client application, better performance, no access to server resources.
  • MBR: is accessed viw proxy object on client, worse performance, full access to server resources.
  • See www.w3.org/Adressing for details on URLs.
  • Configure a remoting client application programatically with System.Runtime.Remoting.
  • Sinks are points of de-/serialization.
  • HttpClientChannel to open a channel and register it with ChannelServices.RegisterChannel.
  • Add a reference to DLL containing the remote object.
  • Typical constellations: HTTP and Soap, TCP and Binary, IPC and Binary.
  • Server activated objects can be registered with the WellKnownClientTypeEntry and RemotingConfiguration.RegisterWellKnownClientType.
  • Client activated object by RemotingConfiguration.RegisterActivatedClientType.
  • <system.runtime.remoting> to configure client.
  • Use new operator on Activator.GetObject to use a remote object.

Chapter 6 – Debugging and Deploying Remoting Applications

  • Hosting remote objects: console application, winforms application, windows service, web application.
  • Deploying: Assembly, interface, soapsuds: meta assembly, WSDL source or assembly.
  • You can use a web setup project to deploy an IIS hosted remote object.
  • Attach to hosting proces for debugging.
  • RemotingException is used by remoting.
  • Remoting performance counters.
  • ITrackingHandler to log remote object behaviour and other purposes.
  • Lease object on server is a proxy object to avoid that the remote object is garbage collected.
  • Lease is configured in IntializeLifetimeService method of remote object or using the lifetime configuration section.

Chapter 7 – Method Invocations and Event Management with .NET Web Services

  • .NET web services allow you to expose data to outside consumers as XML.
  • Visual Studio creates proxy class for web service reference. Gives type-safe access to web service and abstracts from all underlying XML.
  • Web methods can be called sync or async.
  • The OneWay attribute can be used for fire-and-forget behaviour.
  • For two-way async methods: Polling or callback.

Chapter 8 – Method Invocations and Event Management with .NET Remoting

  • Remoting methods can be invoked sync or async.
  • The OneWay attribute to fire-and-forget. Will not return any exceptions occured on the host.
  • Async method invocation: Use a delegate with matching signature.
  • Event management: Event handling requires two-way communication. To implement this the event class must be in a shared assembly referenced by both client and host. Than event handling works as in non-remoting applications.

Chapter 9 – WSE 3.0

  • WSE provides enhancements for extended web service functionality.
  • Builds on the various WS-* specifications.
  • WebServicesClientProtocol is base class for WSE enabled proxies – instead of the SoapHttpClientProtocol.
  • WSE uses configuration file and has a nice editor (WseConfigEditor3) to change the configuration settings.

Chapter 10 – WSE Security

  • Use digital signatures for authentication and message integrity.
  • Supports message encryption.
  • By default, only the body in encrypted.
  • Symmetric encryption: Uses a shared private key between client and host.
  • Asymmetric encryption: Uses a public/private key pair. Message is encrypted with public key and can only be decrypted with private key.
  • IssueSecurityContextTokenRequest method of the SecurityContextTokenService class to access the RequestSecurityToken and RequestSecurityTokenResponse elements of a request.
  • Use the mappings element to specify endpoints.
  • A policy file must contain at least: mappings, endpoint and default operation elements.
  • Use the fileName attribute in web.config policy element to point to a custom configuration file.
  • The following can be configured by the protection element: request, response and fault.
  • WseConfigEditor can be used from Visual Studio or as stand-alone tool.
  • You can manage custom policies with WseConfigEditor via the policy tab.
  • Four authentication modes: Anonymous, Windows, Certificate and Username.

Chapter 11 – Messaging and Routing

  • WSE messaging can use binary formatters.
  • SoapSender and SoapReceiver class for one-way messaging.
  • Receivers are implemented as HTTP handlers.
  • SoapClient and SoapSender for two-way messaging.
  • MTOM to send binary data.
  • WSE router is a web service that redirects validated requests to the real web service.
  • SoapHttpRouter is added as HTTP handler.
  • Referral cache is a XML file that stores all routing information.
  • Security credentials added to the proxy do not work with a WSE router. You need to use WSE security.
  • Use X509SecurityToken/UsernameToken/UsernameOverTransport or AnonymousOver509 and one security policy
  • Policy can be defined in code or XML.

Chapter 12 – Creating Serviced Components

  • Enterprise Services provide distributed transactions, object pooling, JIT activation and messaging.
  • Microsoft Transaction Server (MTS) is equivalent to COM+ (MTS 2.0). Has strange naming.
  • Enterprise Services is the next generation of COM+.
  • Serviced Components are used to access Enterprise Services functionality.
  • Can be provided as a Soap service.
  • Create serviced components: Inherit ServicedComponent, make ComVisible, choose COM+ activation, strongly name assembly.
  • Can be registered via Component Services MMC, service installation tool, dynamic registration or MSI package.
  • Microsoft DTC for transactions
    • Transaction attribute on class level.
    • AutoComplete attribute on method.
  • Object pooling class attribute.
  • JustInTimeActivation class attribute.
  • Queuing with MSMQ via the InterfaceQueuing attribute on class and assembly.
  • Security has it’s own role modell which is not connected to a Windows group.
  • Enterprise Services can alternatively be accessed via ServiceConfig class instead of creating a Service Component. But that does not provide object pooling and queued components.
  • Serviced Components can be consumed like any other assembly except for queued components.

Chapter 13 – Serviced Component Management

  • Message queuing for better performance and availibility.
  • Private queues are not listed in AD. Use ‘\private$’ modifier.
  • Public queues, journal queues.
  • Setting up a queue: Compmgmt.msc or programatically (System.Messaging).
  • MessageQueue.Label sets/gets the name of it.
  • Message object represents a message.
  • Express (in ram) vs. recoverable (on disk) messaging.
  • Aging: TimeToReachQueue, TimeToBeReceived, UseDeadLetterQueue.
  • Dead letter queue behaves differently depending on whether transactions are used or not.
  • Transactions: Single or MTS.
  • BinaryMessageFormatter to send objects.
  • Receiving: Polling, async or via triggers (requires wrapped assembly or command line with parameters).
  • Serviced Component that uses Messaging: ComVisible and InterfaceQueuing attributes, interface and implementation, assembly attributes for COM+ registration.
  • Access rights to queue can be set programatically or via UI.
  • Peeking and message enumeration.
  • Correlating messages to receive an acknowledgement for a sent message.
  • Use makecert tool to create a personal certificate.
  • Signing a message: Either with SID when using AD or X509 certificate.
  • Queue can accept encrypted and/or non-encrypted messages.
  • Encryption requires Microsoft Base Cryptographic Provider 1.0 on all involved machines.

Learning points

  • Marshal-by-Value: Remote objects inherit the MarshalByRefObject and are passed as reference. When the class is marked as [Serializable] the remote object is passed as an exact copy. Marshal-by-Reference objects execute on the host while marshal-by-value objects execute on the client.
  • Web service discovery: ‘.vsdisco’ for dynamic discovery that allows all web services on that level and below to be discovered. ‘.disco’ for static discovery. You can reference vsdisco ‘files’ in a disco file on higher level to ensure that only certain web service applications are discovered automatically.
  • Static discovery: Can be auto-generated with ?DISCO parameter. Has contractRef, discoveryRef and schemaRef elements.
  • Dynamic discovery: Is implemented by an HTTP handler, the DiscoveryRequestHandler.
  • Web service style and use: Typical combinations are: Document/Literal vs RPC/Encoded.
    • Style RPC: Requires called method name and parameters in the SOAP body element. Document does not.
    • Use Literal: Each message part references a concrete schema definition (such as a complex type). The type for parameters can be referenced in message body.
    • Use Encoding: Each message part references an abstract type. The type for parameters must be referenced in message body.
  • Soap Extensions: Group 0 is executed before Group 1. Within the same group the extension with the lower Priority value is executed first.
  • Remoting event: To expose an event to a remoting client it must be implemented in a separate assembly, common to client and host, in a MarshalByRef class.
  • Web service: The WebService base class is optional as well as the WebService attribute. Minimum requirements are public method with WebMethod attribute.
  • Web service authentication: When not using SSI you can set a kerberos token with SetClientCredential on the proxy class.
  • MSMQ triggers: To be able to run two action simultaneously you have to specify two triggers. Each rule can fire one action.
  • Web service without IIS: Use a custom application with a SoapReceiver. Uses WSE messaging and requires only to register a HTTP handler.
  • MSMQ: Purge method removes all unread message from queue.
  • Web Service Bindings: Bindings must be declared on the web service and not on the particular web method. The attribute on web method only refers to which binding is being used.
  • Remoting: MarshalByRefObject.GetLifetimeService method returns ILease object to control lifetime.
  • Web service SOAP header: Policy(Type) attribute to require a certain SOAP header for a web method.
  • Web service SOAP header: Use SoapHeader("MemberName") attribute to map an incoming header to member.
  • Remoting: Client (activated) vs. server (wellknown) activated remote object. Client activated objects have full state just as non-remoting objects.
  • Remoting: MBV objects are executed locally to the caller. Eg. a MBV event handler for an event on a remote object is executed on the server. Like-wise, a MBR event handler on the client.
  • Messaging: SoapReceiver to receive web service calls over tcp (one-way). SoapClient for two-way messaging.
  • Web service: Unknown SoapHeader have DidUnderstand=false as default. This throws an exception on an incoming unknown header.
  • Web service: Documentation protocol to display help page for a web service.