6-12 Getting Started With JAX-WS Web Services for Oracle WebLogic Server
WebServiceRef ComplexService service;
Alternatively, you can create a proxy stub to the ComplexService Web service, as shown below:
ComplexService test = new ComplexService;
■
Return an instance of the ComplexPortType stub implementation by calling the getComplexPortTypePort
operation on the Web service reference: ComplexPortType port = service.getComplexPortTypePort;
■
Invoke the echoComplexType operation of ComplexService using the port you just instantiated:
BasicStruct result = port.echoComplexTypeinput;
6.4 Configuring Web Service Clients
By default, Web service clients use the Web service configuration defined for the server. You can override the configuration settings used by the Web service client
using one of the following methods:
■
Using the Administration or WLST, if applicable. Only a subset of Web service features are configurable on the client.
■
Using the WebServiceRef annotation to associate the Web service client with the configuration defined for the specified Web service reference. The Web service
reference configuration is defined in the weblogic.xml for Web containers and weblogic-ejb-jar.xml
for EJB containers. For more information about the WebServiceRef
annotation, see Section 6.5, Defining a Web Service Reference
Using the WebServiceRef Annotation.
■
Using the WsrmClientInitFeature when creating a Web services reliable messaging client. For more information, see Configuring Reliable Messaging on
the Web Service Client in Programming Advanced Features of JAX-WS Web Services for Oracle WebLogic Server.
6.5 Defining a Web Service Reference Using the WebServiceRef Annotation
The WebServiceRef annotation enables you to define a reference to a Web service and attach the configuration of the Web service to the client instance.
For example, in the following code excerpt, WebServiceRef is used to attach the configuration for MyReliableEchoService to the client’s Web service instance. The
port that is subsequently created and initialized uses the properties defined for MyReliableEchoService
service reference in the weblogic.xml for the Web application.
package wsrm_jaxws.example; import java.xml.ws.WebService;
import java.xml.ws.WebServiceRef;
import wsrm_jaxws.example.client_service.; import wsrm_jaxws.example.client_service.EchoResponse;
... WebService
public class ClientServiceImpl {
Invoking Web Services 6-13
WebServiceRefname=MyServiceRef private ReliableEchoService service;
private ReliableEchoPortType port = null;
PostConstruct public void initPort {
port = service.getReliableEchoPort; ...
} }
Example 6–1 shows an example of a weblogic.xml file that contains a Web service
reference description. For information about the reliable messaging properties shown in this example, see Configuring Reliable Messaging in Programming Advanced
Features of JAX-WS Web Services for Oracle WebLogic Server.
Example 6–1 Example weblogic.xml File Containing Web Service Reference Description
?xml version=1.0 encoding=UTF-8? weblogic-web-app xmlns=http:xmlns.oracle.comweblogicweblogic-web-app
service-reference-description -- Any name you want, but use this same name on
WebServiceRefname=my name. This anno goes on the service field in your client container --
service-ref-nameMyServiceRefservice-ref-name -- Use and any path within the web app to get a local WSDL, or
use a resource name as defined by the Java ClassLoader, or use an absoluteexternal URL you can guarantee is deployed when this web
app deploys -- wsdl-urlWEB-INFwsdlsReliableEcho.wsdlwsdl-url
-- One or more port-infos, one for each type of portstub youll create in your JWS --
port-info -- The local name of wsdl:port not portType. The Java type for this
port, when created from the WebServiceRef JWS field, will contain, in RequestContext, the props you define below --
port-nameReliableEchoPortport-name -- Any prop namevalue pairs you want to show up on you service stub
The Java type for this port, when created from the WebServiceRef JWS field, will contain, in RequestContext, the stub-props you define below --
-- RM Source Properties -- stub-property
nameweblogic.wsee.wsrm.BaseRetransmissionIntervalname valuePT30Svalue
stub-property stub-property
nameweblogic.wsee.wsrm.RetransmissionExponentialBackoffname valuetruevalue
stub-property -- RM Destination Properties --
stub-property nameweblogic.wsee.wsrm.RetryCountname
value5value
6-14 Getting Started With JAX-WS Web Services for Oracle WebLogic Server
stub-property stub-property
nameweblogic.wsee.wsrm.RetryDelayname valuePT30Svalue
stub-property stub-property
nameweblogic.wsee.wsrm.AcknowledgementIntervalname valuePT5Svalue
stub-property stub-property
nameweblogic.wsee.wsrm.NonBufferedDestinationname valuetruevalue
stub-property -- RM Source or Destination Properties --
stub-property nameweblogic.wsee.wsrm.InactivityTimeoutname
valuePT5Mvalue stub-property
stub-property nameweblogic.wsee.wsrm.SequenceExpirationname
valuePT10Mvalue stub-property
port-info service-reference-description
wl-dispatch-policyweblogic.wsee.mdb.DispatchPolicywl-dispatch-policy weblogic-web-app
6.6 Managing Client Identity