麻烦我的wcf的端点

时间:2013-04-18 06:28:48

标签: c wcf wcf-client wcf-endpoint wcf-configuration

我的WCF服务web.config。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="ZesdaagseResultsContext" connectionString="Data Source=194.33.112.88\partywhere;Initial Catalog=ZesdaagseResults;Persist Security Info=True;User ID=*********;Password=******************/;MultipleActiveResultSets=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.serviceModel>
    <services>
      <service name="WcfOpzet.MobileService" behaviorConfiguration="MexBehavior">
        <endpoint binding="webHttpBinding" contract="WcfOpzet.IMobileService" behaviorConfiguration="webHttpBehavior" />
        <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MexBehavior">
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="webHttpBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
  </startup>
  <system.web>
    <compilation debug="true" />
  </system.web>
</configuration>

我的wcf客户端MobileServiceReference.ClientConfig。

<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="webHttpBinding"
                 maxBufferSize="2147483647"
                 maxReceivedMessageSize="2147483647">
          <security mode="None" />
        </binding>       
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://zesdaagse.mobi-app.be/WCFUrl/MobileService.svc"
                binding="basicHttpBinding"
                bindingConfiguration="webHttpBinding"
                contract="MobileService.IMobileService"
                name="webHttpBinding"

                />
    </client>
    <!--<behaviors>
      <endpointBehaviors>
        <behavior name="webHttpBehavior">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>-->
  </system.serviceModel>
</configuration>

运行Windows Phone应用程序时出现错误。

http://zesdaagse.mobi-app.be/WCFUrl/MobileService.svc没有可以接受该消息的端点。这通常是由错误的地址或SOAP操作引起的。有关更多详细信息,请参阅InnerException(如果存在)。

解释

我搜索但是我没有修复它。我的端点有问题,但我不知道是什么。

1 个答案:

答案 0 :(得分:0)

啊,现在我明白了 您正在使用客户端中的basicHttpBinding和服务中的webHttpBinding(REST)......这可能是它无法正常工作的原因,不是吗?

额外的FYI:我试图自己调用你的服务,现在我得到了405,这可能意味着你没有为你的服务操作指定[WebGet]或[WebInvoke]属性。

使用以下客户端配置,您应该能够调用您的服务(在使用WebGet归属您的操作之后)

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="webHttpBinding"
                 maxBufferSize="2147483647"
                 maxReceivedMessageSize="2147483647">
          <security mode="None" />
        </binding>
      </webHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://zesdaagse.mobi-app.be/WCFUrl/MobileService.svc"
                binding="webHttpBinding"
                bindingConfiguration="webHttpBinding"
                contract="MobileService.IMobileService"
                name="webHttpBinding"
                behaviorConfiguration="webHttpBehavior"
                />
    </client>
    <behaviors>
      <endpointBehaviors>
        <behavior name="webHttpBehavior">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>