【发布时间】:2021-01-13 16:23:33
【问题描述】:
我有一个简单的 ASP.Net C# 应用程序,它从 Web 服务获取一些信息,然后将其显示在网页的 iframe 中。应用程序大部分时间都运行良好,除非托管 Web 服务的服务器由于某种原因关闭或不可用。请参考 web.config 片段和带有 web 服务 url 的行。当 Web 服务服务器不可用时,该错误会突出显示
<configuration>
<system.web>
::: ::: :::
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WebServiceSoap" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://locaionOfWebService/WebService1.asmx"
binding="basicHttpBinding" bindingConfiguration="SampleWebServiceSoap"
contract="ServiceReference1.WebServiceSoap" name="WebServiceSoap" />
</client>
</system.serviceModel>
</configuration>
代码;正在使用 basicHttpBinding。
var webservice = new OffSiteWebService.WSSoapClient("WSSoap1");
var data = webservice.GetWebServiceInfo(parm1, parm2);
【问题讨论】:
-
请添加您用于调用服务的代码示例。这将有助于您得到回复。
-
我怀疑调用 Web 服务的代码需要随所使用的绑定一起更改。但是当前实际进行调用的代码工作正常,除非远程服务器关闭/不可用。当远程服务器关闭时,
web.config文件本身会收到错误,而不是调用 web 服务的代码。此外,我尝试的第一件事是向服务器创建一个get request,并且只有在响应代码为 200 OK 时才调用 Web 服务。这时我意识到是 web.config 文件本身出现错误,因为它无法配置 Web 服务端点。 -
注意:正在使用 basicHttpBinding。
var webservice = new OffSiteWebService.WSSoapClient("WSSoap1"); var data = webservice.GetWebServiceInfo(parm1, parm2); -
请将附加信息添加到您的问题中,以便您执行所有步骤。
标签: asp.net web-services web-config