Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net WCF端点配置_Asp.net_Wcf_Wcf Binding - Fatal编程技术网

Asp.net WCF端点配置

Asp.net WCF端点配置,asp.net,wcf,wcf-binding,Asp.net,Wcf,Wcf Binding,我需要在我的WCF服务中配置一个端点。我的服务URL类似于 http://mysite.com/Services/Service1.svc 我想给客户提供URLhttp://mysite.com/MyService使用该服务 我在下面的web.config中尝试过,但它不起作用,当我导航到http://mysite.com/MyService我得到了404错误 <service name="GateApplication.Services"> <host>

我需要在我的WCF服务中配置一个端点。我的服务URL类似于

http://mysite.com/Services/Service1.svc
我想给客户提供URL
http://mysite.com/MyService
使用该服务

我在下面的
web.config中尝试过,但它不起作用,当我导航到
http://mysite.com/MyService
我得到了404错误

<service name="GateApplication.Services">
   <host>
      <baseAddresses>
         <add baseAddress="http://mysite.com/Services/"/>
      </baseAddresses>
   </host>
   <endpoint 
       address="http://mysite.com/MyService"
       binding="wsHttpBinding" 
       contract="GateApplication.IService1" >
   </endpoint>
</service>

尝试以下配置

<endpoint 
    address="http://mysite.com/Services/Service1.svc"
    binding="wsHttpBinding" 
    contract="GateApplication.IService1" />

然后按ok

我假设您是在IIS上托管的

从本质上讲,你不能仅仅选择IIS中的地址,你可以用自托管的方式。但是,您可以使用路由或动态路径重写将用户从别名重定向到SVC


有很多关于它的链接。例如,您可以使用或作为参考。

您如何托管WCF服务?在IIS内部?如果是这样:那么IIS虚拟目录和
.svc
文件的路径定义了您的服务URL,您不能通过config@marc_s你好我刚刚开始使用WCF。据我所知,端点被用来为消费者提供一个更加用户友好的URL。除此之外还有其他优势吗?我使用的是使用IIS的共享主机服务。如果我错了,请纠正我。端点是外部世界与WCF服务对话的连接。但在IIS中托管时,服务URL的命名由IIS指定-您无法轻松更改它。如果您希望完全控制服务URL,则需要使用自托管而不是使用IIS。对于初学者来说。@marc_s那么总是使用端点不是很有必要吗?没有使用端点的WCF服务没有问题,对吗?
http://mysite.com/Services/Service1.svc