0

我的 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(如果存在)。

解释

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

4

1 回答 1

0

啊,现在我明白了您在客户端中使用 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>
于 2013-04-18T08:32:53.140 回答