2010-04-19 11 views
3

J'ai un service WCF qui a exposé un point de terminaison de savon et un XML. Lorsque j'utilise svcutil pour générer le code proxy du côté client, la configuration générée contient deux points de terminaison qui provoquent l'échec du client. Si je modifie le fichier web.config et supprime le second point de terminaison (avec la liaison personnalisée) tout fonctionne comme prévu. Est-ce que je peux obtenir svcutil pour générer une config qui fonctionne juste de sorte que je n'ai pas besoin de modifier manuellement le fichier à chaque fois?Svcutil générant une mauvaise configuration avec plusieurs points de terminaison

erreur côté client:

An endpoint configuration section for contract 'MyNamespace.ITestService' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name.

commande Svcutil:

svcutil http://api.local/Test.svc 
    /reference:bin\MyNamespace.Interface.dll 
    /config:web.config 
    /mergeConfig 
    /out:"Service References\TestService.cs" 
    /n:*,MyNamespace 

généré config client:

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="BasicHttpBinding_ITestService" closeTimeout="00:01:00" 
       openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
       allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
       messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
       useDefaultWebProxy="true"> 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
        maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
       <security mode="None"> 
        <transport clientCredentialType="None" proxyCredentialType="None" 
         realm="" /> 
        <message clientCredentialType="UserName" algorithmSuite="Default" /> 
       </security> 
      </binding> 
     </basicHttpBinding> 
     <customBinding> 
      <binding name="CustomBinding_ITestService"> 
       <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" 
        messageVersion="Soap12" writeEncoding="utf-8"> 
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
         maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
       </textMessageEncoding> 
      </binding> 
     </customBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://api2.local/Test.svc/soap" binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_ITestService" contract="MyNamespace.ITestService" 
      name="BasicHttpBinding_ITestService" /> 
     <endpoint binding="customBinding" bindingConfiguration="CustomBinding_ITestService" 
      contract="MyNamespace.ITestService" name="CustomBinding_ITestService" /> 
    </client> 
</system.serviceModel> 
+0

Que contient votre fichier de configuration de service? – Franchesca

Répondre

0

Vous devez spécifier le nom de la configuration des terminaux. Il n'y a pas moyen de contourner le problème car ils utilisent le même contrat. C'est pourquoi System.ServiceModel.ClientBase a cet argument constructeur.

var client = new TestClient("CustomBinding_ITestService");