瑙e喅java web 椤圭洰鍙戝竷webservice鎺ュ彛
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了瑙e喅java web 椤圭洰鍙戝竷webservice鎺ュ彛相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/%e6%b2%a1%e6%9c%89' title='娌℃湁'>娌℃湁
浣跨敤 灏辨槸 鏇夸唬 end 鎴愬姛 throw point http銆€銆€銆€鏈€杩戝叕鍙告湁涓€涓渶姹傦紝闇€瑕佹毚闇插綋鍓峸eb椤圭洰鐨勬帴鍙g粰绗笁鏂圭郴缁熻皟鐢紝缃戜笂鏌ュ埌webservice鏄法骞冲彴銆佽法璇█鐨勫簲鐢ㄦ妧鏈紝鎵€浠ヤ綔涓洪閫夈€?/p>
鏌ユ壘浜嗗緢澶氫緥瀛愶紝閮芥槸寰堢畝鍗曠殑鍔燖WebService鍒扮被锛屽姞@WebMethod鍒版毚闇茬殑鏂规硶涓婏紝鐒跺悗EndPoint.publish鍗冲彲锛屼絾鎴戝湪web椤圭洰涓娇鐢紝娌℃湁鎶ラ敊锛屼絾灏辨槸鍙戝竷澶辫触锛屽湪杩欓噷鍗′簡寰堜箙锛?/p>
浠ヤ笅鏄垜鐨勮В鍐宠繃绋嬶紝鍋氫笅璁板綍澶囧繕锛?/p>
棣栧厛璇曠潃鏂板缓浜嗕竴涓櫘閫歫ava椤圭洰锛屽悓鏍风殑鍔犳帴鍙c€佸疄鐜扮被銆佹敞瑙o紝缁撴灉鍙戝竷鎴愬姛銆備絾鏄柊寤轰竴涓獁eb椤圭洰鍚屾牱鐨勬搷浣滃氨鏄彂甯冧笉鎴愬姛锛岀湅浜嗕笅椤圭洰缁撴瀯锛屼富瑕佸氨鏄痺eb椤圭洰榛樿鍔犺浇tomcat鐨刲ib
鎵€鏈塉AR鍖咃紝鎶婅繖浜涘寘鍒犻櫎锛岄噸鏂板彂甯冿紝缁撴灉鎴愬姛銆傝繖鏃舵垜鑰冭檻鍒板彲鑳芥槸鎴憈omcat涓嬬殑jar鍖呭啿绐侀棶棰橈紝浜庢槸杩涜鎺掓煡锛屾渶鍚庡彂鐜板幓鎺?nbsp; xfire-all-1.2.6.jar 锛寃eb椤圭洰灏卞彲浠ュ彂甯冩垚鍔熶簡锛屼絾鏄痺eb椤圭洰
鍙堝繀椤绘湁 xfire-all-1.2.6.jar锛岀綉涓婃煡浜嗘病鏈夋壘鍒板叿浣撴柟娉曪紝浣嗘湁鎻愬埌xfire-core-1.2.6.jar锛屼簬鏄垜鎶?xfire-all-1.2.6.jar 鏇夸唬鎴?xfire-core-1.2.6.jar锛寃eb椤圭洰鍔熻兘姝e父锛寃ebservice涔熷彲浠ュ彂甯冩垚鍔熴€?/p>
鍥犱负鎴戠殑椤圭洰鏄痵sh妗嗘灦锛屾墍浠ュ氨鍒涘缓涓€涓猣ilter绫伙紝閰嶇疆鍒皐eb.xml,鍚姩椤圭洰鐨勫悓鏃跺彂甯冩帴鍙c€?/p>
public class StartFilter implements Filter{ @Override public void destroy() { // TODO Auto-generated method stub } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { // TODO Auto-generated method stub } @Override public void init(FilterConfig filterConfig) throws ServletException { this.startWebservice(); } public void startWebservice() { Endpoint.publish("http://localhost:8085/service/wstest",new WsInterfaceImpl()); System.out.println("webservice鍙戝竷鎴愬姛"); } }
//web.xml娣诲姞閰嶇疆
<filter> <filter-name>StartFilter </filter-name> <filter-class>com.cf.cfipms.interceptor.StartFilter</filter-class> </filter>
鐩墠鍙槸瀹炵幇浣跨敤jdk鑷甫鐨剋ebservice杩涜鍙戝竷锛岀湅鍒板緢澶氭帹鑽怌XF锛屾鍦ㄥ涔狅紝绛夋垚鍔熶簡鍦ㄦ洿鏂般€?/p>
以上是关于瑙e喅java web 椤圭洰鍙戝竷webservice鎺ュ彛的主要内容,如果未能解决你的问题,请参考以下文章
鐧藉珫鐗?2019Java寮€鍙戝叏缁堢瀹炴垬绉熸埧椤圭洰瑙嗛鏁欑▼