winform程序怎么调用wcf服务

guanapeng_cn 2013-04-24 12:28:07
刚刚接触不知道怎么让winform程序怎么调用wcf服务感谢
...全文
473 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
我是小李 2013-04-24
  • 打赏
  • 举报
回复
看看这下面的帖子是不是你想要的。 http://blog.csdn.net/firehou/article/details/6527041
guanapeng_cn 2013-04-24
  • 打赏
  • 举报
回复
引用 17 楼 zhouqinghe24 的回复:
引用 15 楼 guanapeng_cn 的回复:引用 11 楼 zhouqinghe24 的回复: 配置了<services> <service behaviorConfiguration="TestAPI.TestServiceBehavior" name="TestAPI.TestService"> <endp……
求给一段完整的代码,谢谢~
瑞卡哥哥 2013-04-24
  • 打赏
  • 举报
回复
引用 15 楼 guanapeng_cn 的回复:
引用 11 楼 zhouqinghe24 的回复: 配置了<services> <service behaviorConfiguration="TestAPI.TestServiceBehavior" name="TestAPI.TestService"> <endpoint address="" binding="netTcpBinding……
这个是配置在wcf服务器端的 客户端 要配置 client节点 和bindings节点
福惜 2013-04-24
  • 打赏
  • 举报
回复
wcf工程属性里面有个选项是window身份验证还有个事winform身份验证,windows是web服务,winform是C/S结构的服务
guanapeng_cn 2013-04-24
  • 打赏
  • 举报
回复
引用 11 楼 zhouqinghe24 的回复:
配置了<services> <service behaviorConfiguration="TestAPI.TestServiceBehavior" name="TestAPI.TestService"> <endpoint address="" binding="netTcpBinding" contract="T……
这个也试了,也是不出现相关的节点
guanapeng_cn 2013-04-24
  • 打赏
  • 举报
回复
引用 12 楼 zhouqinghe24 的回复:
当然 winform需要指定客户端凭证。像如下调用即可 C# code?1234567 using (TestServiceClient client = new TestServiceClient()) { client.ClientCredentials.Windows.ClientCredential.UserName = "用户名……
这个TestServiceClient是指的什么意思呢?
guanapeng_cn 2013-04-24
  • 打赏
  • 举报
回复
引用 8 楼 lixiaolian7 的回复:
似乎是服务器端serviceMetadata 没有开启。 配置文件中在system.servicemodel节点添加 <serviceBehaviors> <behavior> <!-- To avoid disclosing metadata information, set the value below to false ……
加了这个了,但是不显示提示的是Endpoint not found.
瑞卡哥哥 2013-04-24
  • 打赏
  • 举报
回复
当然 winform需要指定客户端凭证。像如下调用即可

  using (TestServiceClient client = new TestServiceClient())
                {
 client.ClientCredentials.Windows.ClientCredential.UserName = "用户名";
                    client.ClientCredentials.Windows.ClientCredential.Password = "密码";
                    client.ClientCredentials.Windows.ClientCredential.Domain = "域名或ip";
var response=client.DoTest();
}
瑞卡哥哥 2013-04-24
  • 打赏
  • 举报
回复
配置了<services> <service behaviorConfiguration="TestAPI.TestServiceBehavior" name="TestAPI.TestService"> <endpoint address="" binding="netTcpBinding" contract="TestAPI.ITestService"> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> 配置了service 就可以使用的 昨天完成的项目刚用了winform调用wcf
大腹 2013-04-24
  • 打赏
  • 举报
回复
楼上说的对,也可以使用ChannelFactory创建通道接口进行wcf服务的调用
qldsrx 2013-04-24
  • 打赏
  • 举报
回复
没有开启服务资源访问许可的情况下,是无法获取Schema的,你可能是未启用。也可以直接引用接口类创建本地客户端方法,那样最方便。
大腹 2013-04-24
  • 打赏
  • 举报
回复
似乎是服务器端serviceMetadata 没有开启。 配置文件中在system.servicemodel节点添加 <serviceBehaviors> <behavior> <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> <serviceMetadata httpGetEnabled="true"/> <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> 试试
guanapeng_cn 2013-04-24
  • 打赏
  • 举报
回复
引用 6 楼 lixiaolian7 的回复:
引用 5 楼 guanapeng_cn 的回复:添加不了服务引用,因为通过浏览器访问是看不到方法的,通过添加服务引用直接报错 你的wcf服务是寄宿到IIS上还是寄宿到winform上?
是在iis上的
大腹 2013-04-24
  • 打赏
  • 举报
回复
引用 5 楼 guanapeng_cn 的回复:
添加不了服务引用,因为通过浏览器访问是看不到方法的,通过添加服务引用直接报错
你的wcf服务是寄宿到IIS上还是寄宿到winform上?
guanapeng_cn 2013-04-24
  • 打赏
  • 举报
回复
添加不了服务引用,因为通过浏览器访问是看不到方法的,通过添加服务引用直接报错
大腹 2013-04-24
  • 打赏
  • 举报
回复
winform是可以添加web服务引用的。和web application引用方法是相同的。
游戏人间 2013-04-24
  • 打赏
  • 举报
回复
添加服务引用即可。就可以跟使用本地的类一样了。
guanapeng_cn 2013-04-24
  • 打赏
  • 举报
回复
引用 1 楼 ly_sl 的回复:
看看这下面的帖子是不是你想要的。 http://blog.csdn.net/firehou/article/details/6527041
这个不行,通过这种方式找不到方法

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧