2020国产成人精品视频,性做久久久久久久久,亚洲国产成人久久综合一区,亚洲影院天堂中文av色

分享

學(xué)習(xí)Java6(一) WebServices (3)在tomcat中發(fā)布 - 交口稱(chēng)贊 -...

 nbtymm 2007-01-08

為了滿(mǎn)足廣大網(wǎng)友的要求,今天抽時(shí)間搞了下WebServices 在tomcat中的發(fā)布
相關(guān)文章:
tomcat啟動(dòng)時(shí)自動(dòng)加載servlet
學(xué)習(xí)Java6(一) WebServices (1)服務(wù)端
學(xué)習(xí)Java6(一) WebServices (2)客戶(hù)端

新建一個(gè)servlet,偶太,能少打一個(gè)字符都是好的,所以servlet寫(xiě)的非常簡(jiǎn)潔,也適合初學(xué)者看得懂。。。。。。。。。。
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("準(zhǔn)備啟動(dòng)服務(wù)");
19         Endpoint.publish("http://localhost:8080/HelloService"new Hello());
20         System.out.println("服務(wù)啟動(dòng)完畢");
21     }
22 }
23 

web service類(lèi)Hello.java也是非常簡(jiǎn)單
 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./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./xml/ns/j2ee"
 3     xmlns:xsi="http://www./2001/XMLSchema-instance"
 4     xsi:schemaLocation="http://java./xml/ns/j2ee 
 5     http://java./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
就這三個(gè)文件。。。。。。。。。啥jar都不要。。。。
發(fā)布,啟動(dòng)服務(wù)器
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()
準(zhǔn)備啟動(dòng)服務(wù)
服務(wù)啟動(dòng)完畢
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


訪問(wèn):http://localhost:8080/HelloService?wsdl
 1   <?xml version="1.0" encoding="UTF-8" ?> 
 2 <definitions xmlns="http://schemas./wsdl/" xmlns:tns="http://jdk.study./client" xmlns:xsd="http://www./2001/XMLSchema" xmlns:soap="http://schemas./wsdl/soap/" targetNamespace="http://jdk.study./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./soap/http" /> 
18 <operation name="sayHello">
19   <soap:operation soapAction="" /> 
20 <input>
21   <soap:body use="literal" namespace="http://jdk.study./client" /> 
22   </input>
23 <output>
24   <soap:body use="literal" namespace="http://jdk.study./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!
客戶(hù)端寫(xiě)法照舊

呵呵,這下大家滿(mǎn)意了吧。。。。。。。。。
有沖動(dòng)想把項(xiàng)目里的xfire撤掉了。。。。。。。。。。。。。。。。。

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶(hù) 評(píng)論公約

    類(lèi)似文章 更多