怎样通过https调用web service 函数?

xxxMMMxxx 2004-08-01 11:13:35
新建一控制台程序,加上如下Web引用:
https://arcweb.esri.com/services/v2/Authentication.wsdl

原程序如下:
using System;
using arcweb = ConsoleApplication2.com.esri.arcweb;

namespace ConsoleApplication2
{
class Class1
{
static void Main(string[] args)
{
arcweb.Authentication svr = new arcweb.Authentication();
try
{
Console.WriteLine(svr.getVersion());
}
catch(System.Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.WriteLine("The end.");
Console.ReadLine();
}
}
}


输出如下:
基础连接已经关闭: 无法与远程服务器建立信任关系。
The end.

请问怎么与远程服务器建立信任关系?
...全文
338 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
starky 2004-08-03
  • 打赏
  • 举报
回复
http://ms.mblogger.cn/starky/posts/7266.aspx
CMIC 2004-08-03
  • 打赏
  • 举报
回复
web service返回这个错误提示一般是通过代理上网,代理服务器配置问题,这是访问
http://www.webservicex.net/globalweather.asmx的web service时vs.net自动生成的webservice代理类的代码
其中:
System.Net.WebProxy myProxy
=new System.Net.WebProxy("192.1.1.1",8080);
this.Proxy=myProxy;
是我加入设置代理服务器代码.

代码调试通过,http://www.webservicex.net/globalweather.asmx你也可以访问到,你可以参考一下。


namespace net.webservicex.www{
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Web.Services;


/// <remarks/>
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="GlobalWeatherSoap", Namespace="http://www.webserviceX.NET")]
public class GlobalWeather : System.Web.Services.Protocols.SoapHttpClientProtocol {

/// <remarks/>
public GlobalWeather() {
this.Url = "http://www.webservicex.net/globalweather.asmx";
//指定代理服务器
System.Net.WebProxy myProxy
=new System.Net.WebProxy("192.1.1.1",8080);
this.Proxy=myProxy;
}

/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.webserviceX.NET/GetWeather", RequestNamespace="http://www.webserviceX.NET", ResponseNamespace="http://www.webserviceX.NET", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public string GetWeather(string CityName, string CountryName) {
object[] results = this.Invoke("GetWeather", new object[] {
CityName,
CountryName});
return ((string)(results[0]));
}

/// <remarks/>
public System.IAsyncResult BeginGetWeather(string CityName, string CountryName, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("GetWeather", new object[] {
CityName,
CountryName}, callback, asyncState);
}

/// <remarks/>
public string EndGetWeather(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((string)(results[0]));
}

/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.webserviceX.NET/GetCitiesByCountry", RequestNamespace="http://www.webserviceX.NET", ResponseNamespace="http://www.webserviceX.NET", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public string GetCitiesByCountry(string CountryName) {

object[] results = this.Invoke("GetCitiesByCountry", new object[] {
CountryName});

return ((string)(results[0]));
}

/// <remarks/>
public System.IAsyncResult BeginGetCitiesByCountry(string CountryName, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("GetCitiesByCountry", new object[] {
CountryName}, callback, asyncState);
}

/// <remarks/>
public string EndGetCitiesByCountry(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((string)(results[0]));
}
}
}

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧