Index

What is "Web Service Developer Pack"!?
-my final conflict using NetBeans4

I have a question unsolved for 2-3 years.
That is, "What is Web Service Developer Pack!?"
We can download it, and extract. Recently this unknown tool even has an installer. Install finished, and THEN!?..Fortunately we have a guidance in NetBeans,ORG's knowledgebase document. So let's make NB4 of it to solve the mystery!

After reading this drama, please proseed to the improved version.

/Get the JWSDP/Taming JWSDP Tomcat in NB4/Favorites Window -useful!/Executing sample client/Customize Sample service and client/My JAX-RPC Web Service from scratchH/ Investigate config.xml/Investigate build.xml /Bottoming-up Web Service!/Changing dependencies among the targets/My setting of classpath /At last reached here, but..../Follow the NB.ORG document / The end of .war war/

Get the JWSDP

What is Web Service!? There had been days when I was thinking only about it. Then I first met Web Service Developer Pack, downloaded and extracted it, but I did not know at all how to use that. I remember there was Tomcat packaged together.

In NB3.6, Axis Web Service worked beautifully. In NB4 the beauty was decreased much but it was managed to work. Then I must try on JAX-RPC in JWSDP again, this time using NB4.

First of all, download the recent JWSDP. This time, I got jwsdp-1_5-windows-i586.exe. Double-clicking it I was surprised to find it was an installer, instead of self-extracting executable! In the past it used to be a pale archive extracted to be one pale folder and "How can I getting along with it!?" I thought...

The installer asked where to install or where I have Java home. This time I set to use JDK5.

The important setting through this installer was what Web Container I should use.

As I wrote above, before JWSDP had its Tomcat bundled. Now we have options, Sun App Server or Tomcat specialized forJWSDP. I selected the latter.

Why only Tomcat? Because it can be registered in NB4. Yes, this time I WANT to operate it in NB4.

The Web container should be downloaded separately.

http://java.sun.com/webservices/containers/

The above site you can select Sun App Server or JWSDP-Tomcat.

At last I got the file

tomcat50-jwsdp.zip

It's just to be extracted. The product is a single directory named tomcat50-jwsdp . I located it as c:\tomcat50-jwsdp.

Then return to JWSDP install wizard and set the above directory as the Web Container.

Now JWSDP is ready.


Taming JWSDP Tomcat in NB4

I remember this trial failed in NB3.6. An error ocurred on starting it, but sorry, I don't remember in detail. Tomcat used was version 4 at that time. Now how about Cat5?

Let's try. Switch to "Runtime" window, Find the node "Server Registory"->"Tomcat5 Server. Right-click it and select "Add New Server".
The picture below was shot after adding it.

The "Add New Server" Window appears.

For Install Directory, c:\tomcat50-jwsdp. It would be safer from errors that "Shared Installation( use different home and base directory)" should not be checked.
ForDisplay Name, JWDSP.
UserName and Password corresponds to those set during installation of JWSDP.

Clicking "OK", The new Tomcat icon is added. If you start this....Oh?

I got no error this time.

Ah...sometimes this tomcat might fail to start, as far as I know...because of an error of Shared Memory or something. Only I know is this error has something relatad with debugging memory or something. Only I could do to skip that error was display Properties window of JWSDP Tomcat and change "Debugging Type" from "Shared Memory" to "Socket"...

By the selection above, This Tomcat becomes unable to start in debugging mode, but anyway it starts...This is what I was going to write, but now there was no trouble in normal start.

Why?

Ah, good. Anyway, you could see Web Services and Web Applications pre-deployed in this Tomcat.

Oh, please don't care about jaxrpc-MyHelloWorld from above list. It was one of my trial . Instead, jaxrpc-HelloWorld was the pre-deployed one.


Favorites Window -useful!

Now, how to build Web Services using this WSDP? Let's play on the sample sources before everything

From some former experience I can imagine the rough procedure...

Prepare source files in a given directory.
Write build.xml file including tasks wscompile and wsdeploy.
Run proper targets of the buildfile to build up a suitable Web module and deploy it to server.

This time I found it's best to use "Favorites"window for operating the samples.

I 'm beginning to think this "Favorites" window might be an answer to many users shouting "HOW CAN I MOUNT FILESYSTEM IN NB FOOOOOOUR".

Switch to "Favorites" window. Or it might not be cascaded with other window for the first time. Then go to Menubar and select "Window"->"Favorites".

Right-click the root node "Favorites" and select "Add to Favorite".A filechooser appears, so select

C:\Sun\jwsdp-1.5\jaxrpc

Well, it really looks like a good old "Filesystems" window....

The source files are in "samples"->"HelloWorld"->"src" folder.

"HelloImpl.java" is the source for the service. Oh where is it's interface?...I don't know, but it does work as described later...

I don't know.

"HelloClient.java" is the source for the client.


Executing sample client

Let's check what is written in the client file. Double-clicking "HelloClient.java" node, the source code appears in NB4 editor.

Never mind of the red waved lines indicating errors. This time we don't use NB4's compiling system. Instead, the build.xml file prepared by JWSDP will manage everything, for example setting classpath, javac, jar, copying....

First of all, let's execute this client as is. Make sure JWSDP Tomcat is running, instead of bundled one. Go to "Favorites" window and find the node...NOT "HelloClient" node. It will only result in nothing or some errors.

Find the node build.xml.
Open it to display the child node "run-client",right-click it and select "Run Target".

Then ant runs and runs in NB's outpu console. Finally we get

Oh, the result. The string JAXRPC Sample was returned, modified by the HelloWorld Service.

Very interesting, NB4 never touches on starting JWSDP's sample service and executing its client, but give the Graphical place for those operation. Don't you think it's a new usage of IDE?


Customize Sample service and client

Next to do is to customize them.

The client seems easier for it. Edit the source code in the editor but never mind of the red line. Yes, it's a trivial matter in the infinite potential of NB4 usage!

Sorry for the new string in Japanese, which means "Developer's Pack". Keep away from "HelloClient.java" node again and go to "build.xml" node. Find its child node "run client", right-click it, select "Run Target".

Easy!

Now the service. The pre-deployed current HelloWorld service could not be overwritten directly. First I must stop and undeploy the current jaxrpc-HelloWorld service. This could be done in NB4's "Runtime" window.

Then I edited the source of HelloImpl.java .

Returning string can be translated into "What the hell" is + str".

Save this code. Next, the configuration files.

Look at the later part of "build.properties"....

This is for selection of the Web Container The default value "sjsws" means "Sun Java Studio Web Server".

Did you forget I had selected Tomcat on installation Gorhuaaaa

Is it a bug? Ah, good. Edit this part as

The value of "container" was changed to "tomcat".
The value of "tomcat.root"was changed to the absolute path of JWSDP-Tomcat.

Save build.properties. Next, tomcat.xml. Look out this commented-out part:

But I needed.

Is it a bug!?

Anyway, I released it from commented-out.

Then, build.xml. Let's run the target "deploy-war".

Ant rushes again and, if it ends without errors, Stop and restart JWSDP-Tomcat.

Run "run-client" target once more...

Ah, complete Japanese sentence meaning "What the hell is Developer's Pack?".


My JAX-RPC Web Service from scratchH

Therefore, we could use the sample easily. But could we build JAX-RPC Web Service from scratch using JWSDP?

I copied this WSDP sample, not the whole but what I thought is required, to the folder I use for NB4 projects. The root folder was named wsdpttwo.

This time I created the interface, MyHello.IF.

Well, customizing is simple. Replace all "Hello" with "MyHello" to upper or lower cases, including endpoint or package names. So, go to build.xml->deploy-war and run!

ERROR.

This first error was "Cannot find MyHelloService.wsdl".

Find? Isn't it You to create that?


Investigate config.xml

Investigating this error more and I found it was "Cannot find MyHelloServis.wsdl required by config.xml file refferenced by this build.xml".
Umm, let's check config.xml.

<configuration
xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
<wsdl
location="./etc/MyHelloWorldService.wsdl"
packageName="myhello" />
</configuration>

Ah, yes I remember I made this replacing "Hello" of HelloWorld sample to "MyHello" etc. When I made this I thought this description were to CREATE this wsdl file...

Take a look at the original sample. There is surely the wsdl file.

And I thought it had been created by running ant....


Investigate build.xml

I had not look into deploy-war target on running ( or LOOK, Noniko!) At last I investigated build.xml and found there was a daisy-chained depenencies:

deploy-war>build-war>create-war>compile-server>generate-server>prepare

Target prepare: to make directories for outputting files.

Target gerenate-server. Here's an important part of that extracted:

<wscompile
keep="true"
import="true"
base="${samplesbuild}/${appname}/classes/server"
xPrintStackTrace="true"
verbose="false"
model="${samplesbuild}/${appname}/${model.rpcenc.file}"
classpath="${compile.classpath}"
config="${config.rpcenc.file}">

</wscompile>

Task wscompile corresponds to wscompile toos explained in the JAX-RPC document packaged in JWSDP:

file:///C:/Sun/jwsdp-1.5/jaxrpc/docs/jaxrpc-tools.html

keep="true" means keep temporary files created by running the target.

import="true" was the cause of this error. It means "Read the existing WSDL file and create templates for service classes.

model=....means writing out the current setting in the form of "model" files for future resuse.

The value of "config" is, in fact, "config.xml".

Finally the target generate-server means

"Create required templates based on the existing wsdl file called in config.xml"

These templates would be outputin
"${samplesbuild}/${appname}/classes/server"
in the case of the sample
C:\Sun\jwsdp-1.5\jaxrpc\build\samples\HelloWorld\classes\server.

Then, target compile-server. Here is the important part extracted:

<javac srcdir="${samples.home}/${appname}/src/server"
destdir="${samplesbuild}/${appname}/classes/server"/>

Note that the property ${samples.home}, different from ${samplesbuild} found more frequently.
${samples.home} means the location of HelloIF or HelloImpl, created manually by users.

In the case of this sample,
C:\Sun\jwsdp-1.5\jaxrpc\samples\HelloWorld

Finally the target compile-server means

Add the classes made manually by users in the same location of the templates created automatically.

...as far as I can suppose.

Target create-warmeans to bundle the classes above, wsdl file, Web-related files like web.xml, jaxrpc-ri.xml etc. to a war file, a "raw" war file still not for deploy.

To modify the "raw" war file by create-war to deployable war file, use target build-war, where the task wsdeploy would be run:

<wsdeploy

inWarFile="${samplesbuild}/${appname}/jaxrpc-${appname}-raw.war"
outWarFile="${samplesbuild}/${appname}/jaxrpc-${appname}.war"

>

</wsdeploy>

The above is an important part of wsdeploy. The required attributes are the name of the "raw" file, simply including the configuration files for Web service(inWarFile), and the name of the deployable war file to be produced through wsdeploy using the "raw" war.

deploy-war is an actual copying of this deployable war to webapp folder of JWSDP-Tomcat.

I could conclude that these procedure described in sample build.xml is

Top-down method reading existing WSDL file to create service classes.

...I had never dreamed of it while enjoying the sample...

Bottoming-up Web Service!

That's a prolem. Existing WSDL...I don't know how to make it exist. That is, I don't know how to write it!

I must find buttom-up method , asking JWSDP to make everything including WSDL, from simple Java Classes that I could prepare.

I looked hard into the Sun Document ( or do it from the beginning, Noniko...) and got to know wscompile tool works in three ways.

  1. Read existing WSDL
  2. Read the name of interface and its implement preapared by a user
  3. Reuse the model file generated by previous execution of this tool itself

And the detail should be written by config.xml.

So, in build.xml file, wscompile should not have import="true"option. On the other hand, it needs server="true" option for creating server-side files.

<wscompile
keep="true"
server="true"
...........

config.xml should be changed as this:

<service name="MyHelloService"
targetNamespace="http://myhello.noniko.com/wsdl"
typeNamespace="http://myhello.noniko.com/types"
packageName="myhello">
<interface name="myhello.MyHelloIF"
servantName="myhello.MyHelloImpl"/>
</service>

<wsdl>tag was erased and <interface>tag was added with the required setting.

OK, Run the target "deploy-war"!

Cannot find myhello.MyHelloIF

Whaaaaa?


Changing dependencies among the targets

Look hardar into it, Noniko!...Umm, it says like "Cannot find myhello.MyHelloIF called by config.xml referenced by wscompile...

Cannot find the path? But base directory of wscompile is set to where MyHelloIF.class file to be created. Can't it find the product of its base directory? Or there are no products there?

Let's see this base directory, actually wsdptwo/build/classes/server folder.

No class files.

Ha ha! you're right, you can't find what does not exist! But, why no files?

Ohhh, there can't be!

Now compile-server, the target to compile HelloIF.java and HelloImpl.java, depends on generate-server. It can't call the product of the target it depends....I say, it is wrong that generate-server depends compile-server, in buttom-up method.

Can I change these dependencies?

First, compile-server, to compile MyHelloIF.java and MyHelloImpl.java which I created myself.

<target name="compile-server" depends="prepare">
<javac srcdir="${proj.home}/src/server"
destdir="${samplesbuild}/classes/server"
......

${proj.home}is the location of my project, set in build.properties file.

Second, generate-server, to create WSDL and required class files as described in config.xml.

<target name="generate-server" depends="compile-server">
......
<wscompile
keep="true"
server="true"
........

Now, "deploy-waaaar!"....At last, it worked!


My setting of classpath

In addition, I must change some setting of classpath to executing my sample, because my working directory is away from JWSDP's home.

build.properties copied from the sample set paths based on the location of itself.

buildhome=../../build
build.dir=${buildhome}
jwsdphome=${buildhome}/../..

In my case, absolute path for jwsdphome must be used.

jwsdphome=/Sun/jwsdp-1.5

Other settings customized are:

nbworks.home=/nonidata/nb4rcworks
proj.home=${nbworks.home}/wsdptwo

buildhome=${proj.home}/build
build.dir=${buildhome}
samplesbuild=${buildhome}

Note that in this build.xml prepared by JWSDP, required classpaths are listed:

<path id="compile.classpath">

<pathelement location="${javamail.jar}"/>
<pathelement location="${jaf.jar}"/>
<pathelement location="${jaxp-api.jar}"/>
.....
</path>

Then we can use

<classpath refid="compile.classpath"/>

when explicit setting of classpath is needeed.

My build.xml needed to add

<pathelement path="${samplesbuild}/classes/server"/>

to the list ov classpaths above, probably because of these changes of targets.


At last reached here, but....

But you can't miss the NetBeans.ORG document on JAX-RPC in NB4!

http://www.netbeans.org/kb/articles/tutorial-webservice-40.html

The method described In this document is to create NB4's standard Web Application and then the files required or JAX-RPC Web service.

But note that these required are only three: interface, its implement, and jaxrpc-rmi.xml. In my case there would be

MyHelloIF
MyHelloImpl
jaxrpc-ri.xml

Then add only one target similar to build-war, which uses wsdeploy task, in NB4's build.xml file.

Unbelievablly Simple.

No, not so unbelievable...my doubt in my method above had been that I had to describe very similar setting in both config.xml and jaxrpc-ri.xml. Which made me feel doubled configuration...

What is the difference?

RTFM(Read the Fundamental Manual), Noniko...

"Behind the scenes, wsdeploy runs wscompile with the -gen:server option. The wscompile command generates classes and a WSDL file that wsdeploy includes in the generated WAR file."

No feel, defenitely doubled

"On JWSDP, the wsdeploy tool must be run. However, on J2EE you don't have to run wsdeploy ....when you deploy a WAR with deploytool or asadmin."

So wscompile is enough when you use deploytool or asadmin?

Now my question is for whom, for what assumption for usage, this build.xml sample of JWSDP is prepared?

......

Ah....good. Anyway I got some knowledge on wscompile and wsdeployn through this struggle.


Follow the NB.ORG document

So let's follow the NB Document above. The difference of my method is using JWSDP Tomcat , while the doc uses bundled Tomcat. It's better to try on a bit different condition to increase information for using NB, isn't it?

Please read NB Document above for shared topics. Here I will write only the differences.

I created NB's standard Web Application named wsdpthree.
Then a new property file named webservice.properties in nbproject folder to set the properties as below:

nbworks.home=/nonidata/nb4rcworks
proj.name=wsdpthree
proj.home=${nbworks.home}/${proj.name}
proj.web=${proj.home}/web
proj.src=${proj.home}/src
proj.build=${proj.home}/build
proj.build.web=${proj.build}/web

tomcat.root=/tomcat50-jwsdp
catalina.home=${tomcat.root}

jwsdphome=/Sun/jwsdp-1.5
jwsdpshared=${jwsdphome}/jwsdp-shared

jaxrpchome=${jwsdphome}/jaxrpc
saajhome=${jwsdphome}/saaj
javamail.jar=${jwsdpshared}/lib/mail.jar
jaf.jar=${jwsdpshared}/lib/activation.jar
jaxrpc-api.jar=${jaxrpchome}/lib/jaxrpc-api.jar
jaxrpc-impl.jar=${jaxrpchome}/lib/jaxrpc-impl.jar
jaxrpc-spi.jar=${jaxrpchome}/lib/jaxrpc-spi.jar
saaj-api.jar=${saajhome}/lib/saaj-api.jar
saaj-impl.jar=${saajhome}/lib/saaj-impl.jar
jax-qname.jar=${jwsdpshared}/lib/jax-qname.jar
ant.jar=${jwsdphome}/apache-ant/lib/ant.jar

One thing about property. Everytime when you build NB's Web project, a war file named "project name".war is created or updated. It's better to change this war name because it's not the war ready for deployment.

Open project.properties file and edit to get this description( near the end of file)

war.name=wsdpthree-nb.war

So if you simply "Build" this web project, wsdpthree-nb.war would be created or updated.

Add to NB4's build.xml descriptions below:

(1)For making use of "webservice.properties",

<property file="nbproject/webservice.properties"/>

(2)Then classpaths, only required ones:

<path id="compile.classpath">
<pathelement location="${javamail.jar}"/>
<pathelement location="${jaf.jar}"/>
<pathelement location="${jaxrpc-api.jar}"/>
<pathelement location="${jaxrpc-spi.jar}"/>
<pathelement location="${jaxrpc-impl.jar}"/>
<pathelement location="${saaj-api.jar}"/>
<pathelement location="${saaj-impl.jar}"/>
<pathelement location="${jax-qname.jar}"/>
<!--pathelement location="${ant.jar}"/-->
</path>

(3)The place to put temporary folder:

<target name="init-create-server" description="craete folders for tasks">
<mkdir dir="build/temp"/>
</target>

(4)Set classpath both in taskdef and wsdeploy.This saves you from "Option"->"Build"->"Ant Setting".

<target name="create-server" description="Create Service-Side Artefacts" depends="init-create-server">

<taskdef name="wsdeploy" classname="com.sun.xml.rpc.tools.ant.Wsdeploy">
<classpath refid="compile.classpath"/>
</taskdef>

<wsdeploy
outWarFile="dist/${proj.name}.war"
inWarFile="dist/${proj.name}-nb.war"
keep="true"
verbose="true"
tmpdir="build/temp">
<classpath refid="compile.classpath"/>
</wsdeploy>

</target>

(5) copy the deployable war file to JWSP-Tomcat.

<target name="deploy-war" description="Deploy war to JWSDP tomcat" depends="create-server">

<copy file="${proj.home}/dist/${proj.name}.war" todir="${tomcat.root}/webapps"/>
</target>

Main difference in description of jaxrpc-ri.xml is:

<webServices
.........
urlPatternBase="/wsdpthree">

...........

<endpointMapping
endpointName="YourHello"
urlPattern="/yourhello"/>

</webServices>

Ok, run "deploy-war" in this NB's buildfile. At last, stopping and restarting JWSDP-Tomcat, you can access

http://localhost:8080/wsdpthree/yourhello

for this Web service's information!


The end of .war war

Or I forced this to the end. Ummm....what can I say...Although there are still uncleared points, all I can say is "I did try, it's better than nothing"...OK, let's use NB4.1 for Web Service from now on!

See my revenge against .war war...Improved version