Transcript WCF Client

Windows Communication
Foundation:
Migration, interop, upgrade,
and integration
Risman Adnan
ISV Lead, Microsoft Indonesia
[email protected]
http://geeks.netindonesia.net/blogs/risman
Integration Motivations
Deployed LOB logic is the core asset
Lengthy application lifecycle
Stability is key
Duplication often unacceptable
Utility throttled by proprietary access
New end-to-end solutions on top of existing
heterogeneous environment
Goal of integration:
Provide the benefits of SO without outweighing
the cost of adoption
WCF Degrees Of Integration
Wire-level interoperability
WS-* protocols for ASP.NET, WSE and nonMSFT web-services and clients
Product level integration
Feature level support for integrating
COM and COM+ applications
Feature level support to integrate with existing
MSMQ applications
Extensible channel architecture to implement
integration between WCF and technology X
Code Migration
.NET Framework v2.0 Web
Services
ASP.NET Web services implementation in
the .NET v2.0 Framework
Supports WS-I Basic Profile (BP) 1.1 for simple
services with metadata support
Doesn’t implement WS-* specifications
WSE 3.0 is an add-on to the .NET v2.0
Framework
WSE 3.0 released with Visual Studio 2005
Implements several WS-* specifications
Adds message security to ASP.NET Web
services and supports the Basic Security Profile
(BSP) 1.0
ASP.NET Web Services
WS-I Basic Profile Conformance
WebServiceBinding attribute
[WebServiceBinding(ConformsTo=WsiProfiles.BasicProfile1_1,
EmitConformanceClaims=true)]
[WebService(Namespace="Microsoft.Sample.WebServices")]
public class BPConformance_asmx
{
[WebMethod]
public string HelloWorldBP()
{
string message = "'Hello World' from a Basic Profile
compliant (BP-compliant) Web Service.";
return message;
}
}
ASP.NET Web Services to WCF
Interoperability Guidance
Embrace
Basic Profile (BP) conformance
.NET 2.0 is BP conformant by default
Use SOAP 1.1
KISS - Keep Interoperable Schemas Simple
Avoid
rpc/encoded as not BP compliant
SOAP Extensions - harder to migrate
Web Services Architecture
Web Services Enhancements 3.0
Security
Management
Reliability
Business
Process
Transactions
…
Metadata
Connected
Applications
Applications
& Application
Infrastructure
Foundation
Messaging
XML
HTTP
TCP
Custom
…
Transports
WSE 3.0 Turnkey Security Scenarios
Based on industry best practices
UsernameOverCertificate
AnonymousOverCertificate
UsernameOverTransport
Kerberos (Windows)
MutualCertificate
WCF Interoperable Pre-Built Bindings
WCF
Bindings
Specifications
basicHttpBinding SOAP 1.1
wsHttpBinding
Basic Profile 1.1
WS-Security 1.0
Basic Security
Profile 1.0
MTOM
SOAP 1.2
WS-Security 1.1
MTOM
.NET
Web
services
stacks
Non-MSFT
Web Services
stacks
ASP.NET
1.1
ASP.NET
2.0
WSE 2.0
WSE 3.0
IBM WAS 5.x, 6.0
BEA WL 8.1.x
Apache Axis 1.3
WSE 3.0
IBM WAS 7.x
(future)
BEA WL 9.x
Apache Axis 2.0
WSE to WCF Interoperability Guidance
Embrace
The ASP.NET web services guidance
Use WSE 3.0 for wire level interoperability with WCF
HTTP transport
Turnkey Security Scenarios and policy (WSE 3.0)
MTOM (WSE 3.0)
Avoid
TCP transport for interoperability
Custom transports
DIME (WSE 2.0)
Custom security configurations
WCF and non-MSFT web services
Request for EMR
Pointer to EMR
Patient
Record
Repository
Patient Records
Locator
BEA WebLogic
8.1.4
Dr. WCF’s Office
WCF
Dr. Java’s Office
Apache Axis 2.0
Current Application Scenario
Server
IIS / ASP.NET
Client
COM+
Find.aspx
Payment.a
spx
Server 2
COM
Order
fulfillment
BookLogic.Financ
e
BookLogic.Retail
IRetail:
-GetBookTitle
-OrderBook
MSMQ
WCF Affiliates
service
stock
data
WCF client
COM+ App As A WCF
Service
Scenario: Core LOB logic hosted deployed in
COM+ throttled by proprietary access
WCF includes feature level support to easily
generate WCF services
ComSvcConfig will expose endpoints for your COM+
component interfaces
Provides interoperable, secure, reliable, transacted web
service access over a choice of transports
ComSvcConfig.exe /install
/application:BookSample
/contract:BookLogic.Finance,IFinance
/hosting:was
/mex
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
[ Shows 1 of 3 hosting modes ]
Catalog
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
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
COM+ App As A WCF Service
The generated service
A clear mapping
COM class  service
COM interface  service contract
COM interface methods 
operation contract
All service configuration through
standard WCF .config
COM+ Integration
Customizations
For exposing a partial interface
List as exposedMethods in config
For Basic Profile clients (non WS-*)
Opt-in to sessionless binding support
Uses per-call session semantics in COM+
For COM+ interface that use VARIANT UDTs
Types cannot be determined through reflection
Specify types and typelibs in config
For methods with object reference parameters
/allowReferences and specify type in config
Requires IPersistStream and is non-interoperable
WCF Queuing Channels
Overview
MSMQ Transport Channel
To exchange queued messages between WCF
applications
SOAP within MSMQ message
Supports new WCF queue addressing scheme
MSMQ Integration Channel
To exchange queued messages between
legacy MSMQ and WCF applications
Classic MSMQ message
Supports all existing MSMQ addressing and
protocol schemes
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
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
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
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
Consuming Services In COM
Scenario: Services are proliferating but COM
based clients are still prevalent
WCF provides a client proxy tool (SvcUtil)
WCF provides a COM-specific “service” moniker
Control over service address, binding and contract
Usage patterns:
Typed contract
WSDL contract
Metadata Exchange contract
IChannelCredentials for security / cert specifics
Provides interoperable, secure, reliable,
transacted web service access over a choice of
transports
Summary
Microsoft is committed to leveraging existing
investments
ASMX & WSE 3.0 wire level interoperability
Integration is baked into the WCF runtime for
COM+, COM & MSMQ
Continued use of MSMQ transport
Adopting WCF can be low impact,
incremental and alongside migration
Feedback urgently required
Prototype with the WinFX CTPs
Find those edges!
Resources
Web Services Developer Center - WSE
http://msdn.microsoft.com/webservices/
Vista Developer Center – WinFX / WCF
http://msdn.microsoft.com/windowsvista/
Windows Communication Foundation community site
http://windowscommunication.net
Windows Communication Foundation forum
http://forums.microsoft.com/msdn/showforum.aspx?forumid=118
© 2005 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Appendix
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
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
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
MSMQ & Windows Vista
Enhancements to MSMQ
Poison message handling for MSMQ
Per application error queue
WCF services can receive messages
transactionally across the network