What is webservice:
WebService is a remote invocation technology across programming languages and operating system platforms.
The so-called cross programming language and cross operating platform means that the server program is written in java, and the client program can be written in other programming languages, and vice versa! Cross-operating system platform means that the server program and client program can run on different operating systems.
using H3.BizBus;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
using System.Web;
using System.Web.Services;
namespace WebApplication4
{
/// <summary>
/// WebService1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// [System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public string GetSchema(string schemaCode)
{
string strSchemaJson = string.Empty;
BizStructureSchema schema = new BizStructureSchema();
string errorMessage = string.Empty;
schema.Code = schemaCode;
schema.Add(new ItemSchema("Status", "Return Results", BizDataType.String));
schema.Add(new ItemSchema("Msg", "Return Results", BizDataType.String));
schema.Add(new ItemSchema("bbh", "bbh", BizDataType.String));
schema.Add(new ItemSchema("bzmc", "bzmc", BizDataType.String));
schema.Add(new ItemSchema("czbzId", "czbzId", BizDataType.Int));
schema.Add(new ItemSchema("id", "id", BizDataType.String));
schema.Add(new ItemSchema("jcdId", "jcdId", BizDataType.String));
schema.Add(new ItemSchema("jcdwtid", "jcdwtid", BizDataType.String));
schema.Add(new ItemSchema("bzlyId", "bzlyId", BizDataType.String));
schema.Add(new ItemSchema("xgsj", "xgsj", BizDataType.DateTime));
schema.Add(new ItemSchema("xssx", "xssx", BizDataType.Int));
schema.Add(new ItemSchema("zt", "zt", BizDataType.Int));
strSchemaJson = BizStructureUtility.SchemaToJson(schema);
//string jsStr = Newtonsoft.Json.JsonConvert.SerializeObject(schemaCode);
return strSchemaJson;
}
[WebMethod]
public string GetSchemaList()
{
return string.Empty;
}
///
public string FJLdata(string json)
{
JObject obj = JObject.Parse(json);
JArray jsonstr = (JArray)obj["Matcher"]["Matchers"];
string value = jsonstr[0]["Value"].ToString();
return value;
}
[WebMethod]
public string GetList(string userCode, string schemaCode, string filter)
{
//Successful call
string intrr = "";
if (schemaCode == "D001728jianchabiaozhun")
{
#region
string url = "http://zxf.hyjktest.top/ruoyi-admin/Jc/data/GetJcInspect?currentPage=10&pageSize=10";
Encoding encodin = Encoding.UTF8;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
request.Accept = "text/html,application/xhtml+xml,*/*";
request.ContentType = "application/json";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
//string thejic = reader.ReadToEnd();
//JObject obj = JObject.Parse(thejic);
//JArray jsonstr = (JArray)obj["data"]["list"];
//String hingeString = Newtonsoft.Json.JsonConvert.SerializeObject(jsonstr);
//return hingeString;
#endregion
int dataCount = 0;
int resultCodein = 0;
string resultMsg = "Global return information";
H3.BizBus.BizStructureSchema schema = null;
string errorMessage = string.Empty;
BizStructureUtility.JsonToSchema(this.GetSchema(schemaCode), out schema, out errorMessage);
List<BizStructure> list = new List<BizStructure>();
string thejic = reader.ReadToEnd();
JObject obj = JObject.Parse(thejic);
JArray jsonstr = (JArray)obj["data"]["list"];
if (jsonstr != null && jsonstr.Count > 0)
{
for (int i = 0; i < jsonstr.Count; i++)
{
string jsonzhuanyi= Newtonsoft.Json.JsonConvert.SerializeObject(jsonstr[i]);
bool czbzcunzai = jsonzhuanyi.Contains("czbzId");
bool xssxcunzai = jsonzhuanyi.Contains("xssx");
BizStructure bizStructure = new H3.BizBus.BizStructure(schema);
bizStructure["Status"] = "true";
bizStructure["Msg"] = "msg";
bizStructure["bbh"] = jsonstr[i]["bbh"];
bizStructure["bzmc"] = jsonstr[i]["bzmc"];
//string abc = jsonstr[i]["czbzId"].ToString();
if (czbzcunzai == false) {
bizStructure["czbzId"] = (int)12135;
}
else { bizStructure["czbzId"] = int.Parse(jsonstr[i]["czbzId"].ToString());}
bizStructure["id"] = jsonstr[i]["id"];
bizStructure["jcdId"] = jsonstr[i]["jcdId"];
bizStructure["jcdwtid"] = jsonstr[i]["jcdwtid"];
bizStructure["bzlyId"] = jsonstr[i]["lybzid"];
bizStructure["xgsj"] = DateTime.Parse(jsonstr[i]["xgsj"].ToString());
if (xssxcunzai==false) {
bizStructure["xssx"] = (int)12135;
}
else
{
bizStructure["xssx"] = int.Parse(jsonstr[i]["xssx"].ToString());
}
bizStructure["zt"] = int.Parse(jsonstr[i]["zt"].ToString());
list.Add(bizStructure);
}
dataCount = list.Count;
}
ListResult listResult = new ListResult(resultCodein, resultMsg, list.ToArray(), dataCount);
return BizStructureUtility.ListResultToJson(listResult);
}
else
{
return string.Empty;
}
}
[WebMethod]
public string Invoke(string userCode, string schemaCode, string methodName, string param)
{
return string.Empty;
}
}
}
call interface
string url = "http://zxf.hyjktest.top/ruoyi-admin/Jc/data/GetJcInspect?currentPage=10&pageSize=10";
Encoding encodin = Encoding.UTF8;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
request.Accept = "text/html,application/xhtml+xml,*/*";
request.ContentType = "application/json";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);