您应该能够只与一位客户脱身。如果合约相同,您可以通过编程方式指定端点配置和远程地址。
让我们说你有这样的事情:
1) Staging - http://staging/Remote.svc
2) Production - http://production/Remote.svc
如果您使用的是 Visual Studio,您应该能够从任一端点生成客户端。
那么,您应该能够执行以下操作:
C#代码:
OurServiceClient client;
if (clientRequest == "Staging")
client = new OurServiceClient("OurServiceClientImplPort", "http://staging/Remote.svc");
else
client = new OurServiceClient("OurServiceClientImplPort", "http://production/Remote.svc");
这应该允许您使用一组对象来传递。上面的“OurServiceClientImplPort”部分引用了端点的配置文件:
配置:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="OurServiceClientSoapBinding" openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="128" maxStringContentLength="9830400" maxArrayLength="9830400" maxBytesPerRead="40960" maxNameTableCharCount="32768"/>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" realm=""/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<!-- This can be either of the addresses, as you'll override it in code -->
<endpoint address="http://production/Remote.svc" binding="basicHttpBinding" bindingConfiguration="OurServiceClientSoapBinding" contract="OurServiceClient.OurServiceClient" name="OurServiceClientImplPort"/>
</client>
</system.serviceModel>