C# .net 调用外部接口 asmx格式的 需要先在Service References 添加服务引用

 

 

 这些步骤完成后就可以像调用方法一样调用接口了。

public string QueryOrderInformation(DataRow rows, string VoucherNo)
{
string QCNum = rows["QC工号"].ToString();
string type = rows["送检类型"].ToString();
string type1 = "";
if (type== "电仪")
{
type1 = "1";
}
if (type == "机械")
{
type1 = "2";
}
QueryOrderInformation.NewServiceHG getlist = new QueryOrderInformation.NewServiceHG();


string strContent = "";
strContent += "{\"document_number\":\"" + VoucherNo + "\",";//物料凭证号
strContent += "\"inspection_sheet_type\":\"" + type1 + "\",";////送检类型:1机械、2电仪
strContent += "\"inspection_sheet_way\":\"" + 1 + "\",";//送检方式:1=正常、2=返修
strContent += "\"qc_user_num\":\"" + QCNum + "\",";//检验员工号
strContent += "\"create_user_id\":\"" + 7777+ "\",";//送检人工号
strContent += "\"create_user_name\":\"" + "" + "\",";//送检人姓名
strContent += "\"purchasing_order\":\"" + rows["订单号"].ToString() + "\"}";//订单号

string JsonStr = getlist.QueryOrderInformation(strContent);//获取送检单号 inspection_sheet 并存入数据库

JObject jo = (JObject)JsonConvert.DeserializeObject(JsonStr);
string inspection_sheet = jo["result"]["inspection_sheet"].ToString();//送检单号
return inspection_sheet;
}

原文地址:https://www.cnblogs.com/codejimmygao/p/14604794.html