快速建置Web Service Provider

by Daphne Lin 11. 十月 2010 00:16

作者:戴谷州

精誠資訊 恆逸教育訓練中心 資深講師



異質平台整合需求

實際開發上有時會需要與其他異質平台整合,無論是與.NET甚至是其他各種程式語言所開發的應用程式,採用Web Service技術則是一個最佳選擇。Web Service可以分作服務提供者(Service Provider)與使用服務者(Service Requester),後者只要先取得服務提供者WSDL的URL或是實體檔案,接下來的工作只需要交給IDE,一切就搞定了。

本文主題為撰寫服務提供者,以執行在JBoss Application Server 為例,只要按照以下步驟,就可以完成:

1. 建立一個自定類別

public class MyMathWS {

public int Add(int i, int j){

return i+j;

}

}


2. 加入適當的annotation

import javax.jws.WebService;

import javax.jws.soap.SOAPBinding;

@WebService

@SOAPBinding(style = SOAPBinding.Style.RPC)

public class MyMathWS {

….略


3. 設定web.xml,以下為檔案片段

import javax.jws.WebService;

<servlet>

<servlet-name>MyPOJOService</servlet-name>

<servlet-class>com.uuu.MyMathWS</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>MyPOJOService</servlet-name>

<url-pattern>/*</url-pattern>

</servlet-mapping>


沒錯,直接撰寫一個自定類別加上annotation,就可以輕輕鬆鬆完成一個Web Service Provider;不過要記得設定web.xml是在JBoss Application Server執行才有需要這個設定喔。如果要執行在其他Application Server,則要參考其設定文件。

最後再確認是否部署成功:http://localhost:8080/jbossws/services

clip_image003



可在課程中了解更多的 Web Service…
相關學習資源︰ DWS-3111-EE5 : 使用Java 技術開發Web Services

                    DWS-4112-EE5 : 設計Java Web Services實作服務導向架構-SOA

                    DWS-4120-EE5 : 開發安全的Java Web Services

                    JB295 : JBoss企業應用程式開發

Tags:

Java | 戴谷州Ken Tai

評論 (40) -

cours de theatre
cours de theatre United States
2017/9/30 下午 11:06:58 #

I truly appreciate this blog article.

回覆

can ho bien vung tau
can ho bien vung tau United States
2017/10/9 下午 07:37:17 #

Say, you got a nice blog article. Much obliged.

回覆

Google cheat 2017
Google cheat 2017 United States
2017/10/12 下午 10:15:50 #

Appreciate you sharing, great blog.Much thanks again. Want more.

回覆

Get the facts
Get the facts United States
2017/10/14 下午 05:31:56 #

Thanks a lot for the blog post.Much thanks again. Keep writing.

回覆

go now
go now United States
2017/10/17 下午 04:21:05 #

Very informative article. Really Cool.

回覆

sletrokor
sletrokor United States
2017/10/17 下午 09:52:42 #

Thanks again for the post. Want more.

回覆

VigRx
VigRx United States
2017/10/19 上午 08:56:10 #

Muchos Gracias for your blog post.Really looking forward to read more. Cool.

回覆

see page
see page United States
2017/10/19 下午 08:01:46 #

Thanks a lot for the blog.Really thank you! Keep writing.

回覆

prix carte grise
prix carte grise United States
2017/10/21 上午 09:00:19 #

Thank you for your blog article.Thanks Again. Really Cool.

回覆

phentaslim
phentaslim United States
2017/11/3 下午 12:14:45 #

I loved your article post.Really looking forward to read more. Want more.

回覆

home remedies for back pain
home remedies for back pain United States
2017/11/15 上午 05:23:15 #

Very good article post.Really thank you! Fantastic.

回覆

avocat criminel quebec
avocat criminel quebec United States
2017/11/16 下午 04:01:23 #

I am so grateful for your blog post.Really thank you! Much obliged.

回覆

Cheap Website Design Nz
Cheap Website Design Nz United States
2017/11/25 下午 04:22:46 #

Im obliged for the post.Really looking forward to read more. Want more.

回覆

Chad Boonswang and Jeffrey Goodman
Chad Boonswang and Jeffrey Goodman United States
2017/11/26 下午 03:34:09 #

I loved your blog article.Really looking forward to read more. Want more.

回覆

Chad Boonswang SEO
Chad Boonswang SEO United States
2017/11/26 下午 09:32:08 #

I am so grateful for your article.Really looking forward to read more. Great.

回覆

New City thu thiem
New City thu thiem United States
2017/11/29 下午 08:27:17 #

Say, you got a nice article post. Great.

回覆

ICO
ICO United States
2017/11/30 下午 10:23:21 #

Thanks for sharing, this is a fantastic blog.Really thank you! Much obliged.

回覆

ICO
ICO United States
2017/12/3 上午 02:21:06 #

Thank you ever so for you blog article.Really thank you!

回覆

Very neat post.Really thank you! Awesome.

回覆

I truly appreciate this blog post.Really looking forward to read more. Fantastic.

回覆

Fidel Collora
Fidel Collora United States
2017/12/14 上午 06:57:46 #

Great, thanks for sharing this post.Much thanks again. Great.

回覆

canon driver software
canon driver software United States
2017/12/16 下午 03:30:44 #

I appreciate you sharing this blog.Much thanks again. Really Cool.

回覆

weight loss
weight loss United States
2017/12/16 下午 09:43:59 #

Muchos Gracias for your article post.Much thanks again. Awesome.

回覆

Thanks again for the blog article.Really looking forward to read more. Fantastic.

回覆

Mid-market
Mid-market United States
2017/12/17 下午 03:13:51 #

Very good blog article.Really thank you! Great.

回覆

look at more info
look at more info United States
2017/12/17 下午 10:14:02 #

Looking forward to reading more. Great blog.Really looking forward to read more.

回覆

working home
working home United States
2017/12/20 下午 04:21:53 #

Thanks-a-mundo for the article post.Really looking forward to read more. Want more.

回覆

driver canon
driver canon United States
2017/12/23 上午 05:44:05 #

This is one awesome blog. Really Great.

回覆

Darwin Horan
Darwin Horan United States
2017/12/23 下午 04:12:22 #

Really informative blog post.Much thanks again. Really Cool.

回覆

driver hp
driver hp United States
2017/12/25 下午 05:46:08 #

Say, you got a nice blog.Much thanks again. Keep writing.

回覆

&#216;&#162;&#219;Œ&#217;†&#217;‡
آینه United States
2017/12/26 上午 05:36:46 #

Fantastic post.Much thanks again. Really Great.

回覆

SOCCER HIGHLIGHTS
SOCCER HIGHLIGHTS United States
2017/12/26 下午 05:01:11 #

I really liked your blog article.Thanks Again. Really Cool.

回覆

canon printer series
canon printer series United States
2017/12/27 下午 08:51:18 #

Very informative blog.Really looking forward to read more. Great.

回覆

more information
more information United States
2018/1/2 下午 07:34:53 #

Muchos Gracias for your article.Really thank you! Great.

回覆

hp drivers
hp drivers United States
2018/1/3 上午 10:47:45 #

Really enjoyed this post.Really thank you! Will read on...

回覆

mobile slots real money
mobile slots real money United States
2018/1/4 下午 09:35:04 #

Really informative blog article.Thanks Again. Fantastic.

回覆

hp printer driver
hp printer driver United States
2018/1/5 下午 05:47:51 #

Very neat blog.Really thank you! Really Cool.

回覆

FBA
FBA United States
2018/1/6 上午 09:53:55 #

Thanks for sharing, this is a fantastic blog.Much thanks again. Want more.

回覆

colocation miami
colocation miami United States
2018/1/10 下午 01:02:13 #

Im thankful for the post.Thanks Again. Much obliged.

回覆

新增評論




  Country flag
biuquote
  • 評論
  • 線上預覽
Loading






NET Magazine國際中文電子雜誌

NET Magazine國際中文電子版雜誌,由恆逸資訊創立於2000,自發刊日起迄今已發行超過500篇.NET相關技術文章,擁有超過40000名註冊讀者群。NET Magazine國際中文電子版雜誌希望藉於電子雜誌與NET Developer達到共同學習與技術新知分享,歡迎每一位對.NET 技術有興趣的朋友們多多支持本雜誌,讓作者群們可以有持續性的動力繼續爬文。<請加入免費訂閱>

月分類Month List