最簡單的Web Service實現,webservice實現

來源:互聯網
上載者:User

最簡單的Web Service實現,webservice實現
概述

這裡提供一個最簡單的Web Service的實現,基於JAX-WS。除了jdk不需要任何其他jar包,使用Eclipse提供的Web Services Explorer訪問服務。服務端的實現
package cn.ljl.sand.jws.chapter0.service;import javax.jws.WebService;import javax.xml.ws.Endpoint;@WebServicepublic class HelloService {    public String hello(String name) {        return "Hello," + name;    }        public static void main(String[] args) {        String address = "http://localhost:6666/service/hello";        Endpoint.publish(address, new HelloService());    }}

這裡類有兩個地方值得注意:

通過Eclipse的工具進行訪問Eclipse內嵌了Web Services Explorer工具,可以作為用戶端,訪問我們上面發布的服務。1. 在Eclipse設定web瀏覽器Web Services Explorer需要使用瀏覽器開啟,可以使用Eclipse內嵌的瀏覽器,或者其他外部的瀏覽器。我這裡使用了Google瀏覽器,後來發現無法看到SOAP報文,又切換了IE瀏覽器。2. 開啟工具Run - Launch the Web Services Explorer3. 請求服務這裡的wsdl的地址,是我們在服務端發布的地址,加上?wsdl。    



來自為知筆記(Wiz)



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.