My decision was correct. I finally made myarch’s example run. I also proved that the article http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/ was correct. If you don’t use literal wrapped style, web service can’t distinguish one method from another. However, I found a way to distinguish it even if you use literal style. In this blog, I would like to show the complete steps of how to run myarch’s example with Sun’s Metro.
Some of readers may not read my past blogs. I starts from a really beginning. The followings are the system software I used. Java SDK 1.6.04, Tomcat 5.5.26, Sun Metro 1.3, and ANT 1.6.5. The order of installation is first Java SDK, and then Tomcat, and finally Metro 1.3. The Metro provides Ant script to install Metro into the Tomcat. https://metro.dev.java.net/1.2/docs/install.html I used Eclipse 3.4 IDE. Since I rely on the Ant script in this experiment, you can use any IDE or editor.
First, to make sure Metro is running on Tomcat, use this “From-WSDL example”: https://metro.dev.java.net/getting-started/basic.html and follow the instruction steps on that page. As you see, this example does not use JAXB practically. Including myself, web service beginners would like to see more complex examples, but I could not find any example on the Internet (maybe, you could.)
Next, please review myarch’s example: http://myarch.com/create-jax-ws-service-in-5-minutes and download the complete schema file and WSDL file on that page. Create a directory for this experiment and copy downloaded files. Also create build, etc, and src directories. Copy all files in etc directory of the Metro’s basic example you run to the etc directory you created. Finally, copy build.xml file in the basic example to the new directory you created.
When you see the contents in your etc directories, you will see the following files:
-
AddNumber.wsdl
-
build.properties
-
custom-client.xml
-
custom-server.xml
-
person.xsd
-
personService.wsdl
-
sun-jaxws.xml
-
web.xml
We are going to update 4 files: custom-client, custom-server, sun-jaxws, and web xml files as well as build.properties and ../build.xml files. In addition, we create PersonServiceImpl.java and PersonServiceClient.java classes. You can download all files already updated from http://sites.google.com/site/takechanweb/Home/learning-web-service-4 . Please download Java source files into the appropriate package.
After you downloaded, open Command Window and move to your directory you created and run the following commands.
-
ant –Duse.tomcat=true server
-
ant –Duse.tomcat=true client
-
ant –Duse-tomcat=true run
You should see the following result.
[java] Invoking add method…
[java] result = [Hey there, I'm a person!]
[java] Invoking add2 method…
[java] result2 = [1000]
If you open your Tomcat stdout log file, you will see
First name = [Shigeru]
Last name = [Takehara]
Name = [hitotsume]
I will comment about this experiment in the next blog.
自分の選択は正しかった。やっと、Myarchの例を動かすことが出来た。それから、この記事http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/ も正しいことが分かる。もしLiteral/Wrappedスタイルをつかわないと、Web Serviceは、メソッドを正しく認識できない時がある。(パラメーターのタイプが全く同じ時)でも、その区別の仕方が分かる。ここでは、Myarchの例をサンのメトロの上で、動かすことを紹介する。
読者の中で、私の前のブログを読んでいない人がいるかも。では最初から。次のシステムソフトウェを使う:Java SDK 1.6.04, Tomcat 5.5.26、Sun Metro 1.3, ANT 1.6.5. インスタレーションの順序は、Java SDK, Tomcat, Metroの順。Metroは、自身をTomcatに組み込むANT Scriptがある。. https://metro.dev.java.net/1.2/docs/install.htmlエディターには、 Eclispe3.4を使う。主にANT Scriptを使うから、どの IDEでも良い。
最初にMetroがTomcatで動いていることを、“From-WSDL example”: https://metro.dev.java.net/getting-started/basic.htmlでステップに従って動作を確認する。見てのとおり、この例は、JAXBを実装しているとはいえない。私を含めて、Web Serviceの出始めの人たちは、もっと複雑な例が見たい。けれども、インターネットで探しても見当たらない。
次にMyarchの例を見直そう http://myarch.com/create-jax-ws-service-in-5-minutes そして完全なShemaファイルとWSDLファイルをダウンロードすること。この実験のためのディレクトリをつくり、ダウンロードしたファイルをそこにコピーする。そして、build, etc, srcのディレクトリもつくる。Metroのベーシックの例のetc ディレクトリの中のすべてのファイルをetcディレクトリにコピー。最後にbuild.xmlファイルを最初につくったディレクトリにコピーする。
Etcのディレクトリの中を見ると、次のファイルがある。
-
AddNumber.wsdl
-
build.properties
-
custom-client.xml
-
custom-server.xml
-
person.xsd
-
personService.wsdl
-
sun-jaxws.xml
-
web.xml
この中から4つのファイル:: custom-client, custom-server, sun-jaxws, web xml それから、build.properties と ../build.xmlファイルを書き換える。それから、PersonServiceImpl.java と PersonServiceClient.java クラスを作成。書き換えられたファイルはfrom http://sites.google.com/site/takechanweb/Home/learning-web-service-4から、ダウンロードして下さい。Javaのソースファイルはパッケージ名に注意して下さい。
ファイルをダウンロードしたら、コマンドWindowをあけて、この実験のディレクトリに移り、次のコマンドを実行する。
-
ant –Duse.tomcat=true server
-
ant –Duse.tomcat=true client
-
ant –Duse-tomcat=true run
次のような結果が表示
[java] Invoking add method…
[java] result = [Hey there, I'm a person!]
[java] Invoking add2 method…
[java] result2 = [1000]
Tomcatのstdout ログファイルをみると、
First name = [Shigeru]
Last name = [Takehara]
Name = [hitotsume]
この実験のコメントは次回のブログで。