简体   繁体   中英

Endpoints for a WCF service not found

I created WCF service. when i test it with WCF Test Client , the service works fine. 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. with no more details.

Here is 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" />

Here is my 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

[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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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