![](/img/trans.png)
[英]Call a callback method on WCF server wihout waiting client must finish
[英]Create a WCF Client wihout Configuration File
請幫助我...
如何在app.config中未指定客戶端配置的情況下創建WCF客戶端。
我看過這個鏈接
.NET - 在沒有app.config的情況下部署WCF客戶端
但是,您需要按屬性指定配置屬性。 無論如何我們可以將app.config配置用作單個字符串並分配給一個類並完成它嗎?
喜歡
var config=GetEndpointConfig(endPointName);
var bindingData=GetBinding(nameodBinding);
其中該方法返回像這樣的字符串中的整個配置。
終點:
<endpoint address="http://localhost:61144/Sampler.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_Iervice" contract="IService"
name="BasicHttpBinding_IService" />
捆綁 :
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
我不想導入配置文件並在當前應用程序中加載配置,因為還有其他模塊將受到影響。 我引用了這個正在使用的例子
System.Configuration.Configuration config =
System.Configuration.ConfigurationManager.OpenMappedExeConfiguration
(filemap,
System.Configuration.ConfigurationUserLevel.None);
提前致謝!!!
無論如何我們可以將app.config配置用作單個字符串並分配給一個類並完成它
沒有。
如果使用所有綁定參數的默認值創建服務,則可以像下面這樣使用它:
using System.ServiceModel;
var factory = new ChannelFactory<IMyServiceInterface>(
new BasicHttpBinding(), <-- or whatever binding your service uses
new EndpointAddress("http://MyServiceUrl"));
var proxy = factory.CreateChannel();
然后,您可以通過代理訪問服務操作。
UPDATE
根據您的評論,請查看以下鏈接:
所以不,沒有辦法很好地做到這一點(盡管你可以看看Chinchoo框架)。
是的,您可以在此處加載為客戶端加載配置文件提供的配置文件
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.