Upload
dinhkhanh
View
223
Download
0
Embed Size (px)
Citation preview
Ex4. An Simple WCF Example
Ex5. WCF REST Service
Yoon Joong Kim Department of computer Engineering
Hanbat National University
Yoon joong Kim
Contents
Ex1. An simple Web Services - HelloWorld
Ex2. An Web Service Example - Convert Centigrade
Ex3. An Web Service Example - using Database
Ex4. An WCF Example - 4.1 WCF Service (default) and Client
- 4.1.1 Serivce : GetData(int)
- 4.2.1 Client
- 4.2 WCF Service and Client
- 4.2.1 Service : SayHellow()
- 4.2.2 Client
- 4.3 WCF Service and Client In DB
- 4.2.1 Service : getDirectorySql(), insertRecord()
- 4.2.2 Client
Ex5. WCF REST Service
- 5.1 REST Service : xmlData(string), jsonData(string), getPhoneBook(string)
- 5.2 REST Client
- 5.3 How to use Fiddler to check the message content
Page 2
Yoon joong Kim
Ex.4 WCF
4.1 WCF Service
Application(Default) and Client
- 4.1.1 Service : GetData(int)
- 4.1.2 Client : console Application
-
WCF Service and Console Application
Web Service - GetData(int)
- SayHello()
Request :
SayHello()
GetData()
result string
SayHello()
Result string
WCF Service WCF Client
Yoon joong Kim
Ex.4 WCF
Page 4
Web Service Explorer
(WCFHelloService) Client Solution Explorer
(WCFHelloClient : Console Application)
Yoon joong Kim
Experimental environment
OS : Window 7
Framework : .NET 4.0
Tool : Visual Studio 2010
Language : C#
Browser : Internet Explorer 9,8
Page 5
Yoon joong Kim
4.1.1 WCF Service Application(Default) Generate WCF Service Application
Yoon joong Kim
4.1.1 WCF Service Application(Default) Generate WCF Service Application(cont.)
Yoon joong Kim
4.1.1 WCF Service Application(Default) modify of file name in the WCF Service application
Yoon joong Kim
4.1.1 WCF Service Application(Default) modify of service class name in the code
Yoon joong Kim
4.1.1 WCF Service Application(Default) modify of service class name in the code(cont.)
Yoon joong Kim
4.1.1 WCF Service Application(Default) Execute the Service Page
Yoon joong Kim
4.1.1 WCF Service Application(Default) List of WCF Service
Yoon joong Kim
4.1.2 WCF Service(Default) Client Generation an WCF Service Client
Yoon joong Kim
4.1.2 WCF Service(Default) Client Add Service Reference
Yoon joong Kim
4.1.2 WCF Service(Default) Client Add Service Reference(cont.)
Yoon joong Kim
4.1.2 WCF Service(Default) Client Add Service Reference(cont.)
Yoon joong Kim
4.1.2 WCF Service(Default) Client Add Service Reference(cont.)
Page 17
Yoon joong Kim
4.1.2 WCF Service(Default) Client Add Service Reference(cont.)
Page 18
Yoon joong Kim
4.1.2 WCF Service(Default) Client Add code
Yoon joong Kim
4.1.2 WCF Service(Default) Client Test of the WCF Service Client
Yoon joong Kim
Ex.4 WCF
4.2 WCF Service and Client - 4.2.1 Service : SayHello()
- 4.2.2 Client : Console Application
-
WCF Service and Console Application
Web Service - GetData(int)
- SayHello()
Request :
SayHello()
GetData()
result string
SayHello()
Result string
WCF Service WCF Client
Yoon joong Kim
4.2.1 WCF Service Add OperationContract
Yoon joong Kim
4.2.1 WCF Service implementation of the OperationContract in HelloService.svc.cs
Yoon joong Kim
4.2.2 WCF Service Client Updat Service Reference in the WCF Service Client
Yoon joong Kim
4.2.2 WCF Service Client Updat Service Reference in the WCF Service Client(cont.)
Yoon joong Kim
4.2.2 WCF Service Client Add a code in the WCF Service Client
Yoon joong Kim
4.2.2 WCF Service Client Add a code in the WCF Service Client(cont.)
Yoon joong Kim
4.2.2 WCF Service Client Test of WCF Service client
Yoon joong Kim
Ex.4.3 WCF
4.3 WCF Service and Client using
Database - 4.3.1 Service : getDirectorySql(),
insertRecord()
- 4.3.2 Client : WindowForm Application
-
WCF Service and WindowForm Application
Web Service - getDirectorySql
- insertRecord
Function of
view list
Function of
insert record
Web Server Client
Yoon joong Kim
4.3.1 WCF Service using Database
Page 30
Web Service Explorer (WcfDbService)
Client Solution Explorer (WcfDbClient : Window Application)
Yoon joong Kim
4.3.1 WCF Service using Database Generation of an WCF Service Application
Page 31
Yoon joong Kim
4.3.1 WCF Service using Database modify the service file name
Page 32
Yoon joong Kim
4.3.1 WCF Service using Database modify the service file name(cont.)
Page 33
Yoon joong Kim
4.3.1 WCF Service using Database modify the service class name
Page 34
Yoon joong Kim
4.3.1 WCF Service using Database modify the service class name
Page 35
Yoon joong Kim
4.3.1 WCF Service using Database Add OperationContract
Page 36
Yoon joong Kim
4.3.1 WCF Service using Database implementation of OperationContract
Page 37
Yoon joong Kim
4.3.1 WCF Service using Database implementation of OperationContract(cont.)
Page 38
Yoon joong Kim
4.3.1 WCF Service using Database Build and Run
Page 39
Control + F5
Yoon joong Kim
4.3.1 WCF Service using Database Build and Run(cont.)
Page 40
Double click
Yoon joong Kim
4.3.1 WCF Service using Database Build and Run(cont.)
Page 41
Yoon joong Kim
4.3.1 WCF Service using Database Build and Run(cont.)
Page 42
Yoon joong Kim
4.3.1 WCF Service using Database Build and Run(cont.)
Page 43
Yoon joong Kim
4.3.1 WCF Service using Database Execution of the WCF Service
Page 44
Yoon joong Kim
4.3.1 WCF Service using Database Test of the WCF Service
Page 45
Yoon joong Kim
4.3.2 WCF Service Client generation of WCF Service Client project
Page 46
Yoon joong Kim
4.3.2 WCF Service Client generation of WCF Service Client project(cont.)
Page 47
Yoon joong Kim
4.3.2 WCF Service Client Add Service Reference
Page 48
Yoon joong Kim
4.3.2 WCF Service Client Add Service Reference(cont.)
Page 49
Yoon joong Kim
4.3.2 WCF Service Client Add Service Reference(cont.)
Page 50
Yoon joong Kim
4.3.2 WCF Service Client Design of Client Form
Page 51
Yoon joong Kim
4.3.2 WCF Service Client Add a code in Form1.cs
Page 52
Yoon joong Kim
4.3.2 WCF Service Client Test of WCF Service Client
Page 53
Yoon joong Kim
5. WCF REST Service
WCF REST Service
5.1 WCF REST Service
- xmlData(string)
- JsonData(string)
- getPhoneBook(string)
WCF REST Service Client
5.2 WCF REST Service Client
WindowForm
Web Service - xmlData
- JsonData
- getPhoneBook
Response : “You requested producted abc”
Request : /xml/abc
Response : DataSet
Request : /phoneBook/8787
Function of
receive the xmlData
Function of
receive the JsonData
Web Server Client
Function of
receive the DataSet
Response : “You requested product def”
Request : /Json/def
Yoon joong Kim
5. WCF REST Service
Yoon joong Kim
5. WCF REST Service
Page 56
WCF Service Explorer (RESTService)
Client Solution Explorer (RestServiceClient/WindorForm)
Yoon joong Kim
5.1 WCF REST Service Project Generation
Page 57
Yoon joong Kim
5.1 WCF REST Service modify the service page name
Page 58
Yoon joong Kim
5.1 WCF REST Service modify the service class name
Page 59
Yoon joong Kim
5.1 WCF REST Service modify the service class name
Page 60
Yoon joong Kim
5.1 WCF REST Service Add operations (xmlData, JsonData)for the RrestService
Page 61
REST path for the service operation
Yoon joong Kim
5.1 WCF REST Service Implementaion of operations(xmlData, JsonData)
Page 62
Yoon joong Kim
5.1 WCF REST Service Test of the service
Page 63
Yoon joong Kim
5.1 WCF REST Service Test of service operation “xmlData(123)”
Page 64
REST Style path
“XMLDataRespone” = Operation name + “Response”
“XMLDataResult” = Operation name + “Result”
Yoon joong Kim
Page 65
5.1 WCF REST Service Test of service operation “JsonData(123)”
“JSONDataResult” = Operation name + “Result”
Yoon joong Kim
5.1 WCF REST Service Web.config
Page 66
Insert endpoint description
Yoon joong Kim
5.1 WCF REST Service Add a service operation getPhoneRecord(string phoneNumber)
Page 67
Yoon joong Kim
5.1 WCF REST Service Implementation of operation getPhoneRecord
Page 68
Yoon joong Kim
5.1 WCF REST Service Test of operation GetPhoneBook
Page 69
the URI of the Operation getPhoneRecord
Yoon joong Kim
5.2 WCF REST Service Client window From project generation
Page 70
Yoon joong Kim
5.2 WCF REST Service Client Client Form design
Page 71
Yoon joong Kim
5.2 WCF REST Service Client How to call the service operation of xmlData
Page 72
Yoon joong Kim
5.2 WCF REST Service Client How to call the service operation of JsonData
Page 73
Yoon joong Kim
5.2 WCF REST Service Client How to call the service operation of GetPhoneBook
Page 74
Yoon joong Kim
5.2 WCF REST Service Client Execution of the REST Client
Page 75
Yoon joong Kim
Execution of the REST Client
Page 76
Yoon joong Kim
5.2 WCF REST Service Client Execution of the REST Client
Page 77
Yoon joong Kim
5.3 Fiddler tool
Page 78
Yoon joong Kim
5.3 Fiddler tool(cont.)
Page 79
Yoon joong Kim
5.3 Fiddler tool(cont.)
Page 80
Double click
Yoon joong Kim
5.3 Fiddler tool(cont.)
Page 81
Yoon joong Kim
5.3 Fiddler tool(cont.)
Page 82
Double click
Yoon joong Kim
5.3 Fiddler tool(cont.)
Page 83