如何在Windows Communication Foundation服务中创建客户端代理 [英] How to create proxy of client in windows communication foundation service

查看:101
本文介绍了如何在Windows Communication Foundation服务中创建客户端代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

海,

我为IIS 5/6托管开发了一个wcf应用程序.我在文件位置"C:\ Documents and Settings \ sridharan \ My Documents \ Visual Studio 2008 \ WebSites \ WCFService3"中创建了一个项目WCFService3.创建网站后,我声明了使用以下语法的IService.cs中的服务合同.

Hai,

Iam developing a wcf application for IIS 5/6 hosting.I create a project WCFService3 in the file location "C:\Documents and Settings\sridharan\My Documents\Visual Studio 2008\WebSites\WCFService3".After creating a website I declare the service contract in IService.cs with the following syntax.

string helloworld(string name);



在Service.cs中,我编写代码



In the Service.cs I write the the code

public string HelloWorld(string name)
    {
        return "Hello " + name;
    }



运行上面的wcf应用程序后,我获得带有以下行的窗口您已经创建了服务".

"svcutil.exe http://localhost:1137/WCFService3/Service.svc?wsdl".

我的疑问是在web.config文件中是否必须输入终点地址为
"svcutil.exe http://localhost:1137/WCFService3/Service.svc?wsdl".

(或)

"C:\ Documents and Settings \ sridharan \ My Documents \ Visual Studio 2008 \ WebSites \ WCFService3".

在命令提示符下,如果我写"svcutil.exe http://localhost:1137/WCFService3/Service.svc?wsdl".错误发生.

无法识别svcutil".
请清除我的疑问.我的问题太长了:)



After running the above wcf application I Get the window "you have created a service" with the following line.

"svcutil.exe http://localhost:1137/WCFService3/Service.svc?wsdl".

My doubt is in web.config file whether i have to put the end point address is
"svcutil.exe http://localhost:1137/WCFService3/Service.svc?wsdl".

(or)

"C:\Documents and Settings\sridharan\My Documents\Visual Studio 2008\WebSites\WCFService3".

In command prompt if i write "svcutil.exe http://localhost:1137/WCFService3/Service.svc?wsdl". the error is occurs.

"svcutil is not recognised".
please clear my doubt.My question is too length :)

推荐答案

要在IIS中托管服务,您需要创建一个扩展名为.svc的文件,并在其中添加以下行它

To host a service in IIS you need to create a file with extension .svc and add following lines in it

<%@ServiceHost Service="WCFService3.Service"%>



然后使用 System.ServiceModel 标签
进入您的web.config



and following to your web.config with in System.ServiceModel tag

<services>
     <service name="WCFService3.Service">
       <!-- Service Endpoints -->
       <endpoint address="" binding="wsHttpBinding" contract="WCFService3.IService">
         </endpoint>
       <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
     </service>
   </services>


然后创建一个客户端,并从Visual Studio添加对此服务的引用,这将自动为您的客户端创建端点.

--Pankaj


then create a client and add reference to this service from visual studio and this will automatically create endpoint for your client.

--Pankaj


这篇关于如何在Windows Communication Foundation服务中创建客户端代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆