Anda di halaman 1dari 14

Naresh

Information
Technologies Technologies
Nagaraju Bende
MCPD.NET Sr Consultant,Trainer
http://nbende.wordpress.com
Consuming WCF Services
VS.NET Role in building WCF Apps
Agenda Session 4
Nagaraj http://nbende.wordpress.com
WCF Service Library & WCF Service
Data Contracts
<system.serviceModel>
<services>
<endpoint
address = "http://localhost:8000/CustomerManager"
binding = "basicHttpBinding"
contract = "IContactManager">
</endpoint>
</services>
</system.serviceModel>
Addresses
Nagaraj http://nbende.wordpress.com
</system.serviceModel>
<system.serviceModel>
<services>
<endpoint
address = "net.tcp://localhost:8001/CustomerManager/"
binding = "netTcpBinding"
contract = "IContactManager">
</endpoint>
</services>
</system.serviceModel>
Develop Real World WCF Service Library
WCFTESTCLIENT.exe / WCFSVCHost.exe
Agenda Session 5
Nagaraj http://nbende.wordpress.com
Host in Windows Service
Configure more bindings
WCF Service using Web Template
Hosting in Web Server
Agenda Session 6
Nagaraj http://nbende.wordpress.com
LinqToSql/ADO.NET Entities/WCF
Demo
IIS Hosting simple 3 steps
1
Create Virtual Directory in
IIS
Create .svc file for service
Nagaraj http://nbende.wordpress.com
2
Create .svc file for service
implementation
3
Configuration of
web.config for services
Web Programming using WCF
WCF for ASP.NET AJAX apps
Agenda Session 9
Nagaraj http://nbende.wordpress.com
webHttpBinding new in 3.5, VS.NET role
SOAP, JSON, POX, REST styles
Demo
webHttpBinding
New web-friendly WCF Binding in Fx 3.5
Allows for the development of RESTful services
Does not use SOAP envelopes
HTTP and HTTPS Transports Only
Supports several wire formats:
Nagaraj http://nbende.wordpress.com
Supports several wire formats:
XML
JSON
Binary (streams)
JavaScript Object Notation
Format for bridging JavaScript and objects
Easier for browsers than XML
ASP.NET AJAX & other AJAX toolkits use it
What is JSON?
Nagaraj http://nbende.wordpress.com
ASP.NET AJAX & other AJAX toolkits use it
Other web-aware clients also (Silverlight, etc.)
va va va va dafa = {femp : 59, dafa = {femp : 59, dafa = {femp : 59, dafa = {femp : 59, desc desc desc desc : c1oudy} : c1oudy} : c1oudy} : c1oudy}
documenf.W1fe documenf.W1fe documenf.W1fe documenf.W1fe {1he Weafhe 1s + {1he Weafhe 1s + {1he Weafhe 1s + {1he Weafhe 1s + dafa.desc dafa.desc dafa.desc dafa.desc} } } }
WCF AJAX support in Visual Studio
Script manager, VS Project Templates
WCF automatically generates JS proxy
Usage pattern similar to existing one:
Add service to Script Manager control
WCF / AJAX Integration
Nagaraj http://nbende.wordpress.com
Add service to Script Manager control
Write JavaScript code to work with proxy
Configuration not required
Via the WebScriptServiceHostFactory (.svc file)
SOAP, JSON, POX, REST styles
WebGet and WebInvoke
Agenda Session 10
Nagaraj http://nbende.wordpress.com
UriTemplate in 3.5
Demo
[WebGet] And [WebInvoke]
Binds a WCF operation to URI
space and HTTP method
Indicate the HTTP Method for the operation
WebGet Dont make me write it
WebInvoke All verbs other than GET (Method
Nagaraj http://nbende.wordpress.com
WebInvoke All verbs other than GET (Method
parameter takes in the name of the Verb)
Other Parameters
BodyStyle Indicates whether the Request/
Response are wrapped or not
RequestFormat Json or Xml
ResponseFormat Json or Xml
UriTemplate Rich binding to URI
UriTemplate
String that allows you to define
the structure of the URI, as well as
to define Holes
The Holes are variables
You Bind the template with parameters to
Nagaraj http://nbende.wordpress.com
You Bind the template with parameters to
fill the holes
{productId} hole / variable gets bound
to productId parameter in operation
j0peratonContract
jWeb6et{ur1emp1ate=product,{product1d)")
roduct 6etroduct{nt product1d

WCF REST Starter Kit


Microsoft.ServiceModel.Web.dll
New features supporting RESTful services
Visual Studio 2008 Templates
REST Collections/Singleton Services
Nagaraj http://nbende.wordpress.com
Atom Feed/Atom Publishing Protocol
HTTP/POX Services
REST Samples
Codeplex Project
Released at PDC
Written by WCF team
Features may be included in .NET 4.0

Anda mungkin juga menyukai