Java Reference
In-Depth Information
/**
* Used to manually run the wsgen tool against.
*/
@WebService(targetNamespace="http://ns.soacookbook.com",
name="GenCatalog", serviceName="GenCatalog")
public class CatalogToGen {
@WebMethod
@WebResult(name="title")
public String getTitle(
@WebParam(name="id") String id) {
return "King Lear";
}
}
Given this source file, you'll compile it like this from the directory that stores the top-level
package:
javac com/soacookbook/CatalogToGen.java
Now you can run the
wsgen
tool across this class to generate a WSDL, schema, and appropri-
ate JAX-WS artifacts:
$ wsgen -verbose -cp . -wsdl -servicename {http://ns.com/}Catalog \
-keep -r gen -s gen com.soacookbook.CatalogToGen
Note: ap round: 1
[ProcessedMethods Class: com.soacookbook.CatalogToGen]
[should process method: getTitle hasWebMethods: true ]
[endpointReferencesInterface: false]
[declaring class has WebSevice: true]
[returning: true]
[WrapperGen - method: getTitle(java.lang.String)]
[method.getDeclaringType(): com.soacookbook.CatalogToGen]
[requestWrapper: com.soacookbook.jaxws.GetTitle]
[ProcessedMethods Class: java.lang.Object]
com\soacookbook\jaxws\GetTitle.java
com\soacookbook\jaxws\GetTitleResponse.java
Note: ap round: 2
You see the output as a result of running the command with the
-verbose
option. Because you
used the
-keep
option, your generated Java source files are not deleted after compilation. The
tool makes two classes,
GetTitle
for request messages and
GetTitleResponse
for response
messages, and places them in the package name you used, appended with
jaxws
. The classes
are put in the directory named gen, as specified with the
-s
option.