c-我的wcf的端点出现问题



我的WCF服务web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="ZesdaagseResultsContext" connectionString="Data Source=194.33.112.88partywhere;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(如果存在(。

解释

我找过了,但没有修好。我的端点有问题,但我不知道是什么。

啊,现在我看到了您正在客户端中使用basicHttpBinding,在服务中使用webHttpBinding(REST(。。。这可能就是它不起作用的原因,不是吗?

额外的仅供参考:我试着自己调用您的服务,现在我得到了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>

最新更新