<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    love fish大鵬一曰同風起,扶搖直上九萬里

    常用鏈接

    統計

    積分與排名

    friends

    link

    最新評論

    學習Java6(一) WebServices (3)在tomcat中發布

    為了滿足廣大網友的要求,今天抽時間搞了下WebServices 在tomcat中的發布
    相關文章:
    tomcat啟動時自動加載servlet
    學習Java6(一) WebServices (1)服務端
    學習Java6(一) WebServices (2)客戶端

    新建一個servlet,偶太,能少打一個字符都是好的,所以servlet寫的非常簡潔,也適合初學者看得懂。。。。。。。。。。
    WebServiceStarter.java

    ?1?import?javax.servlet.ServletException;
    ?2?import?javax.servlet.http.HttpServlet;
    ?3?import?javax.xml.ws.Endpoint;
    ?4?
    ?5?public?class?WebServiceStarter?extends?HttpServlet?{
    ?6?????
    ?7?????private?static?final?long?serialVersionUID?=?5870534239093709659L;
    ?8?
    ?9?????public?WebServiceStarter()?{
    10?????????super();
    11?????}
    12?
    13?????public?void?destroy()?{
    14?????????super.destroy();
    15?????}
    16?
    17?????public?void?init()?throws?ServletException?{
    18?????????System.out.println("準備啟動服務");
    19?????????Endpoint.publish("http://localhost:8080/HelloService",?new?Hello());
    20?????????System.out.println("服務啟動完畢");
    21?????}
    22?}
    23?

    web service類Hello.java也是非常簡單
    ?1?
    ?2?
    ?3?import?javax.jws.WebMethod;
    ?4?import?javax.jws.WebService;
    ?5?import?javax.jws.soap.SOAPBinding;
    ?6?
    ?7?@WebService(targetNamespace?=?"http://jdk.study.hermit.org/client")
    ?8?@SOAPBinding(style?=?SOAPBinding.Style.RPC)
    ?9?public?class?Hello?{
    10?????@WebMethod
    11?????public?String?sayHello(String?name)?{
    12?????????return?"hello:"?+?name;
    13?????}
    14?}
    web.xml
    ?1?<?xml?version="1.0"?encoding="UTF-8"?>
    ?2?<web-app?version="2.4"?xmlns="http://java.sun.com/xml/ns/j2ee"
    ?3?????xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    ?4?????xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee?
    ?5?????http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    ?6?????<servlet>
    ?7?????????<servlet-name>WebServiceStarter</servlet-name>
    ?8?????????<servlet-class>WebServiceStarter</servlet-class>
    ?9?????????<load-on-startup>1</load-on-startup>
    10?????</servlet>
    11?</web-app>
    12?

    ok
    就這三個文件。。。。。。。。。啥jar都不要。。。。
    發布,啟動服務器
    2007-1-5 13:28:37 org.apache.catalina.core.AprLifecycleListener init
    信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: G:\JDK6\bin;F:\tomcat6\bin
    2007-1-5 13:28:37 org.apache.coyote.http11.Http11Protocol init
    信息: Initializing Coyote HTTP/1.1 on http-8080
    2007-1-5 13:28:37 org.apache.catalina.startup.Catalina load
    信息: Initialization processed in 937 ms
    2007-1-5 13:28:38 org.apache.catalina.core.StandardService start
    信息: Starting service Catalina
    2007-1-5 13:28:38 org.apache.catalina.core.StandardEngine start
    信息: Starting Servlet Engine: Apache Tomcat/6.0.7
    2007-1-5 13:28:38 org.apache.catalina.core.StandardHost start
    信息: XML validation disabled
    2007-1-5 13:28:38 org.apache.catalina.core.ApplicationContext log
    信息: ContextListener: contextInitialized()
    2007-1-5 13:28:38 org.apache.catalina.core.ApplicationContext log
    信息: SessionListener: contextInitialized()
    準備啟動服務
    服務啟動完畢
    2007-1-5 13:28:39 org.apache.coyote.http11.Http11Protocol start
    信息: Starting Coyote HTTP/1.1 on http-8080
    2007-1-5 13:28:39 org.apache.jk.common.ChannelSocket init
    信息: JK: ajp13 listening on /0.0.0.0:8009
    2007-1-5 13:28:39 org.apache.jk.server.JkMain start
    信息: Jk running ID=0 time=16/62? config=null
    2007-1-5 13:28:39 org.apache.catalina.startup.Catalina start
    信息: Server startup in 1969 ms


    訪問:http://localhost:8080/HelloService?wsdl
    ?1???<?xml?version="1.0"?encoding="UTF-8"??>?
    ?2?-?<definitions?xmlns="http://schemas.xmlsoap.org/wsdl/"?xmlns:tns="http://jdk.study.hermit.org/client"?xmlns:xsd="http://www.w3.org/2001/XMLSchema"?xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"?targetNamespace="http://jdk.study.hermit.org/client"?name="HelloService">
    ?3???<types?/>?
    ?4?-?<message?name="sayHello">
    ?5???<part?name="arg0"?type="xsd:string"?/>?
    ?6???</message>
    ?7?-?<message?name="sayHelloResponse">
    ?8???<part?name="return"?type="xsd:string"?/>?
    ?9???</message>
    10?-?<portType?name="Hello">
    11?-?<operation?name="sayHello"?parameterOrder="arg0">
    12???<input?message="tns:sayHello"?/>?
    13???<output?message="tns:sayHelloResponse"?/>?
    14???</operation>
    15???</portType>
    16?-?<binding?name="HelloPortBinding"?type="tns:Hello">
    17???<soap:binding?style="rpc"?transport="http://schemas.xmlsoap.org/soap/http"?/>?
    18?-?<operation?name="sayHello">
    19???<soap:operation?soapAction=""?/>?
    20?-?<input>
    21???<soap:body?use="literal"?namespace="http://jdk.study.hermit.org/client"?/>?
    22???</input>
    23?-?<output>
    24???<soap:body?use="literal"?namespace="http://jdk.study.hermit.org/client"?/>?
    25???</output>
    26???</operation>
    27???</binding>
    28?-?<service?name="HelloService">
    29?-?<port?name="HelloPort"?binding="tns:HelloPortBinding">
    30???<soap:address?location="http://localhost:8080/HelloService"?/>?
    31???</port>
    32???</service>
    33???</definitions>
    看到以上代碼就ok!
    客戶端寫法照舊

    posted on 2007-01-12 15:22 liaojiyong 閱讀(424) 評論(0)  編輯  收藏 所屬分類: WebService

    主站蜘蛛池模板: 免费人成又黄又爽的视频在线电影| 伊人久久五月丁香综合中文亚洲| 无遮挡免费一区二区三区| 在线观看无码的免费网站| 亚洲w码欧洲s码免费| 成人黄软件网18免费下载成人黄18免费视频| 亚洲精品国产啊女成拍色拍| 亚洲成人免费网址| 亚洲AV一二三区成人影片| 午夜dj在线观看免费视频| 久久亚洲精品11p| 亚洲精品乱码久久久久久不卡| 一个人看的免费视频www在线高清动漫 | 国产拍拍拍无码视频免费| 亚洲国产精品无码AAA片| 天堂在线免费观看| 亚洲情a成黄在线观看动漫尤物| 99在线免费观看视频| 亚洲国产精品线观看不卡| 免费无码又黄又爽又刺激| 亚洲变态另类一区二区三区| 免费a级毛片无码av| 一级毛片免费全部播放| 亚洲乱色熟女一区二区三区丝袜| 成人片黄网站色大片免费观看APP| 亚洲国产香蕉碰碰人人| 人禽杂交18禁网站免费| 免费在线观看一区| 亚洲国产精品乱码一区二区| 午夜国产精品免费观看| 免费人妻精品一区二区三区| 久久精品国产亚洲av成人| 免费电视剧在线观看| 免费人成动漫在线播放r18| 日本亚洲欧洲免费天堂午夜看片女人员| 最近最新高清免费中文字幕| 亚洲人成色在线观看| 亚洲人成人无码网www电影首页| 成年黄网站色大免费全看| 又硬又粗又长又爽免费看| 亚洲男女性高爱潮网站|