WCFSVRhost 这个服务要如何启动呢?

binbin50 2012-11-22 09:01:10
我用WCF做了个服务,用网页调用这个服务。
在VS2010运行时WCFSVRhost这个服务自己会启动,
但时我的网页发布到IIS后,WCFSVRhost这个服务不会自启动。
如何手工启动,会让它自己启动呢?
谢谢!
...全文
246 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
机器人 2012-12-18
  • 打赏
  • 举报
回复
http://localhost/WCF/Service1/mex 才是引用地址。
binbin50 2012-12-18
  • 打赏
  • 举报
回复
引用 6 楼 fangxinggood 的回复:
添加服务引用就可以了。ip改为你发布的ip
我开启服务的代码如下,但还是会有上面的提示,请帮忙看看!谢谢! static void StartServer() { using (ServiceHost host = new ServiceHost(typeof(Service1), new Uri("http://localhost/WCF/Service1/"))) { WSHttpBinding wsbinding = new WSHttpBinding(); wsbinding.Name = "NoneSecurity"; wsbinding.MaxBufferPoolSize = 12000000; wsbinding.MaxReceivedMessageSize = 12000000; wsbinding.UseDefaultWebProxy = false; WSHttpSecurity security = new WSHttpSecurity(); security.Mode = SecurityMode.None; wsbinding.Security = security; //实例化type,binding,address ServiceEndpoint sed = host.AddServiceEndpoint(typeof(IService1),wsbinding, ""); //设置IService1的ServiceContract特性的SessionMode sed.Contract.SessionMode = SessionMode.Allowed; ServiceMetadataBehavior behavior = new ServiceMetadataBehavior(); host.Description.Behaviors.Add(behavior); ServiceBehaviorAttribute behaviorAttr = host.Description.Behaviors.Find<ServiceBehaviorAttribute>(); if (behaviorAttr == null) { behaviorAttr = new ServiceBehaviorAttribute(); } //设置服务类Service1的ServiceBehavior特性的ConcurrencyMode和InstanceContextMode behaviorAttr.ConcurrencyMode = ConcurrencyMode.Single; behaviorAttr.InstanceContextMode = InstanceContextMode.PerCall; host.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex"); host.Open(); Console.WriteLine("ConsoleHost 服务开启……"); Console.ReadLine(); }
binbin50 2012-12-17
  • 打赏
  • 举报
回复
我自己写了个EXE来启动服务, 服务启动了,但是会提示:服务http://localhost/WCF/Service1/不支持内容类型 text/xml; charset=utf-8.客户端和服务绑定可能不匹配。 怎么解决呢?
机器人 2012-12-02
  • 打赏
  • 举报
回复
添加服务引用就可以了。ip改为你发布的ip
binbin50 2012-12-02
  • 打赏
  • 举报
回复
引用 4 楼 fangxinggood 的回复:
通过 IIS 管理工具,即可启动Web Application (WCF一般作为一个Web Application发布) 注意修改默认程序应用池(.net 2.0 还是 .net 4.0)
发布完,网页如可调用这个服务呢?
机器人 2012-11-27
  • 打赏
  • 举报
回复
通过 IIS 管理工具,即可启动Web Application (WCF一般作为一个Web Application发布) 注意修改默认程序应用池(.net 2.0 还是 .net 4.0)
binbin50 2012-11-27
  • 打赏
  • 举报
回复
引用 2 楼 fangxinggood 的回复:
IIS host 会自动启动啊。不需要你自己写 host.open 啊。 创建 WCF Application,默认使用 svc 的 markup 里用默认的 WsHttpBindingServiceHostFactory 会自动Open Host
我发布的IIS后就不会自启动,如果在VS里调试是会自己启动。
机器人 2012-11-24
  • 打赏
  • 举报
回复
IIS host 会自动启动啊。不需要你自己写 host.open 啊。 创建 WCF Application,默认使用 svc 的 markup 里用默认的 WsHttpBindingServiceHostFactory 会自动Open Host
Jia_H 2012-11-22
  • 打赏
  • 举报
回复
看看MSDN上有关WCF的帮助,里面就有如何Host的介绍。

12,162

社区成员

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

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