我寫了一個Web服務。我寫了一個網站。我希望網站BLL代碼可以調用Web服務。如何使用可配置的URL調用Web服務
我有一個配置表與此服務的URL。我將Web服務URL注入到調用代碼中。我應該使用C#中的哪個Web客戶端或套接字可以接收動態Web服務URL?
我想使用方法:
WebClient webClient = new WebClient();
UTF8Encoding response = new UTF8Encoding();
string originalStr = response.GetString(webClient.DownloadData(BLLConfig.Current);
但也許有更優雅的方式?
我在運行時從數據庫表加載配置。
這裏是我嘗試過使用在Visual Studio中的Web引用:
using (var client = new GetTemplateParamSoapClient("GetTemplateParamSoap"))
{
TemplateParamsKeyValue[] responsArray = client.GetTemplatesParamsPerId(CtId, tempalteIds.ToArray());
foreach (var pair in responsArray)
{
string value = FetchTemplateValue(pair.Key, pair.Value);
TemplateComponentsData.Add(pair.Key, value);
}
}
當你說你從一個db表中加載配置時 - 你的意思只是web服務的不同URL(然後看到我的答案並跟隨鏈接)或不同WSDLs(這些Web服務中真正不同的功能)? – Yahia
@Yahia,只是網址。同樣的WSDL –