WSDL接口数据传递以及外网发布需要注意的地方

2023-03-18,,

A系统传递数据给B系统

1、A创建asmx推送接口如下

using System;
using System.Collection.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using Topevery.DUM.Report;
using Topevery.DUM.Report.Entity;
namespace Topevery.DUM.Report.ASMX
{
///<summary>
///PreEventFive的摘要说明
///</summary>
[WebService(Namespace="http://tempuri.org/")]
[WebServiceBinding(ConformsTo=WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class PreEventFive:System.Web.Services.WebService
{
[WebMethod(Description="直接返回json")]
public string GetPETable()
{
DateTime now=DateTime.Now;
DateTime d1=new DateTime(now.Year,now.Month,);
DateTime d2=DateTime.Now;
DataTable dt=Broker.GetStatisTypeTop10(d1,d2,,"").Tables[];
int i=;
EventDataList DataSource =new EventDataList();
List<Dictionary<string,object>>list =new List<Dictionary<string,object>>();
foreach(DataRow dr in dt.Rows)
{
if(i<)
{
DataSource.SerialNumber.Add(i.ToString());
DataSource.Name.Add(dr["C_Name"].ToString());
DataSource.LNNUM.Add(dr["C_LA_NUM"].ToString());
}
i++;
}
//数组序列化转为json
string jsonData2Tran =Newtonsoft.Json.JsonConvert.SerializeObject(DataSource);
return jsonData2Tran;
}
}
}

2、B引用A接口,接受该服务数据

JNEvent.PreEventFive ef=new JNEvent.PreEventFive();
string pe=ef.GetPETable();
PreEventFive evt=Newtonsoft.Json.JsonConvert.DeserializeObject<PreEventFive>(pe);

3、发布需要注意的是右击B接口,修改属性-web引用url,将localhost改为外网IP

4、发布后需要在该站点下<system.web>中间配置如下信息,开启远程访问

<webServices>
<protocols>
<add name="HttpSoap"/>
<add name="HttpPost"/>
<add name="HttpGet"/>
<add name="Documentation"/>
</protocols>
</webServices>

WSDL接口数据传递以及外网发布需要注意的地方的相关教程结束。

《WSDL接口数据传递以及外网发布需要注意的地方.doc》

下载本文的Word格式文档,以方便收藏与打印。