WCF服务+客户端绑定端点

时间:2015-02-05 14:47:37

标签: c# .net wcf wcf-binding service-model

我的问题在于绑定。当我在调试模式下运行我的客户端但它不能在发布模式下工作时,它可以工作。 服务器和客户端在同一台计算机上运行。

    Unhandled Exception: System.ServiceModel.EndpointNotFoundException: 
There was no endpoint listening at http://localhost:8733/Design_Time_Addresses/ServiceLibrary/Service1/ that
     could accept the message. This is often caused by an incorrect address or SOAP
    action. See InnerException, if present, for more details.

服务器App.config:

    <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service name="ServiceLibrary.Service" behaviorConfiguration="metadataAndDebug">
        <endpoint address="" binding="basicHttpBinding" contract="ServiceLibrary.IService">
        </endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8733/Design_Time_Addresses/ServiceLibrary/Service1/" />
          </baseAddresses>
        </host>
        <!-- Metadata Endpoints -->
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <!-- 
          Step 2. Inside a <serviceBehaviors> section, add 
          a name attribute in the <behaviors> element that 
          matches the behaviorConfiguration attribute in the
          <service> element above.
        -->
        <behavior name="metadataAndDebug">
          <serviceMetadata httpGetEnabled="true" httpGetUrl="" httpsGetEnabled="True" />
          <!-- 
            Step 3. Add a <serviceDebug> element and 
            modify the various attributes that suit your 
            scenario.
          -->
          <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

客户端App.config:

 <?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IService" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:8733/Design_Time_Addresses/ServiceLibrary/Service1/"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
                contract="ServiceReference.IService" name="BasicHttpBinding_IService" />
        </client>
    </system.serviceModel>
</configuration>

任何解决方案?

0 个答案:

没有答案