Multiple Service Address Configurations in a Silverlight Silverlight Application

My team is building our first major Silverlight application using a three-layer architecture and WCF. So far, we have developed about 10 separate WCF services in the middle layer, and this number will only grow.

Typically, the presentation layer (for example, a Silverlight application) refers to services hosted on our dev server. However, there are times when I want him to access services from localhost - that is. machine developer.

Is there an easy way to change where the view layer is looking for services? Is there a way to easily switch between the options here?

+1
source share
2 answers

,

, , - "" , "dev machine".

WCF :

<system.serviceModel>
  <client configSource="client.normal.config" />
</system.serviceModel>

"dev machine",

<system.serviceModel>
  <client configSource="client.localhost.config" />
</system.serviceModel>

:

[client.normal.config]

<?xml version="1.0" encoding="utf-8" ?>
<client>
    <endpoint name="...." address="http://YourServer/Service1" ...... />
    <endpoint name="...." address="http://YourServer/Service2" ...... />
    ....
    <endpoint name="...." address="http://YourServer/ServiceX" ...... />
</client>

[client.localhost.config]

<?xml version="1.0" encoding="utf-8" ?>
<client>
    <endpoint name="...." address="http://localhost/Service1" ...... />
    <endpoint name="...." address="http://localhost/Service2" ...... />
    ....
    <endpoint name="...." address="http://localhost/ServiceX" ...... />
</client>

, localhost - .

WCF - .NET. ( ) *.config. WCF ( <system.serviceModel> node, , ).

+2

, , ServiceReferences.ClientConfig, , - , .

- URL- web.config -, silverlight initParams. , , .

+1

Source: https://habr.com/ru/post/1746980/


All Articles