I have a windows forms application. I want to use two different WCF Services that are in no way connected. HOWEVER, I'm not sure how to go about defining the services in my APP.CONFIG file. From what I have read, it is possible to do what I have done below, but I cannot be sure that the syntax is correct or the tags are all present where necessary and I needed some clarification.
So is the below the correct way to setup two services in A SINGLE APP.CONFIG FILE? I.E:
<configuration>
<system.serviceModel>
<services>
<service>
<!--SERVICE ONE-->
<endpoint>
</endpoint>
<binding>
</binding>
</service>
<service>
<!--SERVICE TWO-->
<endpoint>
</endpoint>
<binding>
</binding>
</service>
</services>
</system.serviceModel>
</configuration>
<configuration>
<system.serviceModel>
<services>
<!--SERVICE ONE-->
<service>
<endpoint
address=""
binding="netTcpBinding"
bindingConfiguration="tcpServiceEndPoint"
contract="ListenerService.IListenerService"
name="tcpServiceEndPoint"
/>
<binding
name="tcpServiceEndPoint"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
transactionFlow="false"
transferMode="Buffered"
transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard"
listenBacklog="10"
maxBufferPoolSize="524288"
maxBufferSize="65536"
maxConnections="10"
maxReceivedMessageSize="65536"
>
<readerQuotas
maxDepth="32"
maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384"
/>
<reliableSession
ordered="true"
inactivityTimeout="00:05:00"
enabled="true"
/>
<security mode="None">
<transport
clientCredentialType="Windows"
protectionLevel="EncryptAndSign"
/>
<message clientCredentialType="Windows" />
</security>
</binding>
</service>
<!--SERVICE TWO-->
<service>
<endpoint
address=""
binding="netTcpBinding"
contract="UploadObjects.IResponseService"
bindingConfiguration="TransactedBinding"
name="UploadObjects.ResponseService"
/>
<binding name="TransactedBinding">
<security mode="None" />
</binding>
</service>
</services>
</system.serviceModel>
</configuration>
What do the BEHAVIOURS represent? How do they relate to the service definitions?
Does the Service Name need to be the same as the Binding Name?
You don't have your config quite right:
<configuration>
<system.serviceModel>
<behaviors>
... here you define sets of behaviors - behavior configurations
</behaviors>
<bindings>
... here you define your binding configurations (parameters for bindings)
</bindings>
<services>
<service name="Service1">
... here you define the service endpoint which includes the ABC of WCF:
... (A)ddress, (B)inding, (C)ontract
</service>
<service name="Service2">
... here you define the service endpoint which includes the ABC of WCF:
... (A)ddress, (B)inding, (C)ontract
</service>
....
</services>
</system.serviceModel>
</configuration>
The services and service endpoints can reference behavior configurations, as well as binding configurations, by specifying the behaviorConfiguration=
and bindingConfiguration=
settings respectively.
You should definitely have a look at the WCF Configuration Editor tool to give you a hand at configuring your WCF services! It should be available from the Visual Studio "Tools" menu:
and it looks something like this:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With