2012-01-09 11 views
5

Estoy construyendo un servicio web reparador y una aplicación consoleHost acogerlo servicio web. En el servicio web RESTFUL, llamo al servicio BingTranslate (referencia del enlace a: http://api.microsofttranslator.com/V2/Soap.svc) mi servicio de host con éxito, pero cuando llamo a la función que llama al servicio BingTranslate, esta excepción arroja: "No se pudo encontrar el elemento de punto final predeterminado que hace referencia al contrato" BingTranslator .LanguageService' en la sección de configuración del cliente de ServiceModel. esto podría ser debido a que no se encontró el archivo de configuración para su aplicación, o porque no hay ningún elemento punto final a juego este contrato se pudo encontrar en el elemento cliente ". (Bing Translator es el nombre de referencia de servicio en el proyecto RELAJANTE)Excepción: No se pudo encontrar defecto elemento de punto final cuando llama Bing traduce servicio del servicio RELAJANTE

El app.config del proyecto reparador es:

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_LanguageService" 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> 

     <webHttpBinding> 
     <binding transferMode="Streamed" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" openTimeout="00:25:00" 
       closeTimeout="00:25:00" sendTimeout="00:25:00" receiveTimeout="00:25:00" name="webBinding"> 
     </binding> 
     </webHttpBinding> 

    </bindings> 
    <client> 
     <endpoint address="http://api.microsofttranslator.com/V2/soap.svc" 
     binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_LanguageService" 
     contract="BingTranslator.LanguageService" name="BasicHttpBinding_LanguageService" /> 
    </client> 
    <services> 
     <service name="SearchService.Service1" behaviorConfiguration="SearchService.Service1Behavior"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8732/Design_Time_Addresses/SearchService/Service1/" /> 
      </baseAddresses> 
     </host> 

     <endpoint address="" binding="webHttpBinding" contract="SearchService.IService1" 
        behaviorConfiguration="Web" bindingConfiguration="webBinding"> 

      <identity> 
      <dns value="localhost"/> 
      </identity> 
     </endpoint> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="SearchService.Service1Behavior"> 
      <serviceMetadata httpGetEnabled="True"/> 
      <serviceDebug includeExceptionDetailInFaults="False" /> 
     </behavior> 
     </serviceBehaviors> 
     <endpointBehaviors> 
     <behavior name="Web"> 
      <webHttp/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    </system.serviceModel> 

y el archivo app.config de ConsoleHost así:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="NewBehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
     </behavior> 
     </serviceBehaviors> 
     <endpointBehaviors> 
     <behavior name="Web"> 
      <webHttp/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <services> 
     <service behaviorConfiguration="NewBehavior" name="SearchService.Service1"> 
     <clear /> 
     <endpoint address="" binding="webHttpBinding" contract="SearchService.IService1" 
      behaviorConfiguration ="Web" /> 
     <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" 
      contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8787/searchservice" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    </system.serviceModel> 
</configuration> 

"Este error puede surgir si llama al servicio en una biblioteca de clase y llama a la biblioteca de clase desde otro proyecto". -> Tal vez esta es mi situación. Pero no sé cómo arreglarlo.

¿Qué debo hacer? Por favor, ayúdenme. Muchas gracias. Saludos cordiales

Respuesta

2

Si tiene el cliente del servicio en un proyecto de biblioteca de clases diferente, la configuración del cliente wcf (es decir, la sección system.servicemodel en app.config) no es heredada por el proyecto de referencia. Debe copiar la sección System.ServiceModel de app.config en el proyecto de la biblioteca de clase en app.config en el proyecto exe.

+0

Lo he hecho. Muchas gracias. ¡Yeath! – Mide

+0

Hi..can por favor enviar el código para ello. – user3217843

Cuestiones relacionadas