Pay attention to the data transmission and Internet publishing of the WSDL interface.
System A transmits data to system B
1. A creates the asmx push interface as follows:
Using System; using System. collections. 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> /// summary of PreEventFive /// </summary> [WebService (Namespace =" http://tempuri.org/ ")] [WebServiceBinding (ConformsTo = WsiProfiles. basicProfile1_1)] [System. componentModel. toolboxItem (false)] // to allow ASP.. net ajax calls this Web service from a script. uncomment the following lines. // [System. web. script. services. scriptService] 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, 1); // DateTime d1 = Convert. toDateTime ("2015-01-01"); DateTime d2 = DateTime. now; DataTable dt = Broker. getStatisTypeTop10 (d1, d2, 1, "2 "). tables [0]; int I = 1; EventDataList DataSource = new EventDataList (); List <Dictionary <string, object> list = new List <Dictionary <string, object >>> (); foreach (DataRow dr in dt. rows) {if (I <6) {DataSource. serialNumber. add (I. toString (); DataSource. name. add (dr ["C_NAME"]. toString (); DataSource. LNNUM. add (dr ["C_LA_NUM"]. toString ();} I ++;} // serialize the array to json string jsonData2Tran = Newtonsoft. json. jsonConvert. serializeObject (DataSource); // Context. response. charset = "GB2312"; // set the character set type // Context. response. contentEncoding = System. text. encoding. getEncoding ("GB2312"); // Context. response. write (jsonData2Tran); // Context. response. end (); return jsonData2Tran ;}}}
View Code
2. B references the interface and accepts the service data.
JNEvent.PreEventFive ef = new JNEvent.PreEventFive(); string pe = ef.GetPETable(); PreEventFive evt = Newtonsoft.Json.JsonConvert.DeserializeObject<PreEventFive>(pe);
View Code
3. for publishing, right-click the B interface, modify the attribute-web Reference url, and change localhost to an Internet IP address.
4. After the release, you must configure the following information in the <system. web> center of the site to enable remote access.
<webServices> <protocols> <add name="HttpSoap"/> <add name="HttpPost"/> <add name="HttpGet"/> <add name="Documentation"/> </protocols> </webServices>
I personally think. asmx is much more convenient than. ashx