WebService it is a universal model for building applications that can be run in any operating system that supports network traffic; it's a new web WebService
The application branch is a self-contained, self-describing, modular application that can be published, positioned, and invoked via the Web. A Web service is an application component that logically provides data and services to other applications. Each application accesses the Web service through a network protocol and some standard data formats (HTTP,XML,SOAP), via the web The internal execution of the service gets the desired results. Web service can perform any function from simple requests to complex business processes. Once deployed, other Web service applications can discover and invoke the services that it deploys.
using System;
Using System.IO;
Using System.Collections;
Using System.Collections.Generic;
Using System.ComponentModel;
Using System.Web;
Using System.Web.Services;
Using System.web.services.protocols;
Using System.Drawing;
Using System.Drawing.Imaging;
Namespace Nightkidsservices
{
<summary>
Summary description of Service1
</summary>
[WebService (Namespace = "http://tempuri.org/")]
[WebServiceBinding (ConformsTo = wsiprofiles.basicprofile1_1)]
[ToolboxItem (False)]
public class Testservice:webservice
{
private static int picnum =-1;
[WebMethod]
Public Resource GetResource ()
{
Return Resource.createresource ("Pic2", "ASDFASD", 0);
}
[WebMethod]
public string HelloWorld ()
{
return "Hello";
}
[WebMethod]
Public byte[] Getpic ()
{
Picnum = (picnum + 1)% 32;
Image image = Image.FromFile (This.server.mappath ("jpeg/" + (picnum+1). ToString () + ". bmp"));
MemoryStream mem=new MemoryStream ();
Image.Save (Mem, imageformat.jpeg);
return Mem.getbuffer ();
}
[WebMethod]
Public list<resource> getresourcelist ()
{
return new list<resource> (new resource[] {resource.createresource ("Pic1", "Jpeg/1.bmp", 0), Resource.createresource ("Pic2", "Jepg/2.bmp", 0), Resource.createresource ("Pic3", "Jpeg/3.bmp", 0), Resource.createresource ("Pic4", "Jepg/4.bmp", 0)});
}
}
The above is just a simple test use to facilitate the subsequent use of web effects to deal with different types of data
For JavaScript, it's definitely using the XMLHttpRequest object to access the server side, but for the sake of simplicity, I didn't consider compatibility issues, directly using the XMLHttpRequest object (I used Chrome as a test browser), For this I use the Ajaxclient class for the HTTP operation (POST method), WebService class to encapsulate the processing webservice (invoke the Ajaxclient class as the action Class), Jsonconverter class processes XML data into JSON data
Common.js (including Jsonconverter class)