winform程序怎么调用wcf服务
刚刚接触不知道怎么让winform程序怎么调用wcf服务感谢 --------------------编程问答-------------------- 看看这下面的帖子是不是你想要的。http://blog.csdn.net/firehou/article/details/6527041 --------------------编程问答--------------------
这个不行,通过这种方式找不到方法 --------------------编程问答-------------------- 添加服务引用即可。就可以跟使用本地的类一样了。 --------------------编程问答-------------------- winform是可以添加web服务引用的。和web application引用方法是相同的。
--------------------编程问答-------------------- 添加不了服务引用,因为通过浏览器访问是看不到方法的,通过添加服务引用直接报错 --------------------编程问答--------------------
你的wcf服务是寄宿到IIS上还是寄宿到winform上? --------------------编程问答--------------------
是在iis上的 --------------------编程问答-------------------- 似乎是服务器端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>
试试 --------------------编程问答-------------------- 没有开启服务资源访问许可的情况下,是无法获取Schema的,你可能是未启用。也可以直接引用接口类创建本地客户端方法,那样最方便。 --------------------编程问答-------------------- 楼上说的对,也可以使用ChannelFactory创建通道接口进行wcf服务的调用 --------------------编程问答-------------------- 配置了<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 --------------------编程问答-------------------- 当然 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();
}
--------------------编程问答--------------------
加了这个了,但是不显示提示的是Endpoint not found. --------------------编程问答--------------------
这个TestServiceClient是指的什么意思呢? --------------------编程问答--------------------
这个也试了,也是不出现相关的节点 --------------------编程问答-------------------- wcf工程属性里面有个选项是window身份验证还有个事winform身份验证,windows是web服务,winform是C/S结构的服务 --------------------编程问答--------------------
这个是配置在wcf服务器端的
客户端 要配置 client节点 和bindings节点 --------------------编程问答--------------------
求给一段完整的代码,谢谢~
补充:.NET技术 , C#