WCF Json-Service: Prüfen Sie, dass sender und Empfänger ist EndpointAddresses Stimmen

Ich gearbeitet habe .NET für eine Weile jetzt, aber ich bin neu in WCF. Ich versuche, meine erste WCF-Dienst mithilfe von JSON. Ich dachte, ich würde anfangen, wirklich, wirklich einfach und erstellen Sie dann von dort. Aber ich habe es irgendwie geschafft, zu Schrauben, bis sogar die einfachsten Dienste. Hier ist, was ich habe, so weit.

Web.Config:

   <?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="MarathonInfo.MarathonInfoService">
        <endpoint address="http://localhost:10298/MarathonInfoService.svc" binding="webHttpBinding" contract="MarathonInfo.IMarathonInfo" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="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>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

Dann, in der service-Datei:

namespace MarathonInfo
{
    public class MarathonInfoService : IMarathonInfo
    {
        public String GetData()
        {
            return "Hello World";
        }
    }
}

Und in der Schnittstelle:

namespace MarathonInfo
{
    [ServiceContract]
    public interface IMarathonInfo
    {

        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/GetData", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        String GetData();
    }
}

So, wenn ich auf diese url:

http://localhost:10298/MarathonInfoService.svc/GetData

Bekomme ich diesen Fehler:

Die Nachricht mit An
'http://localhost:10298/MarathonInfoService.svc/GetData' kann nicht sein
verarbeitet der receiver, aufgrund einer AddressFilter mismatch am
EndpointDispatcher. Überprüfen Sie, dass sender und Empfänger ist
EndpointAddresses Zustimmen.

Ich bin in der Lage, führen Sie den service einfach gut, über Visual Studio im debug-Modus. Aber im browser bekomme ich nur diesen Fehler.

Was mache ich falsch?

Dank!

Casey

InformationsquelleAutor user1418704 | 2012-05-26

Schreibe einen Kommentar