AJAX访问WCF 寄宿WinForm

yas9418 2021-04-07 06:53:44
论坛有个代码下载但是运行不了.
网上拼凑的代码
Host = new ServiceHost(typeof(WcfService1.Service1));
//绑定
System.ServiceModel.Channels.Binding httpBinding = new BasicHttpBinding();
//终结点
Host.AddServiceEndpoint(typeof(WcfService1.Service1), httpBinding, "http://localhost:8002/");
if (Host.Description.Behaviors.Find<System.ServiceModel.Description.ServiceMetadataBehavior>() == null)
{
//行为
ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
behavior.HttpGetEnabled = true;
//元数据地址
behavior.HttpGetUrl = new Uri("http://localhost:8002/Service1");
Host.Description.Behaviors.Add(behavior);
//启动
Host.Open();
MessageBox.Show("1");
}

只能访问http://localhost:8002/Service1 返回的是XML
但是访问 http://localhost:8002/Service1/GetFun2?UserID=as&OperaID=23 里面的方法就不行
...全文
194 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

111,094

社区成员

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

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

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