Pay attention to the data transmission and Internet publishing of the WSDL interface.

Source: Internet
Author: User

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.