大战熟女丰满人妻av-荡女精品导航-岛国aaaa级午夜福利片-岛国av动作片在线观看-岛国av无码免费无禁网站-岛国大片激情做爰视频

專注Java教育14年 全國咨詢/投訴熱線:400-8080-105
動力節(jié)點LOGO圖
始于2009,口口相傳的Java黃埔軍校
首頁 hot資訊 使用tomcat發(fā)布Web Service

使用tomcat發(fā)布Web Service

更新時間:2020-09-18 17:18:49 來源:動力節(jié)點 瀏覽1395次

Web Service用于開發(fā)分布式的交互操作的應用程序,是Web開發(fā)中經(jīng)常用到的一門技術(shù)。本文我們一起來使用tomcat發(fā)布Web Service

下面是tomcat發(fā)布Web Service的具體過程:

1、下載jax-ws依賴包

因tomcat沒有jax-ws所需的依賴環(huán)境,所以第一步先下載Jax-ws RI,即jax-ws reference implemantation, 地址:http://jax-ws.java.net

2、安裝jax-ws RI到tomcat服務器

先下載ant與tomcat,設(shè)置環(huán)境變量ANT_HOME與CATALINA_HOME,然后在path下引入各自的bin目錄打開命令提示符,在jax-ws ri包的目錄下運行ant install。

此命令會直接把需要的包導入到${tomcat}\shared\lib目錄下,其實也就是把jaxws RI lib下的包復制到了tomcat安裝目錄下shared\lib里面。

3、設(shè)置Eclipse中的tomcat

由于eclipse是自己定義的tomcat配置文件,所以需要加些東西,把shared\lib加入進來,打開ctalina.properties文件。

打開后為(節(jié)選):

[html] view plaincopy

# Licensed to the Apache Software Foundation (ASF) under one or more

# contributor license agreements. See the NOTICE file distributed with

# this work for additional information regarding copyright ownership.

# The ASF licenses this file to You under the Apache License, Version 2.0

# (the "License"); you may not use this file except in compliance with

# the License. You may obtain a copy of the License at

#

# http://www.apache.org/licenses/LICENSE-2.0

#

# Unless required by applicable law or agreed to in writing, software

# distributed under the License is distributed on an "AS IS" BASIS,

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

# See the License for the specific language governing permissions and

# limitations under the License.

#

# List of comma-separated packages that start with or equal this string

# will cause a security exception to be thrown when

# passed to checkPackageAccess unless the

# corresponding RuntimePermission ("accessClassInPackage."+package) has

# been granted.

package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.

#

# List of comma-separated packages that start with or equal this string

# will cause a security exception to be thrown when

# passed to checkPackageDefinition unless the

# corresponding RuntimePermission ("defineClassInPackage."+package) has

# been granted.

#

# by default, no packages are restricted for definition, and none of

# the class loaders supplied with the JDK call checkPackageDefinition.

#

package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.

#

#

# List of comma-separated paths defining the contents of the "common"

# classloader. Prefixes should be used to define what is the repository type.

# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute.

# If left as blank,the JVM system loader will be used as Catalina's "common"

# loader.

# Examples:

# "foo": Add this folder as a class repository

# "foo/*.jar": Add all the JARs of the specified folder as class

# repositories

# "foo/bar.jar": Add bar.jar as a class repository

common.loader=${catalina.home}/shared/lib/*.jar,${catalina.home}/shared/lib,${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar

找到common.loader配置項增加${catalina.home}/shared/lib/*.jar,${catalina.home}/shared/lib 這兩個路徑即可。

4、建立項目

新建一個web項目,webservice_web。

HelloService.java是提供web service的一個接口,代碼如下:

[java] view plaincopy

package com.zxuqian.webservice;

import javax.jws.WebMethod;

import javax.jws.WebService;

@WebService

public interface HelloService {

@WebMethod

String greetings (String name);

}

HelloServiceImpl.java是實現(xiàn)類,代碼如下:

[java] view plaincopy

package com.zxuqian.webservice.impl;

import javax.jws.WebService;

import com.zxuqian.webservice.HelloService;

@WebService (endpointInterface = "com.zxuqian.webservice.HelloService" )

public class HelloServiceImpl implements HelloService {

@Override

public String greetings(String name) {

return "Hello: " + name;

}

}

5、添加sun-jaxws.xml

sun-jaxws.xml是通過web方式發(fā)布web service應用的描述文件,內(nèi)容如下:

[html] view plaincopy

<endpoint implementation="com.zxuqian.webservice.impl.HelloServiceImpl" name="HelloWorld" p="" <="">

url-pattern="/hello" />


各個節(jié)點的具體說明請參考下載的jaxws ri包里面的docs文檔,在這里簡單說明一下,endpoint需要指定

web service服務的接口和實現(xiàn)類,以及它的url相對路徑

6、配置web.xml

內(nèi)容如下:

[html] view plaincopy

 

 

  webservice_web 

    

   

    com.sun.xml.ws.transport.http.servlet.WSServletContextListener 

   

   

    hello 

    com.sun.xml.ws.transport.http.servlet.WSServlet 

    1 

   

    

   

    hello 

    /hello 

   

  


7、測試

啟動tomcat,在瀏覽器中輸入web service地址 http://localhost:8088/webservice_web/hello我的tomcat的端口號是8088,大家根據(jù)自己的端口號進行相應的修改。

以上就是tomcat發(fā)布Web Service的整個過程,小伙伴們學會了嗎?還有疑惑的小伙伴可以在本站的java視頻教程中找到相關(guān)課程,慢慢學習。


提交申請后,顧問老師會電話與您溝通安排學習

免費課程推薦 >>
技術(shù)文檔推薦 >>
主站蜘蛛池模板: 欧美色久| 久久99精品久久久久久三级 | 天天干天天操天天玩 | 日韩一区二区在线视频 | 成人sese| 奇米欧美成人综合影院 | 中文字幕曰韩一区二区不卡 | 欧美一区二区三区视频在线 | 久久国产麻豆 | 老司机午夜精品视频 | 国产在线观看中文字幕 | 日韩一级大毛片欧美一级 | 亚洲国产综合网 | 欧美一级黄色片在线观看 | 亚洲日本va | 你懂的日韩 | 国语一区| 天天做天天看夜夜爽毛片 | 国产成人精品一区二区仙踪林 | 日本黄色小视频在线观看 | 欧美日韩亚洲一区二区 | 国产尤物福利视频一区二区 | 亚洲综合色婷婷中文字幕 | 国产一区二区三区精品久久呦 | 久久久精品午夜免费不卡 | 久久福利网站 | 亚洲高清视频在线播放 | 久久香蕉国产线看观看亚洲片 | 欧美日韩亚洲精品一区二区三区 | 国产成+人+综合+亚洲不卡 | 亚洲免费成人 | 精品国产成人a在线观看 | 国产精品资源网站在线观看 | 国产99视频精品草莓免视看 | 亚洲人成自拍网站在线观看忄 | 97精品国产 | 欧洲黄色网 | 亚洲在线视频播放 | 久久久久久人精品免费费看 | 天天干夜夜 | 香蕉视频一区二区 |