getWeatherbyCityName(city),服务器无法处理请求。 ---> 未将对象引用设置到对象的实例。
来源:互联网 发布:山东网络微信投票公司 编辑:程序博客网 时间:2024/06/03 14:43
⑴在需要调用WebService的项目上,点击鼠标右键,选择添加Service Reference,进入'Add Service Reference‘界面
⑵点击'Advanced'按钮,进入'Service Reference Settings'界面
⑶点击'Add Web Reference'按钮,进入'Add Web Reference'界面
①在'URL'文本框中,填写需要引用的WebService的地址(例如:http://www.webxml.com.cn/WebServices/WeatherWebService.asmx)
②点击右边的绿色方框按钮,程序会自动前往给定的地址查找WebService服务
③在'Web Reference Name'文本框中,自定义此次添加的WebService的名称(例如:Weather)
④点击'Add Reference'按钮,程序自动将找的WebService添加的当前的项目中,并自动放在Web References文件夹中.
自己写了个程序,测试成功,主要代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ServiceModel;
using System.Runtime.InteropServices;
namespace weather2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
weather2.Weather.WeatherWebService webc = new weather2.Weather.WeatherWebService();
string[] s = new string[23];//声明一个string数组存放其返回的结果
string city = this.textBox1.Text.Trim();//获得文本框1的内容
s = webc.getWeatherbyCityName(city);
MessageBox.Show("西安气象:" + "\r\n" +"天气:" +s[6] + "\r\n" + "温度:" + s[5]);
}
catch (Exception e1)
{
MessageBox.Show(e1.ToString());
}
}
}
}
测试图见下:
回到”服务器无法处理请求。 ---> 未将对象引用设置到对象的实例“这个问题,估计是VS版本的问题,因为网上看人家用的是VS2008,但我用的是VS2010,不管怎么样,这个问题还是给了个交代,可以安照上面的方法访问天气WebService。
- getWeatherbyCityName(city),服务器无法处理请求。 ---> 未将对象引用设置到对象的实例。
- WebService客户端引用 服务器无法处理请求。 ---> 未将对象引用设置到对象的实例
- axis2.AxisFault: 服务器无法处理请求。 ---> 未将对象引用设置到对象的实例。
- axis2.AxisFault: 服务器无法处理请求。 ---> 未将对象引用设置到对象的实例。
- 服务器无法处理请求。 ---> 未将对象引用设置到对象的实例
- 未将对象引用设置到对象的实例"
- 未将对象引用设置到对象的实例
- 未将对象引用设置到对象的实例
- session未将对象引用设置到对象的实例
- 未将对象引用设置到对象的实例
- 未将对象引用设置到对象的实例
- ConfigurationManager:未将对象引用设置到对象的实例。
- 未将对象引用设置到对象的实例 解决办法
- 未将对象引用设置到对象的实例
- 未将对象引用设置到对象的实例
- 未将对象引用设置到对象的实例 原因
- 未将对象引用设置到对象的实例
- 未将对象引用设置到对象的实例
- Asp.Net学习之数据验证控件(二)
- Linux Shell常用技巧
- BZOJ 1455 罗马游戏 左偏树
- DSP时钟之看门狗
- fuck面试
- getWeatherbyCityName(city),服务器无法处理请求。 ---> 未将对象引用设置到对象的实例。
- MD5加密
- hdu 5093 Battle ships
- C语言程序设计案例精编----文本编辑器
- 玩儿转canvas绘图
- 第十周项目一——程序填充与阅读(三)
- CSS选择权重
- Android动画
- C语言程序设计案例精编----电子时钟