WebService超簡単入門チュートリアル(Java)


<!--
	Title:WebService        
	Author:Lovingshu
	Date:2012/09/21
	Description:Teach you how to use WebService with java easily!
-->
      :
	       ,     ,           ,             !       ,
	              WebService          !

    :
	  A    B    C...


    :       JDK   jdk1.6+,    java6+      ,java5   ...   ,    JDK        
Axis      jar    N       ,java6 webservice           !

       ,  :
1,        Trans,web  ,  java     !         java          !
	1.1         com.shu.function.Function :

//     webservice
@WebService
public class Function{

	//                    
	public String transWords(String words){
		String res="";
		for(char ch : words.toCharArray()){
			res+="\t"+ch+"\t";
		}
		return res;
	}

	//      main        service
	public void static main(String[] args){
		Endpoint.publish("http://localhost:9001/Service/Function",new Function());
		System.out.println("Publish Success~");
	}
}

2.   "Publish Success~" ,          ,    ,  :1.  JDK1.6+,2.            ;   ,
         :http://localhost:9001/Service/Function?wsdl      service     !

3.        :GiveMeWords

     ,  cmd      :wsimport -s src    -p      -keep webservice           OK ,
   : wsimport -s F:\\WorkBench\\Eclipse\\GiveMeWords\\src  -p com.shu.service -keep http://localhost:9001/Service/Function
(  wsimport    ,      jdk      !JAVA_HOME:JDK    ,CLASSPATH:%JAVA_HOME%\lib\tools.jar)
   ,   :
	parsing WSDL...
	generating code...
	compiling code...
   ,   ,         GiveMeWords     com.shu.service       WebService     !
      :
public void static main(String[] args){
	Function fu =new FunctionService().getFunctionPort();
	String str=fu.transWords("Let's Get Heck Out Of Here!");
	//  str   Trans    transWords          !
}

  ...   ,webservice   ,  jdk    !