2
다음 선언적 (구성 파일을 통한) 바인딩을 명령형 바인딩 (응용 프로그램 내부에서 하드 코딩)으로 변환하는 방법은 무엇입니까?WCF 필수 바인딩
<system.serviceModel>
<bindings>
<customBinding>
<binding name="CustomBinding_IAEService">
<security defaultAlgorithmSuite="Basic256Sha256Rsa15" authenticationMode="MutualCertificateDuplex"
requireDerivedKeys="false" securityHeaderLayout="Lax" includeTimestamp="true" allowSerializedSigningTokenOnReply="true"
keyEntropyMode="CombinedEntropy" messageProtectionOrder="SignBeforeEncrypt"
messageSecurityVersion="Default" requireSignatureConfirmation="false">
<localClientSettings cacheCookies="true" detectReplays="true"
replayCacheSize="900000" maxClockSkew="00:05:00"
replayWindow="00:05:00" sessionKeyRenewalInterval="10:00:00"
sessionKeyRolloverInterval="00:05:00" reconnectTransportOnFailure="true"
timestampValidityDuration="00:05:00" cookieRenewalThresholdPercentage="60" />
<localServiceSettings detectReplays="true" issuedCookieLifetime="10:00:00"
maxStatefulNegotiations="128" replayCacheSize="900000" maxClockSkew="00:05:00"
negotiationTimeout="00:01:00" replayWindow="00:05:00" inactivityTimeout="00:02:00"
sessionKeyRenewalInterval="15:00:00" sessionKeyRolloverInterval="00:05:00"
reconnectTransportOnFailure="true" maxPendingSessions="128"
maxCachedCookies="1000" timestampValidityDuration="00:05:00" />
<secureConversationBootstrap />
</security>
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpsTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" requireClientCertificate="false" />
</binding>
</customBinding>
</bindings>
감사
편집 :
이// configure security properties
AsymmetricSecurityBindingElement security = SecurityBindingElement.CreateMutualCertificateDuplexBindingElement(MessageSecurityVersion.Default);
security.DefaultAlgorithmSuite = SecurityAlgorithmSuite.Basic256Sha256Rsa15;
security.SecurityHeaderLayout = SecurityHeaderLayout.Lax;
security.AllowSerializedSigningTokenOnReply = true;
security.KeyEntropyMode = SecurityKeyEntropyMode.CombinedEntropy;
security.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt;
security.RequireSignatureConfirmation = false;
// configure encoding properties
TextMessageEncodingBindingElement encoding = new TextMessageEncodingBindingElement();
// configure transport properties
HttpsTransportBindingElement transport = new HttpsTransportBindingElement();
CustomBinding customBinding = new CustomBinding(security, encoding, transport);
하지만이 코드가 작동하지 않습니다 내가 함께 tryed
Adislav의 재생 후. 나는 무엇을 놓치나요?
감사
무슨 예외가 발생합니까? 내 예제는 그대로 작동하지 않아야합니다. 똑같은 설정을 원한다면 설정에서 선언 된대로 각 속성을 설정해야합니다 (최소한 기본값을 설명하지 않는 속성). 예를 들어 인코딩 요소의 MessageVersion에는 기본값이 없으므로 코드에서 설정하지 마십시오. –
@Ladislav MessageSecurityVersion은 인스턴스 생성 중에 지정됩니다 (AsymmetricSecurityBindingElement security = SecurityBindingElement.CreateMutualCertificateDuplexBindingElement (MessageSecurityVersion.Default);). MessageSecurityException - "보안되지 않은 또는 잘못 확보 된 오류가 상대방으로부터 수신되었습니다. 오류 코드 및 세부 사항에 대한 내부 FaultException을 참조하십시오." 내부 예외는 "조치가 유효하지 않거나 인식 할 수 없으므로 메시지를 처리 할 수 없습니다." 구성 파일에서 구성을 시도하면 모든 것이 잘 작동합니다. –
그래서 이전 주석에서 언급 한 내용입니다. 메시지 버전과 메시지 보안 버전은 두 가지 설정입니다. 보안 버전은 보안 바인딩 요소에 설정되는 반면 메시지 버전은 인코딩 요소에 설정됩니다. 구성에 Soap12 메시지 버전이 정의되어 있지만 인코딩 요소가 Soap12WSAddressing10 인 기본값으로 정의되므로 코드에서 사용하지 않습니다. –