https://www.tutorialspoint.com/wcf/wcf_consuming_service.htm

WCF services allow other applications to access or consume them. A WCF service can be consumed by many ways depending on the hosting type. Here, we are explaining the step-by-step method to consume a WCF service for each of the following popular hosting options:

  • Consuming WCF Service hosted in IIS 5/6
  • Consuming WCF Service that is self-hosted
  • Consuming WCF Service hosted in Windows Activation Service
  • Consuming WCF Service hosted in Windows Service

Consuming WCF Service Hosted in IIS 5/6

The process of consumption of a WCF service hosted in IIS 5/6 is discussed below in detail. In addition, the discussion includes how to create proxy and console applications.

Step-1: Once a service is hosted in IIS, we have to consume it in client applications. Before creating the client application, we need to create a proxy for the service.

This proxy is used by the client application to interact with the service. To create a proxy, run Visual Studio 2008 command prompt.

Using service utility, we can create the proxy class and its configuration information.

svcutilhttp://localhost/IISHostedService/Service.svc

After executing this command, we will get two files generated in the default location.

  • MyService.cs – Proxy class for the WCF service

  • output.config – Configuration information about the service

Step-2: Now, we will start creating the Console application using Visual Studio 2008 (Client application).

Step-3: Add the reference 'System.ServiceModel'; this is the core dll for WCF.

Step-4: Create a Proxy class.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace MyServiceClient
{
Class Program
{
Static void Main(string[] args)
{
// Creating Proxy for the MyService
ServiceClient Client = newServiceClient();
Console.WriteLine("Client calling the service...");
Console.WriteLine("Hello Ram");
Console.Read();
}
}
}

The output appears as follows:

WCF - Consuming WCF Service的更多相关文章

  1. wcf和web service的区别

    1.WebService:严格来说是行业标准,不是技术,使用XML扩展标记语言来表示数据(这个是夸语言和平台的关键).微软的Web服务实现称为ASP.NET Web Service.它使用Soap简单 ...

  2. WCF和Web Service的 区(guan)别(xi)

    参考文献:http://social.microsoft.com/Forums/zh-CN/c06420d1-69ba-4aa6-abe5-242e3213b68f/wcf-webservice 之前 ...

  3. WCF与 Web Service的区别是什么?各自的优点在哪里呢?

    这是很多.NET开发人员容易搞错的问题.面试的时候也经常遇到,初学者也很难分快速弄明白 Web service: .net技术中其实就指ASP.NET Web Service,用的时间比较长,微软其实 ...

  4. 跟我一起学WCF(13)——WCF系列总结

    引言 WCF是微软为了实现SOA的框架,它是对微乳之前多种分布式技术的继承和扩展,这些技术包括Enterprise Service..NET Remoting.XML Web Service.MSMQ ...

  5. Learing WCF Chapter1 WCF Services

    WCF ServicesWCF services are the new distributed boundary in an enterprise application—with an empha ...

  6. 使用WCF 创建 Rest service

    REST SERVICE 允许客户端修改url路径,并且web端功过url 请求数据. 他使用http协议进行通讯,想必大家都知道 . 并且我们可以通过设置进行数据类型转换, 支持XML,JSON 格 ...

  7. 在IIS8.5的环境下配置WCF的Restful Service

    今天在客户的环境中(Windows Server 2012 R2 + IIS 8.5)搭建Call WCF Restful Service的功能,发现了几个环境配置的问题,记录如下: 1):此环境先安 ...

  8. 扩展Wcf call security service, 手动添加 Soap Security Head.

    有次我们有个项目需要Call 一个 Java 的 web service, Soap包中需要一个 Security Head <soapenv:Header> <wsse:Secur ...

  9. Entity Framework + WCF REST JSON Service

    利用EF 和WCF 建立一个REST JSON Service. 首先我们要下载一个Visual Studio 的Template 叫 "ADO.NET C# POCO Entity Gen ...

随机推荐

  1. iOS获取webview高度

    int webHeight = [[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.scr ...

  2. eclipse项目文件编码格式和项目不一致的修改方法

    eclipse导入了一个项目,并把其属性设置成了UTF-8,但是打开里面的文档之后,发现还是乱码,看了下属性,发现文档竟然还是GBK的编码 于是就百度了下,发现了解决方法,现在和大家分享下,希望能帮到 ...

  3. 隐藏NavigationBar 带来的坑

    一.场景介绍 现在大多数APP 都有一个需求,就是隐藏某一个页面的NavigationBar.很多开发者直接   [self.navigationController setNavigationBar ...

  4. CSS3滤镜!!!

    <!DOCTYPE html> <html> <head> <style> img { width: 33%; height: auto; float: ...

  5. UVA - 572 Oil Deposits(dfs)

    题意:求连通块个数. 分析:dfs. #include<cstdio> #include<cstring> #include<cstdlib> #include&l ...

  6. PHP学习笔记——PHP脚本和JAVA连接mysql数据库

    环境 开发包:appserv-win32-2.5.10 服务器:Apache2.2 数据库:phpMyAdmin 语言:php5,java 平台:windows 10 java驱动:mysql-con ...

  7. 【转】Ubuntu编译安装mysql源码

    主要参考了下面两篇文章 http://forum.ubuntu.org.cn/viewtopic.php?t=330121 http://www.linuxidc.com/Linux/2011-09/ ...

  8. osi七层模型和两主机传输过程:

    osi七层模型和两主机传输过程: http://www.zhihu.com/question/24002080/answer/31817536  注:笔记部分可能参考其他作者内容的一个记录,仅为加深自 ...

  9. linux shell编程学习笔记(二) --- grep命令

    Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来.grep全称是Global Regular Expression Print,表示全局正则表达 ...

  10. asp.net <% %>,<%# %>,<%= %>,<%$ %>区别大集合

    前台页面 <div><%--可以执行服务器代码,相当于在后台写代码,Render%><%=取后台变量或方法值,只能绑定客户端控件,绑定服务器控件时后来必须调用databi ...