Use Cases and Examples 2-9
WebLogic-specific JWS annotation that specifies the context path and service URI used to build the URI of the Web Service is complexComplexService
WLHttpTransportcontextPath=complex, serviceUri=ComplexService, portName=ComplexServicePort
This JWS file forms the basis of a WebLogic Web Service. The Web Services has two public operations:
- echoIntint - echoComplexTypeBasicStruct
The Web Service is defined as a document-literal service, which means that the SOAP messages have a single part referencing an XML Schema element
that defines the entire body. public class ComplexImpl {
Standard JWS annotation that specifies that the method should be exposed as a public operation. Because the annotation does not include the
member-value operationName, the public name of the operation is the same as the method name: echoInt.
The WebResult annotation specifies that the name of the result of the operation in the generated WSDL is IntegerOutput, rather than the
default name return. The WebParam annotation specifies that the input parameter name in the WSDL file is IntegerInput rather than the Java
name of the parameter, input. WebMethod
WebResultname=IntegerOutput, targetNamespace=http:example.orgcomplex
public int echoInt WebParamname=IntegerInput,
targetNamespace=http:example.orgcomplex int input
{ System.out.printlnechoInt + input + to you too;
return input; }
Standard JWS annotation to expose method echoStruct as a public operation called echoComplexType
The WebResult annotation specifies that the name of the result of the operation in the generated WSDL is EchoStructReturnMessage,
rather than the default name return. WebMethodoperationName=echoComplexType
WebResultname=EchoStructReturnMessage, targetNamespace=http:example.orgcomplex
public BasicStruct echoStructBasicStruct struct {
System.out.printlnechoComplexType called; return struct;
} }
2.2.3 Sample Ant Build File for ComplexImpl.java JWS File
The following build.xml file uses properties to simplify the file. project name=webservices-complex default=all
-- set global properties for this build -- property name=wls.username value=weblogic
2-10 Getting Started With JAX-RPC Web Services for Oracle WebLogic Server
property name=wls.password value=weblogic property name=wls.hostname value=localhost
property name=wls.port value=7001 property name=wls.server.name value=myserver
property name=ear.deployed.name value=complexServiceEAR property name=example-output value=output
property name=ear-dir value={example-output}complexServiceEar property name=clientclass-dir value={example-output}clientclass
path id=client.class.path pathelement path={clientclass-dir}
pathelement path={java.class.path} path
taskdef name=jwsc classname=weblogic.wsee.tools.anttasks.JwscTask
taskdef name=clientgen classname=weblogic.wsee.tools.anttasks.ClientGenTask
taskdef name=wldeploy classname=weblogic.ant.taskdefs.management.WLDeploy
target name=all depends=clean,build-service,deploy,client target name=clean depends=undeploy
delete dir={example-output} target
target name=build-service jwsc
srcdir=src destdir={ear-dir}
keepGenerated=true jws file=exampleswebservicescomplexComplexImpl.java
type=JAXRPC WLHttpTransport
contextPath=complex serviceUri=ComplexService portName=ComplexServicePort
jws jwsc
target target name=deploy
wldeploy action=deploy name={ear.deployed.name}
source={ear-dir} user={wls.username} password={wls.password} verbose=true
adminurl=t3:{wls.hostname}:{wls.port} targets={wls.server.name}
target target name=undeploy
wldeploy action=undeploy failonerror=false name={ear.deployed.name}
user={wls.username} password={wls.password} verbose=true adminurl=t3:{wls.hostname}:{wls.port}
targets={wls.server.name} target
target name=client clientgen
wsdl=http:{wls.hostname}:{wls.port}complexComplexService?WSDL destDir={clientclass-dir}
packageName=examples.webservices.complex.client type=JAXRPC
javac srcdir={clientclass-dir} destdir={clientclass-dir}
includes=.java
Use Cases and Examples 2-11
javac srcdir=src destdir={clientclass-dir}
includes=exampleswebservicescomplexclient.java target
target name=run java fork=true
classname=examples.webservices.complex.client.Main failonerror=true
classpath refid=client.class.path arg line=http:{wls.hostname}:{wls.port}complexComplexService
java target
project
2.3 Creating a Web Service from a WSDL File