简体   繁体   English

找不到WCF服务的端点

[英]Endpoints for a WCF service not found

I created WCF service. 我创建了WCF服务。 when i test it with WCF Test Client , the service works fine. 当我使用WCF测试客户端对其进行测试时,该服务可以正常运行。 I decided to configure the end point to display the result using the browser. 我决定配置端点以使用浏览器显示结果。

I have a blank page with the text Endpoint not found. 我有一个空白页面, 找不到文本Endpoint。 with no more details. 没有更多细节。

Here is my web.config 这是我的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" />

Here is my ICollectorService 这是我的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);

}

Any Help. 任何帮助。

Try modifying your Service like this: 尝试像这样修改您的服务:

<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 并更改您的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);

}

And Call your URL in this way! 并以这种方式调用您的URL!

http://localhost:51855/CollectorService.svc/CollectorService.svc/Authenticate/YourAgentCode/YourPin/YourDeviceIMEI/YourGPSLat/YourGPSLong

Hope this will help. 希望这会有所帮助。 Thank You! 谢谢!

EDIT: I will recommend you to wrap your request in JSON instead of sending it in the Request URL if you are implementing Authentication mechanism. 编辑:如果您要实施身份验证机制,建议您将请求包装在JSON中,而不是在请求URL中发送。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM