- 追加された行はこの色です。
- 削除された行はこの色です。
[[JAVAの記事一覧]]
*目次 [#cf14e4bc]
#contents
*Axis2 [#jb30914a]
Axis2ってWDSLのツールが便利だった覚えがあるんだけど、ちょっとわすれたなぁ。
**URL [#af633fc1]
http://ws.apache.org/axis2/
**使い方 [#fb7d0b72]
ダウンロードして解凍すると下記のようなフォルダが出てくる
axis2-1.5\bin
**基本的な設定 [#ud8add36]
*いろいろな日本語のサイトをみて実験 [#m7edc867]
***こんなエラーがました。 [#i614ddf6]
最新版(2010/06/29時点での最新)落としたけど、
エラーが出て使い物にならなかった。
おっかしいいなぁ、去年の9月ごろのプロジェクトでは楽天のWDSLの変換で、
ちゃんと使えていたのになぁ。
とりあえず、今は勉強のため、調べているだけなのでHelloWorld的なサンプルを動かすところまでメモっておきたい。
***エラーログ [#fb5c9adb]
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'.
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
*アマゾンの場合はツールを使おう [#c4a2ba75]
http://builder.japan.zdnet.com/sp/09-personal-cloud/story/0,3800097247,20393200-3,00.htm
***参考URL [#f1bba7db]
-Axis2でクラウド用のWebサービスクライアントを作成する
http://japan.internet.com/developer/20090714/26.html
-Apache Axis2 (Pukiwiki)
http://w3.doshisha.ac.jp/~mogawa/index.php?Apache%20Axis2
-Axis2によるWebサービス
http://www.ee.e-mansion.com/~egami/axis2/index.html
よさそうだったので、これをたしかめてみる。
-チュートリアル風(英語)
http://www.crosschecknet.com/web_services_testing_tools_amazon_ec2.php
***axis2.bat [#f86e001f]
***axis2server.bat [#q7fddae0]
***java2wsdl.bat [#d5f30e4c]
***wsdl2java.bat [#q2fc0293]
*Axis2のwarファイルをEclipseにインポートしてみる。 [#v20a503a]
おいおい、コンパイルエラーじゃん。
あと、必要なjarファイルが2つも取り込まれていないって、どーゆーことなわけ?
おそらく、自分の間違いじゃないはず、だって
2010/06/29時点で最新のEclipseのオールインワンで取り込んだんだもの。
**修正箇所 [#l7703a7f]
List型で帰ってくる箇所をArrayList型で代入しようとしている箇所でコンパイルエラーになっていたので、キャストするように修正
**取り込みJar [#xfd67ded]
-jsp-api.jar
-servlet-api.jar
*いざ実行 [#m48d64d1]
http://localhost:8080/axis2/services/Version?wsdl
Tomcatはダウンロードして解凍してあれば多分動作します。
**Tomcatが動いていない場合 [#x13bb741]
HTTPステータス 404 - /axis2/services/
となる
**正常な結果 [#f0bda0c3]
<?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>
**ためしにやってみました。 [#n1231f44]
http://localhost:8080/axis2/services/AnnoTestServiceService.AnnoTestServicePort/sayHello?yourName=egami [#ede9a88f]
**こんなエラーが出てきました。 [#k59dd38e]
[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)
*参考ページ [#oe2ed3c2]
下記のURLも参考にしようか
http://wikiwiki.jp/lovebeer/?%B3%D8%A4%D6%2F%A5%B5%A5%F3%A5%D7%A5%EB%2FAXIS2_POJO