【发布时间】:2017-12-12 14:00:29
【问题描述】:
我知道这个问题已经被问过(以某种形式),但我是新手,无法让它发挥作用。 问题:需要创建一个我需要从 PowerBuilder(通过 COM)调用的 .NET dll (c#) --> dll 将处理 SOAP 客户端对 Web 服务的调用。
在 .NET 方面没有太多经验,但设法与(例如)公共 Web 服务“对话”。但问题是我不能使用配置文件(否则找不到端点的错误)。
请问,谁能帮我解决这个问题(可能是示例代码)?
这是配置文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="GlobalWeatherSoap" />
</basicHttpBinding>
<customBinding>
<binding name="GlobalWeatherSoap12">
<textMessageEncoding messageVersion="Soap12" />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://www.webservicex.com/globalweather.asmx"
binding="basicHttpBinding" bindingConfiguration="GlobalWeatherSoap"
contract="SrvRefWeather.GlobalWeatherSoap" name="GlobalWeatherSoap" />
<endpoint address="http://www.webservicex.com/globalweather.asmx"
binding="customBinding" bindingConfiguration="GlobalWeatherSoap12"
contract="SrvRefWeather.GlobalWeatherSoap" name="GlobalWeatherSoap12" />
</client>
</system.serviceModel>
</configuration>
我通过 WSDL 文件添加了一个“服务引用”并像这样调用 web 服务(例如):
SrvRefWeather.GlobalWeatherSoapClient client = new SrvRefWeather.GlobalWeatherSoapClient("GlobalWeatherSoap");
string strCities = client.GetCitiesByCountry("Belgium");
谁能告诉我如何在没有配置文件的情况下实现与我所做的相同的操作?
我认为我需要通过“BasicHttpBinding()”,但在我的示例中不知道如何引用“SrvRefWeather”对象。
任何帮助将不胜感激!真的……
谢谢, 马克。
【问题讨论】:
标签: c# web-services wcf soap basichttpbinding