菜鸟问题:webservice的调用!!c#winform的~~

小朵乌云 2006-09-21 01:51:53
偶是新手~刚学WebService的东西~
学着写了个demo,其中写了个Select(算是服务吧),但不知怎样调用~,总是提示下面的错误(附后);哪位老大指点一下~,给个调用webservice的调用代码最好,不胜感激~就调用系统生成的那个“helloworld”就行~要c#winform的~~~
对了~偶调用时建的是移动设备的工程~汗ing~在线~ing


关调用实时(JIT)调试而不是此对话框的详细信息,
请参阅此消息的结尾。

************** 异常文本 **************
System.InvalidOperationException: 无法反射方法 Service1.Select。 ---> System.IO.FileNotFoundException: 找不到文件或程序集名称“System.Web.Services”,或找不到它的一个依赖项。
文件名: “System.Web.Services”
at System.Reflection.CustomAttribute.GetDataForPropertyOrField(Boolean& isProperty, Object& value, Type& type, Boolean isLast)
at System.Reflection.CustomAttribute.GetObject()
at System.Reflection.CustomAttribute.CheckConsistencyAndCreateArray(CustomAttribute caItem, Type caType)
at System.Reflection.CustomAttribute.GetCustomAttributes(MemberInfo member, Type caType, Boolean inherit)
at System.Reflection.RuntimeMethodInfo.GetCustomAttributes(Type attributeType, Boolean inherit)
at System.Web.Services.Protocols.LogicalMethodInfo.GetCustomAttributes(Type type)
at System.Web.Services.Protocols.SoapReflector.GetSoapMethodAttribute(LogicalMethodInfo methodInfo)
at System.Web.Services.Protocols.SoapReflector.ReflectMethod(LogicalMethodInfo methodInfo, Boolean client, XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter, String defaultNs)

=== Pre-bind state information ===
LOG: DisplayName = System.Web.Services, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=969db8053d3322ac
(Fully-specified)
LOG: Appbase = C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\SmartDeviceApplication1\bin\Release\
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===

LOG: Publisher policy file is not found.
LOG: Host configuration file not found.
LOG: Using machine configuration file from C:\WINNT\Microsoft.NET\Framework\v1.1.4322\config\machine.config.
LOG: Post-policy reference: System.Web.Services, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=969db8053d3322ac
LOG: Attempting download of new URL file:///C:/Documents and Settings/Administrator/My Documents/Visual Studio Projects/SmartDeviceApplication1/bin/Release/System.Web.Services.DLL.
LOG: Attempting download of new URL file:///C:/Documents and Settings/Administrator/My Documents/Visual Studio Projects/SmartDeviceApplication1/bin/Release/System.Web.Services/System.Web.Services.DLL.
LOG: Attempting download of new URL file:///C:/Documents and Settings/Administrator/My Documents/Visual Studio Projects/SmartDeviceApplication1/bin/Release/System.Web.Services.EXE.
LOG: Attempting download of new URL file:///C:/Documents and Settings/Administrator/My Documents/Visual Studio Projects/SmartDeviceApplication1/bin/Release/System.Web.Services/System.Web.Services.EXE.

--- 内部异常堆栈跟踪的结尾 ---
at System.Web.Services.Protocols.SoapReflector.ReflectMethod(LogicalMethodInfo methodInfo, Boolean client, XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter, String defaultNs)
at System.Web.Services.Protocols.SoapClientType..ctor(Type type)
at System.Web.Services.Protocols.SoapHttpClientProtocol..ctor()
at SmartDeviceApplication1.Service.Service1..ctor()
at SmartDeviceApplication1.Form1.button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** 已加载的程序集 **************
mscorlib
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///c:/winnt/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
SmartDeviceApplication1
程序集版本: 1.0.2455.20765
Win32 版本: 1.0.2455.20765
基本代码: file:///C:/Documents%20and%20Settings/Administrator/My%20Documents/Visual%20Studio%20Projects/SmartDeviceApplication1/bin/Release/SmartDeviceApplication1.exe
----------------------------------------
System.Windows.Forms
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///c:/winnt/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///c:/winnt/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///c:/winnt/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Web.Services
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///c:/winnt/assembly/gac/system.web.services/1.0.5000.0__b03f5f7f11d50a3a/system.web.services.dll
----------------------------------------
System.Xml
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///c:/winnt/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
System.Web
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///c:/winnt/assembly/gac/system.web/1.0.5000.0__b03f5f7f11d50a3a/system.web.dll
----------------------------------------
System.Web.Services.resources
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///c:/winnt/assembly/gac/system.web.services.resources/1.0.5000.0_zh-chs_b03f5f7f11d50a3a/system.web.services.resources.dll
----------------------------------------
System.Windows.Forms.resources
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///c:/winnt/assembly/gac/system.windows.forms.resources/1.0.5000.0_zh-chs_b77a5c561934e089/system.windows.forms.resources.dll
----------------------------------------
mscorlib.resources
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///c:/winnt/assembly/gac/mscorlib.resources/1.0.5000.0_zh-chs_b77a5c561934e089/mscorlib.resources.dll
----------------------------------------

************** JIT 调试 **************
计算机的配置文件(machine.config)的
system.windows.forms 节中必须设置 jitDebugging 值。
编译应用程序时还必须启用\r\n调试。\r\n\r\n例如: \r\n\r\n<configuration>\r\n <system.windows.forms jitDebugging="true" />\r\n</configuration>\r\n\r\n启用 JIT 调试后,任何未处理的异常\r\n都将被发送到此计算机上注册的 JIT 调试器,\r\n而不是由此对话框处理。\r\n
...全文
289 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
小朵乌云 2006-09-25
  • 打赏
  • 举报
回复
顿悟无果T_T

用winform调用该webservice成功~
在ce下~~~~,高手们救命~

To Knight94(愚翁)
请您说具体些,我很菜~,感谢其他人的回答~,不过问题依旧,呵呵~

感谢sskset(断点) 的代码~还有其他人的建议~

希望大虾们继续帮偶~分可以再加关键是解决问题,各位辛苦啦^_^!
cofeilover 2006-09-21
  • 打赏
  • 举报
回复
添加引用后,和类使用方法差不多
lionelwy 2006-09-21
  • 打赏
  • 举报
回复
添加引用
路人霆 2006-09-21
  • 打赏
  • 举报
回复
上面的信息足够了。
小朵乌云 2006-09-21
  • 打赏
  • 举报
回复
谢谢各位~试验中~~,ok就结贴^_^
zhiri 2006-09-21
  • 打赏
  • 举报
回复
建议用反射!
dapanda 2006-09-21
  • 打赏
  • 举报
回复
http://www.microsoft.com/china/msdn/archives/library/dv_vstechart/html/vbtchgettingstartedwithxmlwebservicesinvisualstudionet.asp
blackant2 2006-09-21
  • 打赏
  • 举报
回复
第一步:生成web service
第二步:使用wsdl工具生成web service调用类
第三步:在工程中加入对system.web.services的引用
(System.IO.FileNotFoundException: 找不到文件或程序集名称“System.Web.Services”,或找不到它的一个依赖项。)
然后你就可以象普通类一样调用webservice了
Knight94 2006-09-21
  • 打赏
  • 举报
回复
问题的关键不是如何写webservice以及如何调用,而是在cf中如何调用。

参看msdn,vs1.1中的webservice并不支持cf环境。
copico 2006-09-21
  • 打赏
  • 举报
回复
http://www.cnblogs.com/robin0925/archive/2006/05/30/412622.html
sskset 2006-09-21
  • 打赏
  • 举报
回复
给你段调用

程序里

private void btnLogin_Click(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
try
{
if (!InputCheck()) return;

string uCode = null;
//用户登录确认
VAWebService.VAService loginService = new VA.AnalystTool.VAWebService.VAService();
int iLogin = loginService.Login(this.txtUserid.Text, this.txtPwd.Text, ref uCode);

if (iLogin == (int)LoginStatus.Successed)
{
// 登陆成功
}
else if (iLogin == (int)LoginStatus.NoAccount)
{
MessageBox.Show("没有此用户帐号,请确认?","用户登录");
this.txtUserid.Focus();
}
else if (iLogin == (int)LoginStatus.WrongPassword)
{
MessageBox.Show("密码输入错误,请确认?", "用户登录");
this.txtPwd.Focus();
}
else
{
MessageBox.Show("登录失败!", "用户登录");
this.txtUserid.Focus();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
this.Cursor = Cursors.Default;
}
}






WebService

/// <summary>
/// 用户的登录验证
/// </summary>
/// <param name="uid">用户名</param>
/// <param name="pwd">用户密码</param>
/// <returns>
/// 3 代表 验证通过 
/// 1 代表 用户名输入错误 
/// 2 代表 密码输入错误
/// 其他 登录失败
/// </returns>
[WebMethod]
public int Login(string uid, string pwd,ref string ucode)
{
int iLoginStatus = 0;

Database camDatabase = DatabaseFactory.CreateDatabase();
System.Data.Common.DbCommand loginCmd = camDatabase.GetStoredProcCommand("clientLogin");
camDatabase.AddInParameter(loginCmd,"@uid",System.Data.DbType.String,uid);
camDatabase.AddInParameter(loginCmd,"@pwd",System.Data.DbType.String,pwd);
camDatabase.AddOutParameter(loginCmd,"@status",System.Data.DbType.Int32,4);
camDatabase.AddOutParameter(loginCmd, "@ucode", System.Data.DbType.Guid, 16);
camDatabase.ExecuteNonQuery(loginCmd);

ucode = camDatabase.GetParameterValue(loginCmd, "@ucode").ToString();
iLoginStatus = (int)camDatabase.GetParameterValue(loginCmd, "@status");

return iLoginStatus;
}
Knight94 2006-09-21
  • 打赏
  • 举报
回复
你的webservice 怎么写得,IE中调用是否能成功

110,561

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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