Visual Studio를 통해 WCF를 등록 할 때 App.config에서 생성 된 값에서 바인딩 또는 끝점을 지정하지 않고 서비스를 만들면 정상적으로 작동하는 WCF 서비스가 있습니다. (값은 설정에서 읽기 때문에)WCF : 이러한 App.config 값을 프로그래밍 방식으로 다시 만들려면 어떻게해야합니까?
return new SmsServiceReference.SmsEngineServiceClient();
이 작품을 좋아 :
나는 서비스 참조를 반환하는 간단한 방법이있다. 그러나, 나는 데이터베이스 (예를 들어, URI)이 값의 일부를 가지고 싶습니다과 같은 것을 할 싶습니다 :이 작동하지 않습니다 Binding binding = new BasicHttpBinding();
EndpointAddress endpointAddress = new EndpointAddress("my.uri.com/service.svc");
return new SmsServiceReference.SmsEngineServiceClient(binding,endpointAddress);
. 서비스 참조를 사용하려고하면 예외가 throw됩니다.
내 App.config에 두 줄이 제공되지 않는다는 정보가 더 많기 때문에 의심 스럽습니다. 문제는 어떻게 App.Config 값을 프로그래밍 방식으로 복제 할 수 있습니까?
다음은 내 App.Config의 일부입니다 (URI가 inocent를 보호하기 위해 변경되었습니다).
<endpoint address="http://www.myuri.com/Services/Services.svc/basic"
하지만 코드 샘플에서
, 당신은 만들 :EndpointAddress endpointAddress = new EndpointAddress("my.uri.com/service.svc");
주소는 일치해야합니다
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ISmsEngineService" 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>
</bindings>
<client>
<endpoint address="http://www.myuri.com/Services/Services.svc/basic"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISmsEngineService"
contract="SmsServiceReference.ISmsEngineService" name="BasicHttpBinding_ISmsEngineService" />
</client>
트릭을했습니다. 감사. –