Java Reference
In-Depth Information
NOTE
This file is a standard service implementation for deployment in a WAR. It could be an EJB without
many changes, but then you'd have to do more packaging work in the build script and put it in an
EAR.
Let's examine the file in some detail.
Notice that you're importing the com.soacookbook.ns.credit package in order to use the
parameter and the return type. That's the package you know JAXB will generate the types to,
but they don't exist until we run the build.
When you first create the class, the web service operation accepts types that are based on
schema, and which don't exist until you generate them with JAXB. You then have to make
sure they're on the classpath at service compile time, and then include them with the WAR.
Your build will handle that for you, as we'll see later.
The service implementation uses the @WebService annotation and specifies a few properties:
▪ The @WebService.name value matches the value of the wsdl:portType name. Here this
is CreditAuthorizer .
▪ The @WebService.serviceName value matches the value specified in the WSDL's service
name as <service name="CreditService"> .
▪ The @WebService.targetNamespace property is used to indicate the namespace. While
the namespace is the same here for the schema types, that is for convenience, and there is
no restriction there. In general, it is a best practice to separate your type namespaces and
your WSDL namespace.
▪ Finally, specify the wsdlLocation , which must be physically present in the WAR with
the service implementation. Because you're specifying the WSDL by hand and including
it along with a schema you have written, the Glassfish deployment tool will honor the
schema so that it still contains your type constraints.
Take a look at the code listing in Example 7-3 and we'll unpack the business method annota-
tions.
Example7-3.CreditService.java
package com.soacookbook.ch03.validate;
import com.soacookbook.ns.credit.*;
import javax.jws.WebMethod;
Search WWH ::




Custom Search