BruceLee
DocumentDiscussion

导航

 

环境:

Webservice部署到内网机器,地址:http://aaa.bbb.ccc.ddd/xkzjk/LicensesService.asmx

通过端口影射到外网地址:http://eee.fff.ggg.hhh:88/xkzjk/LicensesService.asmx

同事碰到的第一个问题:

在Visual Studio中引用Webservice报如下错误:

在Visual Studio 2008下报如下错误:

Unable to download following files from.

http://eee.fff.ggg.hhh:88/xkzjk/LicensesService.asmx?wsdl

Do you want to skip these files and continue?

image

在Visual Studio 2010报如下错误:

An error(Details) occurred while attempting to find services at ‘http://eee.fff.ggg.hhh:88/xkzjk/LicensesService.asmx

元数据包含无法解析的引用:“http://eee.fff.ggg.hhh:88/xkzjk/LicensesService.asmx?wsdl”。
下载“http://eee.fff.ggg.hhh:88/xkzjk/LicensesService.asmx?wsdl”时出错。
请求因 HTTP 状态 503 失败: Service Temporarily Unavailable。
元数据包含无法解析的引用:“http://eee.fff.ggg.hhh:88/xkzjk/LicensesService.asmx?wsdl”。
元数据包含无法解析的引用:“http://eee.fff.ggg.hhh:88/xkzjk/LicensesService.asmx?wsdl”。
If the service is defined in the current solution, try building the solution and adding the service reference again.

原因:

开发人员对Webservice不懂,WSDL不知道是干什么的,引用的地址少了?wsdl,第一个问题解决。

 

同事碰到的第二个问题:

调用具体webservice方法时时报如下错误

请求因 HTTP 状态 503 失败: Service Temporarily Unavailable。

说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Net.WebException: 请求因 HTTP 状态 503 失败: Service Temporarily Unavailable。

分析:

具体去看异常内部信息:

ResponseUri={http://eee.fff.ggg.hhh/xkzjk/LicensesService.asmx},开始没仔细看,后来找了很久,发现少了外网映射的端口88。

原因:

在Visual Studio 2008中引用Webservice时,在Web.config中自动增加如下节

<applicationSettings>
    <Test.Web.Properties.Settings>
      <setting name="Test_Web_LicService_LicensesService" serializeAs="String">
        <value>http://eee.fff.ggg.hhh/xkzjk/LicensesService.asmx</value>
      </setting>
    </Test.Web.Properties.Settings>
  </applicationSettings>

在工程的Settings.settings文件中增加了App的设置,代理类会使用该设置的变量。

在Visual Studio 2010中引用Webservice时,在Web.config中自动增加如下节

endpoint address="http://eee.fff.ggg.hhh/xkzjk/LicensesService.asmx"
        binding="basicHttpBinding" bindingConfiguration="LicensesServiceSoap"
        contract="ServiceReference1.LicensesServiceSoap" name="LicensesServiceSoap" />

定义了Webservice的一些基本信息。

 

请注意Visual Studio都把端口去掉了。手动在Web.config里增加上88端口问题解决。

 

总结:第一个问题是因为对Webservice的原理不明白。第二个对Visual Studio引用Webservice的原理不清楚,只会用,现在很多人对Webservice的一些基本理论知识都不明白,就是上来就用Visual Studio引用,然后调用。

posted on 2012-03-28 10:21  Bruce Lee  阅读(14065)  评论(1编辑  收藏  举报