Axis2ってWDSLのツールが便利だった覚えがあるんだけど、ちょっとわすれたなぁ。
ダウンロードして解凍すると下記のようなフォルダが出てくる axis2-1.5\bin
日本語のページみてもまともに最後まで動くドキュメントがないから、本家のStartGuide?を和訳する。たぶん途中で、和訳に飽きるから、だれか気が向いたら手伝ってくれたらうれしい。
URLはこちら
http://ws.apache.org/axis2/1_5_1/quickstartguide.html#deploy
この章では, 5通りのWebサービスの作り方示していきます。(訳:この和訳ではPOJO(deploying Plain Old Java Objects のこと)だけだけどね)。 1つは、StockQuoteService? と命名したPOJOなクラス。 2つめはAXIOM形式、 3つめはAxis2のデータをくっつけるフレームワークであるADB(Axis2 Databinding Frameworkの略) 4つめは, XML 5つめは, JiBXです。
To deploy the service using POJOs (Plain Old Java Objects), execute the following steps.
注意: the directory structure contained at AXIS2_HOME/samples/quickstart (the services.xml file is from the first section of this guide):
- quickstart - README.txt - build.xml - resources - META-INF - services.xml - src - samples - quickstart - service - pojo - StockQuoteService.java
注意: that you can generate a WSDL from the quickstart directory by typing:
ant generate.wsdl
However, creating StockQuoteService?.wsdl is optional. It can be the version generated directly from the Java class, or a customized version of that file, and that services.xml is the same file referenced earlier in this document.
Now build the project by typing ant generate.service in the quickstart directory, which creates the following directory structure:
- quickstart/build/classes - META-INF - services.xml - samples - quickstart - service - pojo - StockQuoteService.class
If you want to deploy the service in an exploded directory format, rename the classes directory to StockQuoteService?, and copy it to the webapps/axis2/WEB-INF/services directory in your servlet engine. Otherwise, copy the build/StockQuoteService?.aar file to the webapps/axis2/WEB-INF/services directory in your servlet engine. Then check to make sure that the service has been properly deployed by viewing the list of services at:
http://localhost:8080/axis2/services/listServices
You can also checkout the WSDL at:
http://localhost:8080/axis2/services/StockQuoteService?wsdl
And the schema at:
http://localhost:8080/axis2/services/StockQuoteService?xsd
Once the URLs are working, quickly test the service. Try pointing your browser to the following URL:
http://localhost:8080/axis2/services/StockQuoteService/getPrice?symbol=IBM
You will get the following response:
<ns:getPriceResponse xmlns:ns="http://pojo.service.quickstart.samples/xsd"><ns:return>42</ns:return></ns:getPriceResponse>
If you invoke the update method as,
http://localhost:8080/axis2/services/StockQuoteService/update?symbol=IBM&price=100
and then execute the first getPrice URL, you will see that the price has got updated.
最新版(2010/06/29時点での最新)落としたけど、
エラーが出て使い物にならなかった。
おっかしいいなぁ、去年の9月ごろのプロジェクトでは楽天のWDSLの変換で、
ちゃんと使えていたのになぁ。
とりあえず、今は勉強のため、調べているだけなのでHelloWorld?的なサンプルを動かすところまでメモっておきたい。
C:\axis2-1.5.1\bin>wsdl2java.bat -uri http://ec2.amazonaws.com/doc/2009-03-01/AmazonEC2.wsdl -o out Using AXIS2_HOME: C:\axis2-1.5.1 Using JAVA_HOME: C:\java\jdk1.6.0_20 Retrieving document at 'http://ec2.amazonaws.com/doc/2009-03-01/AmazonEC2.wsdl'.
Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException?: Error parsing WSDL
at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.<init>(CodeGenerationEngine.java:156) at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35) at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24) Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=OTHER_ERROR: Unable to resolve imported document at 'http://ec2.amazonaws.com/doc/2009-03-01/AmazonEC2.wsdl'.: java.net.SocketException: Connection reset by peer: connect at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source) at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.readInTheWSDLFile(CodeGenerationEngine.java:288) at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.<init>(CodeGenerationEngine.java:111) ... 2 more Caused by: java.net.SocketException: Connection reset by peer: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:529) at java.net.Socket.connect(Socket.java:478) at sun.net.NetworkClient.doConnect(NetworkClient.java:163) at sun.net.www.http.HttpClient.openServer(HttpClient.java:394) at sun.net.www.http.HttpClient.openServer(HttpClient.java:529) at sun.net.www.http.HttpClient.<init>(HttpClient.java:233) at sun.net.www.http.HttpClient.New(HttpClient.java:306) at sun.net.www.http.HttpClient.New(HttpClient.java:323) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:860) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:801) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:726) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1049) at java.net.URL.openStream(URL.java:1010) at com.ibm.wsdl.util.StringUtils.getContentAsInputStream(Unknown Source)
... 6 more
http://builder.japan.zdnet.com/sp/09-personal-cloud/story/0,3800097247,20393200-3,00.htm
http://www.ee.e-mansion.com/~egami/axis2/index.html
よさそうだったので、これをたしかめてみる。
http://www.crosschecknet.com/web_services_testing_tools_amazon_ec2.php
おいおい、コンパイルエラーじゃん。
あと、必要なjarファイルが2つも取り込まれていないって、どーゆーことなわけ?
おそらく、自分の間違いじゃないはず、だって
2010/06/29時点で最新のEclipseのオールインワンで取り込んだんだもの。
List型で帰ってくる箇所をArrayList?型で代入しようとしている箇所でコンパイルエラーになっていたので、キャストするように修正
http://localhost:8080/axis2/services/Version?wsdl
Tomcatはダウンロードして解凍してあれば多分動作します。
HTTPステータス 404 - /axis2/services/
となる
<?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:ns="http://axisversion.sample" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://axisversion.sample"> <wsdl:documentation>Version</wsdl:documentation> <wsdl:types> <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://axisversion.sample"> <xs:complexType name="Exception"> <xs:sequence> <xs:element minOccurs="0" name="Exception" nillable="true" type="xs:anyType"/> </xs:sequence> </xs:complexType> <xs:element name="Exception"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="Exception" nillable="true" type="ns:Exception"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="getVersionResponse"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> </wsdl:types> <wsdl:message name="getVersionRequest"/> <wsdl:message name="getVersionResponse"> <wsdl:part name="parameters" element="ns:getVersionResponse"/> </wsdl:message> <wsdl:message name="Exception"> <wsdl:part name="parameters" element="ns:Exception"/> </wsdl:message> <wsdl:portType name="VersionPortType"> <wsdl:operation name="getVersion"> <wsdl:input message="ns:getVersionRequest" wsaw:Action="urn:getVersion"/> <wsdl:output message="ns:getVersionResponse" wsaw:Action="urn:getVersionResponse"/> <wsdl:fault message="ns:Exception" name="Exception" wsaw:Action="urn:getVersionException"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="VersionSoap11Binding" type="ns:VersionPortType"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <wsdl:operation name="getVersion"> <soap:operation soapAction="urn:getVersion" style="document"/> <wsdl:input> <soap:body use="literal"/> </wsdl:input> <wsdl:output> <soap:body use="literal"/> </wsdl:output> <wsdl:fault name="Exception"> <soap:fault use="literal" name="Exception"/> </wsdl:fault> </wsdl:operation> </wsdl:binding> <wsdl:binding name="VersionSoap12Binding" type="ns:VersionPortType"> <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <wsdl:operation name="getVersion"> <soap12:operation soapAction="urn:getVersion" style="document"/> <wsdl:input> <soap12:body use="literal"/> </wsdl:input> <wsdl:output> <soap12:body use="literal"/> </wsdl:output> <wsdl:fault name="Exception"> <soap12:fault use="literal" name="Exception"/> </wsdl:fault> </wsdl:operation> </wsdl:binding> <wsdl:binding name="VersionHttpBinding" type="ns:VersionPortType"> <http:binding verb="POST"/> <wsdl:operation name="getVersion"> <http:operation location="Version/getVersion"/> <wsdl:input> <mime:content type="text/xml" part="getVersion"/> </wsdl:input> <wsdl:output> <mime:content type="text/xml" part="getVersion"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="Version"> <wsdl:port name="VersionHttpSoap11Endpoint" binding="ns:VersionSoap11Binding"> <soap:address location="http://localhost:8080/axis2/services/Version.VersionHttpSoap11Endpoint/"/> </wsdl:port> <wsdl:port name="VersionHttpSoap12Endpoint" binding="ns:VersionSoap12Binding"> <soap12:address location="http://localhost:8080/axis2/services/Version.VersionHttpSoap12Endpoint/"/> </wsdl:port> <wsdl:port name="VersionHttpEndpoint" binding="ns:VersionHttpBinding"> <http:address location="http://localhost:8080/axis2/services/Version.VersionHttpEndpoint/"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
http://localhost:8080/axis2/services/AnnoTestServiceService.AnnoTestServicePort/sayHello?yourName=egami [#ede9a88f]
[ERROR] An error was detected during JAXWS processing org.apache.axis2.AxisFault: An error was detected during JAXWS processing at org.apache.axis2.jaxws.server.JAXWSMessageReceiver.receive(JAXWSMessageReceiver.java:187) at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:173) at org.apache.axis2.transport.http.util.RESTUtil.invokeAxisEngine(RESTUtil.java:135) at org.apache.axis2.transport.http.util.RESTUtil.processURLRequest(RESTUtil.java:130) at org.apache.axis2.transport.http.AxisServlet$RestRequestProcessor.processURLRequest(AxisServlet.java:838) at org.apache.axis2.transport.http.AxisServlet.doGet(AxisServlet.java:262) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:595)