找不到WCF服务的端点
本文关键字:端点 服务 WCF 找不到 | 更新日期: 2023-09-27 17:51:19
创建WCF服务。当我用WCF测试客户端测试它时,服务工作正常。我决定将结束点配置为使用浏览器显示结果。
我有一个空白页的文本端点未找到。没有更多的细节。
这里是my web.config
<system.serviceModel>
<services>
<service name="mCollectorService.CollectorService" behaviorConfiguration="mCollectorService.CollectorServiceBehavior">
<endpoint address="../CollectorService.svc"
binding="webHttpBinding"
contract="mCollectorService.ICollectorService"
behaviorConfiguration="webBehaviour"
/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mCollectorService.CollectorServiceBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
<endpointBehaviors>
<behavior name="webBehaviour">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
这是我的ICollectorService
[ServiceContract]
public interface ICollectorService
{
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "Authenticate/{agentcode}/{pin}/{deviceIMEI}/{gpslat}/{gpslong}")]
Authentification Authenticate(string agentcode,string pin, string deviceIMEI, string gpslat, string gpslong);
}
任何帮助。
试着这样修改你的服务:
<services>
<service name="mCollectorService.CollectorService" behaviorConfiguration="mCollectorService.CollectorServiceBehavior">
<endpoint address="../CollectorService.svc"
binding="webHttpBinding"
contract="mCollectorService.ICollectorService"
behaviorConfiguration="webBehaviour"
/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:51855/CollectorService.svc" />
</baseAddresses>
</host>
</service>
</services>
And Change your OperationContract
[ServiceContract]
public interface ICollectorService
{
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "Authenticate/{agentcode}/{pin}/{deviceIMEI}/{gpslat}/{gpslong}")]
Authentification Authenticate(string agentcode,string pin, string deviceIMEI, string gpslat, string gpslong);
}
并以这种方式调用您的URL !
http://localhost:51855/CollectorService.svc/CollectorService.svc/Authenticate/YourAgentCode/YourPin/YourDeviceIMEI/YourGPSLat/YourGPSLong
希望这将帮助。谢谢你!
EDIT:如果你正在实现认证机制,我建议你用JSON包装你的请求,而不是在请求URL中发送它。