14
N aresh I nformation Technologies T echnologies Nagaraju Bende MCPD.NET Sr Consultant,Trainer http://nbende.wordpress.com

Naresh Information Technologies - … · Data Contracts ... LinqToSql/ADO.NET Entities/WCF Demo. ... – Allows for the development of RESTful services

  • Upload
    lythu

  • View
    223

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Naresh Information Technologies - … · Data Contracts  ... LinqToSql/ADO.NET Entities/WCF Demo. ... – Allows for the development of RESTful services

Naresh InformationTechnologiesTechnologies

Nagaraju BendeMCPD.NET Sr Consultant,Trainer

http://nbende.wordpress.com

Page 2: Naresh Information Technologies - … · Data Contracts  ... LinqToSql/ADO.NET Entities/WCF Demo. ... – Allows for the development of RESTful services

Consuming WCF Services

VS.NET Role in building WCF Apps

Agenda – Session 4

�������������� �����������������

WCF Service Library & WCF Service

Data Contracts

Page 3: Naresh Information Technologies - … · Data Contracts  ... LinqToSql/ADO.NET Entities/WCF Demo. ... – Allows for the development of RESTful services

<system.serviceModel> <services> <endpoint address = "http://localhost:8000/CustomerManager" binding = "basicHttpBinding" contract = "IContactManager"> </endpoint> </services> </system.serviceModel>

Addresses

�������������� �����������������

</system.serviceModel>

<system.serviceModel> <services> <endpoint address = "net.tcp://localhost:8001/CustomerManager/" binding = "netTcpBinding" contract = "IContactManager"> </endpoint> </services> </system.serviceModel>

Page 4: Naresh Information Technologies - … · Data Contracts  ... LinqToSql/ADO.NET Entities/WCF Demo. ... – Allows for the development of RESTful services

Develop Real World WCF Service Library

WCFTESTCLIENT.exe / WCFSVCHost.exe

Agenda – Session 5

�������������� �����������������

Host in Windows Service

Configure more bindings

Page 5: Naresh Information Technologies - … · Data Contracts  ... LinqToSql/ADO.NET Entities/WCF Demo. ... – Allows for the development of RESTful services

WCF Service using Web Template

Hosting in Web Server

Agenda – Session 6

�������������� �����������������

LinqToSql/ADO.NET Entities/WCF

Demo

Page 6: Naresh Information Technologies - … · Data Contracts  ... LinqToSql/ADO.NET Entities/WCF Demo. ... – Allows for the development of RESTful services

IIS Hosting – simple 3 steps

1 Create Virtual Directory in IIS

Create .svc file for service

�������������� �����������������

2 Create .svc file for service implementation

3 Configuration of web.config for services

Page 7: Naresh Information Technologies - … · Data Contracts  ... LinqToSql/ADO.NET Entities/WCF Demo. ... – Allows for the development of RESTful services

Web Programming using WCF

WCF for ASP.NET AJAX apps

Agenda – Session 9

�������������� �����������������

webHttpBinding new in 3.5, VS.NET role

SOAP, JSON, POX, REST styles

Demo

Page 8: Naresh Information Technologies - … · Data Contracts  ... LinqToSql/ADO.NET Entities/WCF Demo. ... – Allows for the development of RESTful services

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:

�������������� �����������������

• Supports several wire formats:– XML– JSON– Binary (streams)

Page 9: Naresh Information Technologies - … · Data Contracts  ... LinqToSql/ADO.NET Entities/WCF Demo. ... – Allows for the development of RESTful services

• 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?

�������������� �����������������

• ASP.NET AJAX & other AJAX toolkits use it– Other web-aware clients also (Silverlight, etc.)

������������ ����������� ������������������ ������������������ ������������������ ����������������������� ��������� �� ��������� �� ��������� �� ��������� ��

������������������������������������������������ �� ���� ������!��� ���� ������!��� ���� ������!��� ���� ������!�������������������������������������"�"�"�"�

Page 10: Naresh Information Technologies - … · Data Contracts  ... LinqToSql/ADO.NET Entities/WCF Demo. ... – Allows for the development of RESTful services

• 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

�������������� �����������������

– Add service to Script Manager control– Write JavaScript code to work with proxy

• Configuration not required– Via the WebScriptServiceHostFactory (.svc file)

Page 11: Naresh Information Technologies - … · Data Contracts  ... LinqToSql/ADO.NET Entities/WCF Demo. ... – Allows for the development of RESTful services

SOAP, JSON, POX, REST styles

WebGet and WebInvoke

Agenda – Session 10

�������������� �����������������

UriTemplate in 3.5

Demo

Page 12: Naresh Information Technologies - … · Data Contracts  ... LinqToSql/ADO.NET Entities/WCF Demo. ... – Allows for the development of RESTful services

[WebGet] And [WebInvoke]

• Binds a WCF operation to URI space and HTTP method

• Indicate the HTTP Method for the operation– WebGet – Don’t make me write it– WebInvoke – All verbs other than GET (Method

�������������� �����������������

– 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

Page 13: Naresh Information Technologies - … · Data Contracts  ... LinqToSql/ADO.NET Entities/WCF Demo. ... – Allows for the development of RESTful services

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

�������������� �����������������

– You Bind the template with parameters to fill the holes

• {productId} hole / variable gets bound to productId parameter in operation

��������������

����������������������������������������

����� ��� �������� ����������

��������

Page 14: Naresh Information Technologies - … · Data Contracts  ... LinqToSql/ADO.NET Entities/WCF Demo. ... – Allows for the development of RESTful services

WCF REST Starter Kit

• Microsoft.ServiceModel.Web.dll– New features supporting RESTful services

• Visual Studio 2008 Templates– REST Collections/Singleton Services

�������������� �����������������

– 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