2014-10-02 8 views
0

안녕하세요, 저는 C# 클라이언트 응용 프로그램을 WCF 웹 서비스에 연결하려고합니다. 바인딩의 구성은 클라이언트의 app.config 파일에 있습니다.app.config 파일에서 WCF 바인딩을 만들려고 할 때 예외가 발생했습니다.

웹 서비스 (https 연결)를 instatiate로 호출하면 다음 오류가 발생합니다.

예외 정보 :

System.InvalidOperationException: Could not find default endpoint element that references contract 'TcWcfServices.ITcWcfService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element. 
    at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName) 
    at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address) 
    at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress) 
    at System.ServiceModel.ConfigurationEndpointTrait`1.CreateSimplexFactory() 
    at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait) 
    at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef() 
    at xx.Int.Biz.Services.TMOScheduling.TcWcfServices.TcWcfServiceClient..ctor() 

내 코드에 간단한 전화 내 TMOSAcheduling.exe.config 파일에서

if (_wcfClient == null) 
     _wcfClient = new TcWcfServiceClient(); 

나는 시도하고 WCF 서비스에 바인딩이 조각을 가지고있다. 누군가가 나에게 내가 내가 인스턴스화하고 서비스를 호출 할 수 있습니다 바인딩 HTTPS를 추가하는 방법에 대한 갈 수도 무슨 문제가 될 것 또는 방법에 대한 몇 가지 제안을 줄 수 있다면

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpsBinding_ITcWcfService" closeTimeout="00:01:00" 
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" 
     allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
     maxBufferSize="33554432" maxBufferPoolSize="524288" maxReceivedMessageSize="33554432" 
     messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
     useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="999999999" maxStringContentLength="999999999" 
      maxArrayLength="999999999" maxBytesPerRead="999999999" maxNameTableCharCount="999999999" /> 
      <security mode="Transport"> 
      <transport clientCredentialType="None" 
         proxyCredentialType="None" 
         realm=""/> 
      <message clientCredentialType="UserName" 
        algorithmSuite="Default"/> 
      </security> 
     </binding> 

     </basicHttpBinding> 
    </bindings> 

    <!-- If Environment is HTTPS then use below client and comment out HTTP Client--> 
    <!-- HTTPS Client --> 

    <client> 
     <endpoint address="https://xyz.externalhttpsAddredd.net/TcWcfServices/TcWcfServices.svc" 
       behaviorConfiguration="TcWcfServicesBehavior" 
       binding="basicHttpBinding" 
       bindingConfiguration="BasicHttpsBinding_ITcWcfService" 
       contract="TcWfcServices.ITcWcfService" 
       name="BasicHttpsBinding_ITcWcfService" /> 
    </client> 

    <behaviors> 
     <endpointBehaviors> 
     <behavior name="TcWcfServicesBehavior"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    </system.serviceModel> 

가 궁금하네요.

이 설정 파일은 HTTPS가 아니고 localhost 개발 웹 서비스 사이트에있는 동일한 이름의 서비스에 대해 개발할 때 "손으로 생성"해야합니다.

또한이 클라이언트 응용 프로그램은 내 dev에서 실행할 수 없습니다. 왜냐하면 내가 dev에 서버 URL에 연결할 수 없습니다. 기계

고마워요! 나는이 일을 실현하기위한 위기 상황에 처해 있으며 비슷한 결과로 생각할 수있는 모든 것을 시도했다. 여기

EDIT는 두 번째 구성 파일

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpsBinding_ITcWcfService" 
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" 
     allowCookies="false" bypassProxyOnLocal="false"  hostNameComparisonMode="StrongWildcard" 
    maxBufferSize="33554432" maxBufferPoolSize="524288" maxReceivedMessageSize="33554432" 
    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
    useDefaultWebProxy="true"> 
     <readerQuotas maxDepth="999999999" maxStringContentLength="999999999" 
     maxArrayLength="999999999" maxBytesPerRead="999999999" maxNameTableCharCount="999999999" /> 
     <security mode="Transport"> 
     <transport clientCredentialType="None" 
        proxyCredentialType="None" 
        realm=""/> 
     <message clientCredentialType="UserName" 
       algorithmSuite="Default"/> 
     </security> 
    </binding> 
    </basicHttpBinding> 
</bindings> 

<client> 
    <endpoint address="https://xxxxxx.testexternal.net/TcWcfServices/TcWcfServices.svc" 
      behaviorConfiguration="TcWcfServicesBehavior" 
      binding="basicHttpBinding"    
      contract="TcWfcServices.ITcWcfService" /> 
</client> 
<behaviors> 
    <endpointBehaviors> 
    <behavior name="TcWcfServicesBehavior"> 
     <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
    </behavior> 
    </endpointBehaviors> 
</behaviors> 
입니다

Second edit. This worked but had certificate errors due to the https 

    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="BasicHttpBinding_ITcWcfService" 
      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="Transport"> 
      <transport clientCredentialType="None" 
      proxyCredentialType="None" 
      realm="" /> 
      <message clientCredentialType="UserName" 
      algorithmSuite="Default" /> 
      </security> 
      </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="https://txxxx.external.net/TcWcfServices/TcWcfServices.svc" 
      binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_ITcWcfService" 
      contract="TcWcfServices.ITcWcfService" 
      name="BasicHttpBinding_ITcWcfService" /> 
    </client> 
    </system.serviceModel> 

답변

1

문제는 그것을 만들 제거해야 하나 당신은 귀하의 <endpoing> 요소는 name 속성이 정의되어 있다는 것입니다 해당 계약의 "기본 엔드 포인트"또는 클라이언트 프록시 오브젝트의 생성자에서 수동으로 엔드 포인트 이름을 지정하십시오. http://msdn.microsoft.com/en-us/library/ms731762(v=vs.110).aspx

선택적 문자열 속성에서 문서에서

. 이 속성은 지정된 계약의 끝점을 고유하게 식별합니다. 지정된 계약 유형 에 대해 여러 클라이언트를 정의 할 수 있습니다. 각 정의는 고유 구성 이름으로 구분해야합니다. 이 속성이 생략되면 해당 끝점 지정된 계약 타입와 연관된 기본 포인트로서 사용된다. 기본값은 빈 문자열입니다.

+0

"name ="BasicHttpsBinding_ITcWcfService "를 config에서 제거 했는데도 여전히 오류가 발생합니다. Message ="ServiceModel 클라이언트 구성 섹션에서 계약 'TcWcfServices.ITcWcfService'를 참조하는 기본 끝점 요소를 찾을 수 없습니다. 이는 응용 프로그램에 대한 구성 파일이 없거나이 계약에 일치하는 noelement가 클라이언트 요소에서 발견 될 수 있기 때문일 수 있습니다. – jvoigt

+0

올바른 설정 파일을 사용하고 있습니까? – tomasr

+0

상당히. 서비스에있는 다른 구성 설정은이 동일한 파일에서 확실히 읽혀지고 있습니다. 나는 뭔가 다른 것이 두드러 질 때를 대비하여 파일을 포함시킬 것입니다. – jvoigt

0

대답은 내가 마지막으로 편집 한 것으로 끝났지 만 cert 문제 (다른 모든 것을 함께)가 발생했습니다. 그래서 우리는 결국 HTTP를 사용하지 않게되었습니다.

Tomasr - 제안 사항은 적어도 끝점 등에 대해 알지 못했던 몇 가지 점을 지적하는 데 도움이되었습니다.실제로 올바른 설정을 사용하고 있음을 확인할 수있었습니다. 내가 두 번째로 추측 한 것입니다.