Adam Dille CS526 Spring 2010 Project Scope Advances in Microsofts service offerings ASMX vs WCF Latest WCF Improvements NET 40 No indepth study of backwards compatibility No ID: 544906
Download Presentation The PPT/PDF document "Microsoft WCF Services" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Microsoft WCF Services
Adam
Dille
CS526 – Spring 2010Slide2
Project Scope
Advances in Microsoft’s service offerings
ASMX vs. WCF
Latest WCF Improvements (.NET 4.0)
No
in-depth study of backwards
compatibility
No
comparisons to Java, Ruby, PHP, etcSlide3
MS Web Service History
ASMX
Introduced with .NET 1.0 in 2002
Service creation is quick and painless
Limited in scope
WCF
Introduced with .NET 3.0 in 2006
More steps involved to create and configure
Much more broad in scope and abilitiesSlide4
ASMX
Add ASMX file to Web Application
Decorate a function with [
WebMethod
] attribute
Viola! We have a web service!
[
WebMethod
]
public
String
SayHello
(
String
name)
{
return
“Hello “
+ name;
}Slide5
ASMX
Limited to HTTP protocol
Requires IIS, Cassini or hand-coded web server instance
Relies on web server for securitySlide6
WCF
Unifies development of web services, peer to peer, client/server and IPC
Endpoints expose different protocols
Combines and interoperates with:
ASP.NET Web Services (ASMX)
.NET
Remoting
Message Queuing
Enterprise Services (COM+)Slide7
WCF Security
Variety of Security Options
Windows
Certificate
Digest
Basic
UserName
NTLM
IssuedToken
Allows varied security for same service through EndpointsSlide8
WCF Service Design
Attributes
ServiceContract
– Marks a class or interface as a WCF service
OperationContract
– Marks a function as a member of the parent service contract
DataContract
– Marks a class or
struct
as a data type that will be passed to or from the service
DataMember
– A property of a data contract that will be passed along with it’s parent object
MessageContract
– Allows explicit formatting of messages. Useful for interoperability.Slide9
WCF Service Design
[
DataContract
]
public
class
HelloInfo
{
[
DataMember
]
public
String
Name { get; set; }
}Slide10
WCF Service Design
[
ServiceContract
]
public
interface
IHelloService
{
[
OperationContract
]
public
String
SayHello
(
HelloInfo
info);
}
public
class
HelloService
:
IHelloService
{
public
String
SayHello
(
HelloInfo
info)
{
return
“Hello “
+
info.Name
;
}
}Slide11
WCF Hosting
Hosting Options
IIS 5 & 6 (HTTP protocol only)
IIS 7
.NET Forms or Console application
Windows ServiceSlide12
WCF Hosting
Defining Endpoint through Configuration
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<
system.serviceModel
>
<services>
<service name=“
HelloService
">
<endpoint address=“
HelloService
" binding="
basicHttpBinding
" contract="
IHelloService
"/>
</service>
</services>
</
system.serviceModel
>
</configuration>Slide13
WCF Hosting
Defining Endpoint through Configuration
public void
DefineEndpointInConfig
()
{
ServiceHost
sh
= new
ServiceHost
(
typeof
(
HelloService
));
sh.Open
();
}Slide14
WCF Hosting
Defining Endpoint Imperatively
public
void
DefineEndpointImperatively
()
{
ServiceHost
sh
= new
ServiceHost
(
typeof
(
HelloService
));
sh.AddServiceEndpoint
(
typeof
(
IHelloService
),
new
WSHttpBinding
(),
"http://localhost/HelloService/EP1"
);
sh.Open
();
}Slide15
WCF in .NET 4.0
Released April 12, 2010
Simplified Configurations (
Config
-free!)
Service discovery
Routing services
REST Improvements
Workflow Services IntegrationSlide16
Questions
?