Webservice is a universal model for building applications. It can be run in any operating system that supports network communication. It is a new web webservice.
Application branches are self-contained, self-described, and modular applications that can be published, located, and called through the web. Web service is an application component that logically provides data and services for other applications. each application accesses the web service through the network protocol and some standard data formats (http, xml, and soap). The results are obtained through the internal execution of the web service. web services can execute any function from simple requests to complex business processing. After deployment, other web service applications can discover and call the services deployed by the application.
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 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. 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 to facilitate subsequent use of webpage special effects to process different types of data
For javascript, the xmlhttprequest object must be used to access the server. However, for simplicity, I did not consider compatibility issues and directly used the xmlhttprequest object (I used chrome as the test browser ), for this reason, I use the ajaxclient class for http operations (post method). The webservice class is used to encapsulate and process webservice (the ajaxclient class is called as the operation class). The jsonconverter class is used to process xml data and convert it to json data.
Common. js (including the jsonconverter class)
1 2 3