first, what is a Web service
Web Service is a development model that can be used to solve the problem of cross-network application integration, in order to ensure that the application services of different platforms can interoperate.
Ii. three core of Web services
Soap:
SOAP, Simple Object access Protocol, is an XML-based protocol that can be identified in a step-by application. In addition, SOAP itself does not define any programming language, which allows soap to be delivered as a message to various remote systems.
The transport protocol used by SOAP, which can be http,smtp,pop3,jms.
soap consists of 4 parts:
"Soap Encapsulation (Envelope)":
Define a description of what the information describes, who is sending it, who should deal with it, and how to deal with their framework.
"SOAP Encoding Rules":
An instance of the data type that the application needs to use.
"SOAP RPC":
Represents a contract that is called and answered in a remote procedure.
"Sopa binding":
Exchange information using the underlying protocol.
WSDL:
The WSDL (Web service Description language,web Service Description Language) is an XML document that defines operations and messages for a given WEB service receiver in an abstract way that is not specific to the language.
UDDI:
UDDI (Universal Description Discovery and integration, unified Description Discovery and Integration protocol) is a specification that defines the publishing, discovery, and management of information related to Web services.
third, Jax-ws
Jsx-ws (Java API for XML Web Service). He is a technique used to simplify the work of building Web services and Web service clients using Java.
iv.use of Web services in projects
Scenario One: Enter URL,HTTP://WS.WEBXML.COM.CN/WEBSERVICES/MOBILECODEWS.ASMX?WSDL in the address bar
Scenario two: Implementation via Java code
To Open the cmd command: ------"cd\ to C packing directory------" wsimport-s. http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl. and generate a series of Java classes in the C packing directory. and apply it to the project for testing
Test class:
public class MyTest {public static void main (string[] args) {mobilecodews ws=new mobilecodews (); Mobilecodewssoap Soap=ws.getmobilecodewssoap (); String address=soap.getmobilecodeinfo ("13225788", ""); SYSTEM.OUT.PRINTLN (address);}}
Scenario three: Using Jax-WS Publishing Services
① defining server classes and Methods [HelloService]
Use @webservice annotations to identify a Java class or an interface as a service
/* * @WebService annotations, identify a Java class or an interface as a service, once labeled @webservice, he is not a normal * interface, he is called the Service endpoint interface (Services Endpoint Interface) */@ Webservicepublic class HelloService {public void Say (String name) {System.out.println ("Hello" + name);} public static void Main (string[] args) {endpoint.publish ("Http://192.168.0.2:40000/hello", New HelloService ()); SYSTEM.OUT.PRINTLN ("Server is listening ...");}}
service is listening ...
Test in the browser:
② the same cmd command parses the document's class or method [client]
Create a new project, use these classes, and test
MyTest Test class:
public class MyTest {public static void main (string[] args) {helloserviceservice service=new helloserviceservice (); HelloService hs = Service.gethelloserviceport (); Hs.say ("Tease");}}
First knowledge of WebService