When developing this project, we mainly use the following technologies.
1. Web Service Development Technology
1.1JavaPlatform generationWebServiceUse xfire + Tomcat to implement pojo release on the Java platform as Web Service. Tomcat is a Web container used to process HTTP in soap messages. xfire is a SOAP engine used to process soap messages on the server. The specific process is as follows: 1. First, the configuration ing of the web. xml file is established. when accessing services, xfirecompuableservlet is called for processing:
...... <Web-app> <servlet> <Servlet-Name> xfireservlet </servlet-Name> <Display-Name> xfire servlet </display-Name> <Servlet-class> Org. codehaus. xfire. Transport. http. xfireconfigurableservlet </Servlet-class> </Servlet> <servlet-mapping> <Servlet-Name> xfireservlet </servlet-Name> <URL-pattern>/servlet/xfireservlet/* </url-pattern> </Servlet-mapping> <servlet-mapping> <Servlet-Name> xfireservlet </servlet-Name> <URL-pattern>/services/* </url-pattern> </Servlet-mapping> </Web-app> |
2. xfireconfigurableservlet will automatically find the META-INF/xfire/services under classes. xml configuration file: In this xml configuration file, bind the service class or interface to be provided, set its name, namespace, and the class to be bound:
<Beans xmlns = "http://xfire.codehaus.org/config/1.0"> <Service> <Name> helloworldservice </Name> <Namespace> http: // 202.118.22.171/helloworldservice </namespace> <Serviceclass> cactus. helloworldservice </serviceclass> </Service> </Beans> |
3. Compile the classes or interfaces for services. In my example, cactus. helloworldservice class:
Package cactus; public class helloworldservice {public void sayhelloworld (){ System. Out. println ("Hello World !"); } } |
4. Copy xfire and all the required packages. After downloading xfire, decompress it to a lib directory and copy all the packages to the downloaded xfire package. 5. start Tomcat for server testing. Enter the URL: http: // localhost: 8080/helloworldservice/services/the browser displays the name of the class or interface you are bound to, for example:
Available Services: helloworldservice [WSDL] Generated by xfire (http://xfire.codehaus.org) |
Click [WSDL] next to the service name to display the detailed WSDL description of the service class.
1.2. NetPlatform generationWebServiceUse IIS + C # +. Net to publish a web service on the. NET platform. IIS is a Web container used to process the HTTP part of a SOAP message, and the API provided by. NET is used to process a SOAP message. For example, publish a hello World web service and create a web service on the. NET platform to write the following code:
[Webmethod] Public String helloworld () {return "Hello World ";} |
1.3 PPlatform generationWebService
HPApache + nusoap is used to publish Web Services on the PHP platform. Apache is a Web container used to process the HTTP part of soap messages. nusoap is responsible for generating WSDL to process soap messages. Next we will use PHP + nusoap to publish a web service with two numbers.
<? PHP // Server. PHP // import nusoap. phprequire ("nusoap/lib/nusoap. PHP "); // declare a soap_server object $ Server = new soap_server (); // configure the WSDL $ server-> configurewsdl ('helloworld', 'urn: helloworld '); // define the target namespace $ server-> WSDL-> schematargetnamespace = 'urn: helloworld'; // register adder $ server-> Register (// operation name "adder ", // parameter type array ('format' => 'xsd: int', 'fuck' => 'xsd: int '), // return value type array ('Return '=> 'xsd: int'), 'urn: helloworld', 'urn: helloworld # adder'); func Tion adder ($ A, $ B) {return ($ A + $ B);} $ http_raw_post_data = isset ($ http_raw_post_data )? $ Http_raw_post_data: ''; $ server-> service ($ http_raw_post_data);?> |
Access http: // localhost/server. php is the service and the corresponding WSDL location is http: // localhost/server. php? WSDL
2. Web service calling Technology
2.1WebService parsing TechnologyWsdl4j provides a standard Java interface that can be used to parse existing WSDL documents or create new WSDL documents through programming. Wsdl4j is an open source project located on the IBM developerworks website. Most wsdl4j classes represent elements that can appear in the WSDL document. For example, the definition class represents the <definition> element, and the service class represents the <service> element. It also makes the WSDL document easy to read and parse, and uses the content of the wsdl4j object as the compile class written in the XML document.
2.2Message Generation Technology
SoapSAAJ (soap with attachments API for Java) is an API specification based on XML message transmission implemented by using the SOAP protocol in loosely coupled software systems. As the name suggests, SAAJ supports soap messages with attachments. SAAJ provides a library that allows you to easily build and read soap information. This Library also allows you to receive and send soap information over the network. The saaj api provides a high-level SOAP message encapsulation interface, such as javax. XML. soap. soapenvelope and provides the getheader () operation. This method returns a message header: javax. XML. soap. soapheader. Therefore, by calling the SAAJ interface function, we can operate the SOAP message. Using JDOM Technology, return values in soap are extracted based on the returned information parsed from the WSDL and finally presented to users.
2.3Based onLuceneOfWebService search Based on search efficiency, we use the open source index database engine Lucene. Through the analysis of the Lucene source code package, we can initially realize that the Lucene core class package mainly has three: l Org. apache. lucene. analysisl Org. apache. lucene. indexl Org. apache. lucene. search where Org. apache. lucene. analysis is mainly used for word segmentation. The work of Word Segmentation is implemented by the extension class of analyzer. Lucene comes with the standardanalyzer class. We can refer to this class to write our own word segmentation analyzer class, for example, a Chinese analyzer. Org. Apache. Lucene. Index mainly provides the Read and Write interfaces for databases. This package allows you to create databases, add and delete records, and read records. Org. apache. lucene. search mainly provides the Retrieval Interface. Through this package, we can enter conditions to obtain the query result set, which is consistent with Org. apache. lucene. the queryparser package can also be used with custom query rules. like Google, the queryparser package supports composite queries between Query conditions, such as and, or, not, And belongs.
3. J2EE Web application Construction TechnologyThis project is based on J2EE WEB technology to develop server-side programs and browser-based client pages. The servlet API of J2EE is used to process HTTP requests from browsers or mobile devices. The servlet container used is Apache tomcat5.5. Use JSP to construct a browser-based client page. Use JDBC to process the connection to the MySQL database.
4. mobile client Development TechnologyUsing Sun's j2-based technology to develop mobile client applications, the development of such programs can be simplified into three layers: 1. The j2-based client (MIDlet Program)
2. server-side servlet (servlet Program)
3 Database (MySQL, etc.) in this project, there are two types of server servlets: one is the HTTP request from the browser and the other is the HTTP request from the mobile phone, this type of servlet is the code that we need to add on the server when developing the mobile client. Other code can directly call the original code on the server, such as database connection to verify that the user's login information is correct. Therefore, the mobile client development of this project is mainly focused on the development of the MIDlet program.