WCF - 如何使此配置更清晰

时间:2010-07-13 17:22:44

标签: wcf wcf-binding

我是WCF的新手,我有这个配置文件,我真的想让它更清洁。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="warConfig" name="Service.WarService">
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:2222/war"/>
          </baseAddresses>
        </host>
        <endpoint address="" binding="netTcpBinding" contract="Service.IWarService"/>
        <endpoint address="MEX" binding="mexTcpBinding" contract="IMetadataExchange" />
      </service>
      <service behaviorConfiguration="authConfig" name="Service.AuthService">
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:2222/auth"/>
          </baseAddresses>
        </host>
        <endpoint address="" binding="netTcpBinding" contract="Service.IAuthService"/>
        <endpoint address="MEX" binding="mexTcpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="warConfig">
          <serviceMetadata />
        </behavior>
        <behavior name="authConfig">
          <serviceMetadata />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <connectionStrings>
    <add name="WarDatabaseEntities" connectionString="metadata=res://*/WarModel.csdl|res://*/WarModel.ssdl|res://*/WarModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=BOGUS\SQLEXPRESS;Initial Catalog=WarDatabase;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>

1)我试图摆脱那些基地址但是当我运行它时我得到了这个异常

Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [].

2)如果我对两种服务使用svcutil.exe,我会在客户端服务中获得一些重复的类:

public partial class ObjectChangeTracker : object, System.Runtime.Serialization.IExtensibleDataObject
public class ExtendedPropertiesDictionary : System.Collections.Generic.Dictionary<string, object>
public class ObjectsAddedToCollectionProperties : System.Collections.Generic.Dictionary<string, Service.ObjectList>
public class ObjectsRemovedFromCollectionProperties : System.Collections.Generic.Dictionary<string, Service.ObjectList>
public class OriginalValuesDictionary : System.Collections.Generic.Dictionary<string, object>
public enum ObjectState : int
public class ObjectList : System.Collections.Generic.List<object>

1 个答案:

答案 0 :(得分:0)

不要担心配置的清洁度。这很像香肠 - 你不想知道细节。