WebService简单问题求高手解惑

lbq0801 2011-04-27 05:43:17
写了一个测试WebService,代码如下:
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public void FMSys_Fill(string FormID, string SerialID, string ApplyID, string ApplyerDeptID,
string gentID, string LeaveTypeID, string LeaveDays)
{
InsertData(FormID, SerialID, ApplyID, ApplyerDeptID, AgentID, LeaveTypeID, LeaveDays);
//触发流程
StringBuilder url = new StringBuilder("http://localhost/Second/FMSys_Fill.aspx?SerialID= " + SerialID + "&ApplyID=" + ApplyID + "&ApplyerDeptName=");
url.Append("&ApplyerDeptID=" + ApplyerDeptID + "&ApplyName=");
url.Append("&FormID=" + FormID + "&FormName=&UniqueID=&SequenceID=&FM3TestMode=0.00&ApplyDateTIme=&DraftFlag=0.00&refill=");
url.Append("&AutoFlowClass=2011Study&AutoFlowProject=0417&ProcessRuleID=1CAA362E-4FC7-4934-9248-A8FFEE59E8D0");

HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(url.ToString());
WebResponse myRes = myReq.GetResponse();
HttpContext.Current.Response.Redirect("http://www.baidu.com");

}

然后在另一个工程里引用这个WebService,代码如下:(申请跟Web引用没关系)

//这个方法调用没有问题,并且在WebSerVice编译后能正确运行
yd.Service1 s = new yd.Service1();
Response.Write(s.HelloWorld());
//下面这个方法调用时出错,报错:引用错误,不明白的地方是在WebSerVice工程里运行调用不出错,发布到IIS上,点浏览也能正确运行,不知道这样说有说清楚不
s.FMSys_Fill("a","a","a","a","a","a","1");
...全文
49 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
lbq0801 2011-04-28
  • 打赏
  • 举报
回复
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace APIGPS
{
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的接口名“ICheckSN”。
[ServiceContract]
public interface ICheckSN
{
[OperationContract]
bool Add(string SN, string userID);
}
}

首先谢谢你们的解答,在面的代码什么意思哦,没看懂思路,能解释下不?
我是小菜,谢谢!
ycproc 2011-04-27
  • 打赏
  • 举报
回复
接口


using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace APIGPS
{
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的接口名“ICheckSN”。
[ServiceContract]
public interface ICheckSN
{
[OperationContract]
bool Add(string SN, string userID);
}
}



方法

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace APIGPS
{
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码、svc 和配置文件中的类名“CheckSN”。
public class CheckSN : ICheckSN
{
public bool Add(string SN, string userID)
{
return Add(null, null);
}
}
}


调用实现

static void Main()
{
CheckSNClient client = new CheckSNClient();

// 使用 "client" 变量在服务上调用操作。

// 始终关闭客户端。
client.Close();
}
se7en 2011-04-27
  • 打赏
  • 举报
回复
看这个 ,http://blog.163.com/dragon_love_angel/blog/static/135339376201101524848972/

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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