Server-side thinking, server-side thinking

Source: Internet
Author: User

Server-side thinking, server-side thinking
Overview

We think about what a web Service needs to do and divide its responsibilities. Division of duties Usually we will first develop Abstract InterfaceAnd then construct Implementation class. Interfaces and implementation classes are completed before implementation. Release. Therefore, server roles can be divided: Service Interface, Service implementation, Service publisher. Server implementation Merit Yes : Set A Pull Bo Quantity Word Transfer Change Cheng Medium Text Quantity Word Collation Column . Service Interface
Package cn. ljl. sand. jws. chapter1.service; import javax. jws. webParam; import javax. jws. webResult; import javax. jws. webService; @ WebServicepublic interface InterpretService {@ WebResult (name = "chnum") // The name Of The default result is return public String interpret (@ WebParam (name = "num ") /* the default parameter name is arg0, arg1... */int num );}

Note:

Service implementation class
Package cn. ljl. sand. jws. chapter1.service; import javax. jws. webService; @ WebService (endpointInterface = "cn. ljl. sand. jws. chapter1.service. interpretService ") public class InterpretServiceImpl implements InterpretService {public static final String [] CH_NUMS = // force-formatted line feed {" 0 "," 1 "," 2 "," 3 ", "4", "5", "6", "7", "8", "9"}; @ Override public String interpret (int num) {StringBuilder builder = new StringBuilder (Integer. toString (num ). length (); for (int digit = num % 10; num> 0; num = num/10, digit = num % 10) {builder. append (CH_NUMS [digit]);} builder. reverse (); return builder. toString ();}}

 

Note: Service publisher
package cn.ljl.sand.jws.chapter1.service; import javax.xml.ws.Endpoint; public class InterpretServicePublisher {  public static void main(String[] args) {    String address = "http://localhost:6666/service/interpret";    InterpretService service = new InterpretServiceImpl();    Endpoint.publish(address, service);  }}

 

According to the Code, the wsdl URL is http: // localhost: 6666/service/interpret? Wsdl. You can enter this address in your browser to view its content. But we are not ready to explain it. Client Test  



From Weizhi note (Wiz)



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.