最後に、クライアント側の構成ファイルを説明
構成ファイルを作成するにあたっては、VisualStudio2010の
「サービス参照の追加」を利用して作成するとある程度ひな形が作成できる
(svcutilで作成されるものと同じもの)
サービス参照の追加ダイアログを開き
アドレスを入力
http://xxx.co.jp:80/Service/Service1.svc
移動ボタンをクリックすると
サービスの内容がしたに表示される
OKボタンで、ソースが生成される
この時、構成ファイルも追加される
(赤字)
一部、設定を追加する
(青字)
ClientBehaviorの定義によって、とりあえずルート証明がない証明書も許可しておく
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ITraceLogService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="None" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="ClientBehavior">
<clientCredentials>
<serviceCertificate>
<authentication certificateValidationMode="PeerOrChainTrust" />
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="http://xxx.co.jp/Service/Service1.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ITraceLogService"
contract="MainService.ITraceLogService" name="WSHttpBinding_ITraceLogService" behaviorConfiguration="ClientBehavior">
<identity>
IDが生成される一部省略
<certificate encodedValue="AwAAAAEAAAAUAAAAnvfi4F7J ---------- " />
</identity>
</endpoint>
</client>
</system.serviceModel>

PR