<< Klicken Sie hier um das Inhaltsverzeichnis anzuzeigen >> Navigation: Konfiguration > Kommunikation > Server |
Damit sich die Clients mit dem Server verbinden können, muss dieser entsprechende Endpoints (Services) zur Verfügung stellen. Die WCF Einstellungen sind im Tag <system.serviceModel> der App.config enthalten.
Die Konfiguration der Server-Endpoints wird in <system.serviceModel><services> vorgenommen. Hier werden die beiden Services DabisServer und DabisFileTransferService in je einer <service></service> Section konfiguriert. Im <endpoint>-Attribut address="net.tcp://localhost:8000/DabisServer" wird das Protokoll, die Adresse und der Port des Services definiert.
Die Verbindung vom Client und Server wird über ein Zertifikat authentifiziert und verschlüsselt. Dabei liegen das Server und das Client Zertifikat (in unserem Fall sind die beiden identisch) auf dem Filesystem und werden direkt vom Server eingelesen. Damit der Server weiss wo er die Zertifikate findet, muss dies in der Konfiguration festgelegt werden. Dies geschieht in der Section <sohard.dabis.connection.cert>. Dort wird für jeden Service das Server- und das Clientzertifikat im Attribut serverCertificate="Pfad|Passwort" bzw. clientCertificate="Pfad|Passwort" eingestellt. Es muss sichergestellt sein, dass der Server Zugriff auf diesen Pfad hat (wichtig bei UNC-Pfad).
Damit die Section <sohard.dabis.connection.cert> in der App.config erkannt wird muss diese vorgängig in der Section <configSections> hinzugefügt werden <section name="sohard.dabis.connection.cert" type="Sohard.Dabis.Connection.Cert.Configuration.Section, DabisConnection" />
Beispiel WCF-Konfiguration Server:
<system.serviceModel>
<services>
<!-- **** Service Konfiguration für DabisServer **** -->
<service behaviorConfiguration="DabisServerBehavior" name="Sohard.Dabis.Server.DabisServerImpl">
<endpoint name="DabisServer"
address="net.tcp://localhost:8000/DabisServer"
binding="netTcpBinding"
bindingConfiguration="DabisServerTcpBinding"
contract="Sohard.Dabis.ServiceContracts.IServerContract"/>
</service>
<!-- **** Service Konfiguration für DabisFileTransferService **** -->
<service behaviorConfiguration="DabisServerBehavior" name="Sohard.Dabis.Server.DabisFileTransferServiceImpl">
<endpoint name="DabisFileTransferService"
address="net.tcp://localhost:8006/DabisFileTransferService"
binding="netTcpBinding"
bindingConfiguration="DabisStreamingBinding"
contract="Sohard.Dabis.ServiceContracts.IServiceContractFileTransfer"/>
</service>
<!-- **** Service Konfiguration für DabisIndexService (Kommentieren Sie diese Sektion aus, damit der IndexService Webservice nicht gesatrtet wird )**** -->
<service behaviorConfiguration="DabisWebServerBehavior" name="Sohard.Dabis.Server.DabisIndexServiceImpl">
<endpoint address="http://localhost:8080/Web"
binding="webHttpBinding"
bindingConfiguration="DabisIndexServiceBinding"
contract="Sohard.Dabis.ServiceContracts.IServiceContractIndexSearch"
behaviorConfiguration="web" />
</service>
<!-- **** Service Konfiguration für DabisMobileBaseService (Kommentieren Sie diese Sektion aus, damit der DabisMobileBase Webservice nicht gesatrtet wird) **** -->
<service behaviorConfiguration="DabisWebServerBehavior" name="Sohard.Dabis.Server.DabisMobileBaseServiceImpl">
<endpoint address="http://localhost:8081/Web"
binding="webHttpBinding"
bindingConfiguration="DabisWebServiceBinding"
contract="Sohard.Dabis.Contracts.ServiceContracts.IServiceContractMobileBase"
behaviorConfiguration="web" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<!-- Service Behavior für DabisServer und DabisFileTransferService -->
<behavior name="DabisServerBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
<!-- Service Behavior für DabisIndexService und DabisMobileBaseService -->
<behavior name="DabisWebServerBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceThrottling maxConcurrentSessions="100" />
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
<!-- Endpoint Behavior für DabisIndexService und DabisMobileBaseService -->
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<!-- Tcp-Binding für den DabisServer und DabisFileTransferService -->
<netTcpBinding>
<binding name="DabisServerTcpBinding"
openTimeout="00:10:00"
receiveTimeout="00:10:00"
sendTimeout="00:10:00"
transferMode="Buffered"
maxBufferSize="2147483647"
maxConnections="100"
maxReceivedMessageSize="2147483647"
transactionFlow="true">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="16384"/>
<security mode="Transport">
<transport clientCredentialType="Certificate"/>
</security>
</binding>
<binding name="DabisStreamingBinding"
transferMode="Streamed"
maxBufferSize="5000000"
maxReceivedMessageSize="5000000"
transactionFlow="true">
<readerQuotas maxDepth="32"
maxStringContentLength="5000000"
maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384"/>
<security mode="Transport">
<transport clientCredentialType="Certificate"/>
</security>
</binding>
</netTcpBinding>
<!-- Http-Binding für den DabisIndexService und DabisMobileBaseService -->
<webHttpBinding>
<binding name="DabisIndexServiceBinding"
openTimeout="00:02:00"
sendTimeout="00:02:00">
<security mode="None">
</security>
</binding>
<binding name="DabisWebServiceBinding"
openTimeout="00:02:00"
sendTimeout="00:02:00"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
transferMode="Streamed">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="Basic" />
</security>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
<sohard.dabis.connection.cert>
<services>
<add name="DabisServerImpl" serverCertificate="certificates\DabisServer.pfx|wcf" clientCertificates="\certificates\DabisServer.cer"/>
<add name="DabisFileTransferServiceImpl" serverCertificate="certificates\DabisServer.pfx|wcf" clientCertificates="certificates\DabisServer.cer"/>
</services>
</sohard.dabis.connection.cert>