views:

26

answers:

1

I am new to WCF ,i have this config file and i really want to make it cleaner.

<?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) I am trying to get rid of those base addresses but when i run it i get this exception

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

2)If i use svcutil.exe for both services i get some duplicate classes in the client services:

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>
A: 

Don't worry about the cleanliness of the configuration. It's a lot like sausage - you don't want to know the details.

John Saunders
Thanks for the reply John, but what about those duplicate classesI use svcutil net.tcp://localhost:2222/war and svcutil net.tcp://localhost:2222/auth and i get some duplicate classes in those 2 generated proxy. How can i handle this?
boo
@boo: they're not duplicates - they're each in their own different namespace, right? Does your code compile?
John Saunders
No ,it does not compile. The error message i get is that those classes i enumerated in my first post are duplicated..The namespace is the same, should make those namespaces different?
boo
The namespaces should be different if they are different service references. If you're going to use svcutil.exe, then you need to use the /namespace switch to map from the different XML namespaces to different CLR namespaces. If these are really the same type, then have you tried running svcutil _once_ with both WSDL files on the same command line?
John Saunders
I have just tried to execute svcutil with both WSDL files on the same command line, it was generated 1 app.config and 1 fie containing contracts and proxies, no duplicates. I think that this file will get huge so i think that your first solution, to use /namespace for mapping xml<->clr is the one to go for. Thanks for your help.
boo
Why do you care how large the file gets? You're not going to be editing it - it's generated code.
John Saunders