Windows Communications Foundation: Integrating COM+ and

Download Report

Transcript Windows Communications Foundation: Integrating COM+ and

Windows Communication Foundation:
Integrating COM+ and MSMQ Applications
Andy Milligan
COM305
Program Manager
Microsoft Corporation
1
Agenda
Integration degrees and motivations
Illustrated scenarios
Exposing COM+ applications as WCF services
Consuming services in COM
WCF client using an MSMQ receiver
MSMQ client sending to WCF services
Summary
Questions
2
Degrees Of Integration
Wire-level interoperability
WCF services and clients interoperate with ASMX, WSE and
WebSphere services and clients using WS-* protocols
Product level integration
WCF includes feature level support for integrating
COM and COM+ applications with other WCF applications
WCF includes feature level support for MSMQ to integrate with
existing MSMQ applications
Company X may implement WCF channels to enable integration
between WCF and a technology Y
Code Migration
Migrating COM+ components to WCF enables most effective
integration with new WCF applications
3
Integration Motivations
Deployed LOB logic
Core asset of the business
Duplication is often unacceptable
Lengthy application lifecycle
Stability is key
Utility throttled by proprietary access
Goal of integration:
provide the benefits of SO without outweighing
the cost of adoption
4
Application Scenario
5
COM+ App As A WCF Service
Scenario:
You need to access COM+ business logic
from web service clients
Solution:
Use WCF’s COM+ Integration to expose
endpoints for your COM+ component
interfaces
Provides:
An interoperable, secure, reliable, transacted
web service access over a choice of
transports
6
COM+ App As a WCF Service
Approach
Run ComSvcConfig specifying the application interface
Metadata examination: type library & catalog
Creates a default .config and host
Modify generated .config file as required
Start application and WCF service starts
Contract reflected from type library
Behavior driven from config
ComSvcConfig.exe /install
/application:BookSample
/contract:BookLogic.Finance,IFinance
/hosting:complus
/mex
7
COM+ App As A WCF Service
8
A WCF Service
[ServiceContract]
WCF source
public interface IFinance
{
[OperationContract]
ServiceHost
ServiceDescription
[TransactionFlow(TransactionFlowOption.Allowed)]
Address:http://myservice/IFinance.svc
bool ValidateCardNumber(string CCNumber); Binding
}
Name:WSHttpBinding
[OperationContract]
Contract
[TransactionFlow(TransactionFlowOption.Allowed)]
Operation[0]
int ChargeCard(string Name, string Number, float
Amount);
Name:ValidateCardNumber
<configuration xmlns="…">
WCF .config
<system.serviceModel>
<services>
<service type="Lucerne.FinanceService"
<endpoint address="“
binding="wsHttpBinding“
bindingConfiguration="Binding1“
contract="Lucerne.IFinance" />
</service>
</services>
</system.serviceModel>
</configuration>
SyncMethod:params
Behaviors:TransactionFlowAttribute:Allowed
Operation [1]
Name:ChargeCard
SyncMethod:params
Behaviors:TransactionFlowAttribute:Allowed
9
A COM+ Integration WCF Service
[
uuid(5D9A0467-AFFE-3250-988D-24B439686656),
COM contract
[typelib + catalog]
]
interface IFinance : IDispatch {
HRESULT ValidateCardNumber(
[in] BSTR CCNumber,
[out, retval] VARIANT_BOOL* pRetVal);
HRESULT ChargeCard(
[in] BSTR Name,
[in] BSTR Number,
[in] single Amount,
[out, retval] long* pRetVal);
};
ServiceDescription
<configuration xmlns="…">
WCF .config
<system.serviceModel>
<services>
<service type="Lucerne.FinanceService"
<endpoint address="“
binding="wsHttpBinding“
bindingConfiguration="Binding1“
contract="Lucerne.IFinance" />
</service>
</services>
</system.serviceModel>
</configuration>
ServiceHost
Address:http://myservice/IFinance.svc
Binding
Name:WSHttpBinding
Contract
Operation[0]
Name:ValidateCardNumber
SyncMethod:params
Behaviors:TransactionFlowAttribute:Allowed
Operation [1]
Name:ChargeCard
SyncMethod:params
Behaviors:TransactionFlowAttribute:Allowed
10
COM+ App As A WCF Service
The provided service
Canonical mapping
COM class  service
COM interface  service contract
COM interface methods  operation contract
Service configuration:
NetNamedPipeBinding or WSHttpBinding
WS-Security – think up to “PacketPrivacy”
WS-RM for session lifetime
OLE-Tx, with WS-AT as required
11
COM+ App As A WCF Service
Server: COM+
App C
App B
Client
App A
Component Y
Component X
Interface 1
Interface 2
DCOM
WS-* messages
Client
Endpoint
ServiceModel
Initializer
Endpoint
App
.config
Catalog
COM+ hosted:
Remains accessible from DCOM
No message based activation
12
COM+ App As A WCF Service
Server: COM+
App C
App B
Client
App A
Component Y
Component X
Interface 1
Interface 2
DCOM
IIS / WAS
WS-* messages
Client
Endpoint
Endpoint
web
.config
Web hosted:
Remains accessible from DCOM
Message based activation, cross-process
Catalog
13
COM+ App As A WCF Service
Server: COM+
App C
App B
App A
IIS / WAS
WS-* messages
Client
Component Y
Endpoint
Endpoint
Component X
Interface 1
Interface 2
web
.config
Web hosted in-proc:
Message based activation
All in process
Catalog
14
COM+ App As A WCF Service
Considerations
WCF integration versus COM+ 1.5 “Uses SOAP”
Integration is done on a per interface basis.
No overhead for apps which don’t opt in
Object reference passing not supported
COM+ context does not flow
Wizard view
15
Consuming Services In COM
Scenario:
Services are proliferating and you still have
COM based clients
Solution:
Use WCF’s COM “service” moniker to
communicate with service endpoints
Provides:
An approachable COM specific syntax for
accessing web services with WS-* support
over multiple transports
16
Consuming Services In COM
Approach
SvcUtil can compile a COM-visible proxy assembly
.NET Framework 2.0 and WinFX / WCF runtime required
Optimized for managed clients with COM-Interop limitations
Use “service” moniker syntax to specify service address,
binding and contract
Typed contract
WSDL contract
Metadata Exchange contract
IChannelCredentials for SSPI, username / password, x509
17
COM Client Integration
Service moniker: Typed
Scenario:
You want to extend a Visual Basic 6.0 application to retrieve
current stock levels
You have full control over deployment
Solution:
Typed moniker for IntelliSense
Address & binding name in moniker string
Build local assembly for contract (SvcUtil)
Binding defined in app.config
Dim monikerProxy as IRetailProxy
set monikerProxy = GetObject("service:address=http://myServer/TestService/,
binding=wsProfileBinding")
currStock = monikerProxy.GetStockLevel("ID:223")
18
COM Client Integration
Service moniker: WSDL
Scenario:
You want to distribute a document including current web service
results
Registering app specific proxies can be tough
Solution:
WSDL Service moniker
Entirely self contained with no app-specific registration
Address, binding and contract are in the code
wsdlStr = "<xml ... "
Set monikerProxy =
GetObject("service:address=http://myServer/TestService/,
wsdl='" & wsdlStr & "',
binding=wsProfileBinding,
contract=IWarehouse")
currStock = monikerProxy.GetStockLevel("ID:223")
19
COM Client Integration
Service moniker: Metadata Exchange
Scenario:
You want to distribute a document including current web service
results
Registering app specific proxies can be tough
Solution:
MEX moniker
Address, binding and contract are retrieved at runtime
Optional overrides for address & binding
Set monikerProxy =
GetObject("service:mexAddress=http://myServer/myService.svc/mex,
mexBindingSectionName=customBinding,
mexBindingConfiguration=myCustomBinding,
contractName=IFinance,
contractNamespace=http://contoso.com/fooServices,
bindingName=Binding1,
bindingNamespace=http://contoso.com/Bindings")
currStock = monikerProxy.GetStockLevel("ID:223")
20
Consuming Services In COM
21
WCF Queuing Channels
Overview
Transport channel
Intended for exchanging queued messages
between WCF applications
SOAP within MSMQ message
Supports new WCF queue addressing scheme
Integration channel
Intended for exchanging queued messages
between legacy MSMQ and WCF applications
Classic MSMQ message
Supports all legacy MSMQ addressing and
protocol schemes
22
WCF Client To MSMQ Receiver
Scenario
Key business processes are at the other end of an
MSMQ queue. WCF clients need to send message to
the queue to be processed by deployed MSMQ
receiver
Solution:
Use WCF’s MSMQ integration channel
Provides:
Integrates WCF clients with existing MSMQ
applications without modification
Places classic MSMQ message on the wire
Same infrastructure, same management, same receiver code
23
WCF Client To MSMQ Receiver
WCF Client
WCF
App
.config
MSMQ Receiver
Integration Channel
MSMQ
QM to QM transfer
MSMQ
Queue Manager
Queue Manager
Store
Store
MSMQ
24
Integrating WCF With An
MSMQ Application
25
MSMQ Client To WCF Receiver
Scenario:
Services are proliferating and you wish to call from
deployed MSMQ clients
Solution:
Use WCF’s MSMQ integration channel to
communicate with service endpoints
Provides:
Integrates existing MSMQ clients with WCF services
Sender sends message same as it always did
WCF service can consume classic MSMQ messages
from the wire
Messages arriving in the queue are converted to SOAP
messages and dispatched to the operationcontract by the
channel
26
MSMQ Client To WCF Receiver
MSMQ Client
WCF Receiver
MSMQ
App
.config
Integration Channel
WCF
QM to QM transfer
Queue Manager
MSMQ
Queue Manager
Store
Store
MSMQ
27
WCF MSMQ Integration
Considerations
Caveats to consider
MSMQ channels don’t support peek
Sending COM objects in message body to Indigo apps
will not be supported
MSMQ Vista enhancements
Poison message handling for MSMQ
Per application error queue
WCF services can receive messages transactionally
across the network
28
Summary
Microsoft is committed to leveraging
existing investments
Integration is baked into the WCF runtime
ComSvcConfig for COM+
Service moniker for COM
Continued use of MSMQ transport
With existing apps you are off to a fine start
Adopting WCF can be low impact,
incremental and alongside migration
29
Community Resources
At PDC
For more information, go see
COM312 - WCF: Writing Secure Distributed Applications (Wed 1:45pm)
COM307 - WCF: Writing Reliable and Transacted Distributed Applications (Wed 3:15pm)
COM308 - WCF: Developing Manageable Web Services (Wed 5:00pm)
Labs: COMHOL26: Legacy Integration
Ask The Experts table: WCF
COM Track lounge: I’ll be there Wed 2-5pm
After PDC
If you missed this related session, watch it on the DVD
COM200 - Applications and Communications Roadmap
COM202 - A Lap around the Windows Communications Foundation
MSDN dev center: http://msdn.microsoft.com/webservices/
Channel 9 tag: http://channel9.msdn.com/tags/Indigo
Contact us
Andy.Milligan @ microsoft.com
Blog: http://blogs.msdn.com/distilled
AnandRaj @ microsoft.com
Blog: http://blogs.msdn.com/solutions
30
© 2005 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.