急求!如何用windows service调用部署在IIS上的WCFservice

zyysusan_1 2012-12-06 02:03:53

我需要开发一个windows service,通过此service可以调用已经发布在IIS 上的wcf service, 并且这个wcf service 被部署在与windows service同一个域下的另外一台电脑上。 求救,怎样在windows service中调用这样的wcf service 呢? 我尝试用一般的调用方式,通过在windows service 项目上 点击 增加web service,输入地址,的方式加入wcf service, 不过报错了。

错误:Could not find default endpoint element that references contract 'ServiceReference1.IService1' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
调用WCF service 代码如下:
ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
client.ClientCredentials.Windows.ClientCredential.UserName = "administrator";
client.ClientCredentials.Windows.ClientCredential.Password = "Password1";
client.ClientCredentials.Windows.ClientCredential.Domain = "TMServerA.GES-TM.COM xmlstring = client.DriverData(sw.ToString(), i);
app.config如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://tmservera/wintest/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
...全文
414 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
机器人 2012-12-15
  • 打赏
  • 举报
回复
Windows Service 直接通过添加 Service Reference 就能调用WCF了啊。 你的错误是因为WCF Service有错误 看你的错误提示:Could not find default endpoint element that references contract 'ServiceReference1.IService1' 另外要注意 Windows Service 的权限。
zyysusan_1 2012-12-11
  • 打赏
  • 举报
回复
还是没人理 不过我想到了一个替代的方法。 先建一个Console的程序,在这个程序内调用部署在IIS 上的WCF SSERVICE 。 然后再在WINDOWS SERVICE 中通过代码运行这个Console程序的EXE 文件,这样算是间接地调用了WCF SERVICE。 不过还是没有找到直接调用的方法!!
zyysusan_1 2012-12-06
  • 打赏
  • 举报
回复
顶起,不能沉呀~
zyysusan_1 2012-12-06
  • 打赏
  • 举报
回复
网上的都是介绍 怎样用windows service 来做WCF 宿主的~ 没有介绍 用windows service作客户端的~ 求救呀,求救~

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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