2-8 Getting Started With JAX-WS Web Services for Oracle WebLogic Server
prompt ant deploy
14.
Test that the Web service is deployed correctly by invoking its WSDL in your browser:
http:host:portcomplexComplexService?WSDL To run the Web service, you need to create a client that invokes it. See
Section 2.4, Invoking a Web Service from a Java SE Application
for an example of creating a Java client application that invokes a Web service.
2.2.1 Sample BasicStruct JavaBean
package examples.webservices.complex; Defines a simple JavaBean called BasicStruct that has integer, String,
and String[] properties public class BasicStruct {
Properties private int intValue;
private String stringValue; private String[] stringArray;
Getter and setter methods public int getIntValue {
return intValue; }
public void setIntValueint intValue { this.intValue = intValue;
} public String getStringValue {
return stringValue; }
public void setStringValueString stringValue { this.stringValue = stringValue;
} public String[] getStringArray {
return stringArray; }
public void setStringArrayString[] stringArray { this.stringArray = stringArray;
} public String toString {
return IntValue=+intValue+, StringValue=+stringValue; }
}
2.2.2 Sample ComplexImpl.java JWS File
package examples.webservices.complex; Import the standard JWS annotation interfaces
import javax.jws.WebMethod; import javax.jws.WebParam;
import javax.jws.WebResult; import javax.jws.WebService;
import javax.jws.soap.SOAPBinding; Import the BasicStruct JavaBean
import examples.webservices.complex.BasicStruct; Standard JWS annotation that specifies that the portType name of the Web
Use Cases and Examples 2-9
Service is ComplexPortType, its public service name is ComplexService, and the targetNamespace used in the generated WSDL is http:example.org
WebServiceserviceName=ComplexService, name=ComplexPortType, targetNamespace=http:example.org
Standard JWS annotation that specifies this is a document-literal-wrapped Web Service
SOAPBindingstyle=SOAPBinding.Style.DOCUMENT, use=SOAPBinding.Use.LITERAL,
parameterStyle=SOAPBinding.ParameterStyle.WRAPPED 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-10 Getting Started With JAX-WS Web Services for Oracle WebLogic Server
2.2.3 Sample Ant Build File for ComplexImpl.java JWS File