9-14 Programming Advanced Features of JAX-WS Web Services for Oracle WebLogic Server
private WsatBankTransferService getWebServiceURL wsdlURL { TransactionalFeature feature = new TransactionalFeature;
feature.setFlowTypeTransactionFlowType.MANDATORY; feature.setVersionVersion.WSAT10;
WsatBankTransferService_Service service = new WsatBankTransferService_ServicewsdlURL, new QNamehttp:tempuri.org, WsatBankTransferService;
return service.getWSHttpBindingIServicenew javax.xml.ws.soap.AddressingFeature,
feature; }
public String createAccountString acctNo, String amount throws java.lang.Exception{ Context ctx = null;
UserTransaction tx = null; try {
ctx = new InitialContext; tx = UserTransactionctx.lookupjavax.transaction.UserTransaction;
try { DataSource dataSource = DataSourcectx.lookupexamples-dataSource-demoXAPool;
String sql = insert into wsat_acct_local acctno, amount values + acctNo + , + amount + ;
int insCount = dataSource.getConnection.prepareStatementsql.executeUpdate; if insCount = 1
throw new java.lang.Exceptioninsert fail at local.; return :acctno= + acctNo + amount= + amount + creating.. ;
} catch SQLException e { System.out.println Exception caught ;
e.printStackTrace; throw new SQLExceptionSQL Exception during createAccount at local.;
} } catch java.lang.Exception e {
System.out.println Exception caught ; e.printStackTrace;
throw new java.lang.Exceptione; }
} public String deleteAccountString acctNo throws java.lang.Exception{
. . . }
public String transferMoneyString acctNo, String amount, String direction throws java.lang.Exception{
. . . }
public String listAccount throws java.lang.Exception{ . . .
} }
9.5 Configuring Web Services Atomic Transactions Using the Administration Console
The following sections describe how to configure Web services atomic transactions using the Administration Console.
■
Section 9.5.1, Securing Messages Exchanged Between the Coordinator and Participant
■
Section 9.5.2, Enabling and Configuring Web Services Atomic Transactions
Using Web Services Atomic Transactions 9-15
9.5.1 Securing Messages Exchanged Between the Coordinator and Participant
Using transport-level security, you can secure messages exchanged between the Web services atomic transaction coordinator and participant by configuring the properties
defined in the following table using the WebLogic Server Administration Console. These properties are configured at the domain level. For detailed steps, see Configure
Web services atomic transactions in the Oracle WebLogic Server Administration Console Help.
9.5.2 Enabling and Configuring Web Services Atomic Transactions
To enable Web services atomic transactions and configure the version and flow type, you can customize the configuration at the endpoint or method level for the Web
service or client. For detailed steps, see Configure Web services atomic transactions in the Oracle WebLogic Server Administration Console Help.
9.6 Using Web Services Atomic Transactions in a Clustered Environment
For considerations when using atomic transaction-enabled Web services in a clustered environment, see
Chapter 8, Managing Web Services in a Cluster .
9.7 More Examples of Using Web Services Atomic Transactions
Refer to the following sections for additional examples of using Web services atomic transactions:
■
For an example of how to sign and encrypt message headers exchanged during the Web services atomic transaction, see Securing Web Services Atomic Transactions
in Securing WebLogic Web Services for Oracle WebLogic Server.
Table 9–5 Securing Web Services Atomic Transactions
Property Description
Web Services Transactions Transport Security Mode Specifies whether two-way SSL is used for the message
exchange between the coordinator and participant. This property can be set to one of the following values:
■
SSL Not Required—All Web service transaction protocol messages are exchanged over the HTTP
channel.
■
SSL Required—All Web service transaction protocol messages are exchanged over the HTTPS channel. This
flag must be enabled when invoking Microsoft .NET Web services that have atomic transactions enabled.
■
Client Certificate Required—All Web service transaction protocol messages are exchanged over
HTTPS and a client certificate is required. For more information, see Configure two-way SSL in the
Oracle WebLogic Server Administration Console Help. Web Service Transactions Issued Token Enabled
Flag the specifies whether to use an issued token to enable authentication between the coordinator and participant.
The IssuedToken is issued by the coordinator and consists of a security context token SCT and a session key used for
signing. The participant sends the signature, signed using the shared session key, in its registration message. The
coordinator authenticates the participant by verifying the signature using the session key.
9-16 Programming Advanced Features of JAX-WS Web Services for Oracle WebLogic Server
■
A detailed example of Web services atomic transactions is provided as part of the WebLogic Server sample application. For more information about running the
sample application and accessing the example, see Sample Application and Code Examples in Information Roadmap for Oracle WebLogic Server .
Note: You can secure applications that enable Web service atomic
transactions using only WebLogic Web service security policies. You cannot secure them using Oracle Web Services Manager WSM
policies.
10
Publishing a Web Service Endpoint 10-1
10
Publishing a Web Service Endpoint
The javax.xml.ws.Endpoint API see http:download.oracle.comjavaee5apijavaxxmlwsEndpoint.ht
ml enables you to create a Web service endpoint at runtime without deploying the Web
service to a WebLogic Server instance. The following table summarizes the steps to publish a Web service endpoint.
Table 10–1 Steps to Publish a Web Service Endpoint
Step Description
1 Create a Web service endpoint.
Use the javax.xml.ws.Endpoint create method to create the endpoint, specify the
implementor that is, the Web service implementation to which the endpoint is associated, and optionally
specify the binding type. If not specified, the binding type defaults to SOAP1.1HTTP. The endpoint is
associated with only one implementation object and one javax.xml.ws.Binding, as defined at
runtime; these values cannot be changed.
For example, the following example creates a Web service endpoint for the CallbackWS
implementation. Endpoint callbackImpl = Endpoint.createnew
CallbackWS; 2
Publish the Web service endpoint to accept incoming requests.
Use the javax.xml.ws.Endpoint publish method to specify the server context, or the address
and optionally the implementor of the Web service endpoint.
Note:
If you wish to update the metadata documents WSDL or XML schema associated with the
endpoint, you must do so before publishing the endpoint.
For example, the following example publishes the Web service endpoint created in Step 1 using the
server context. Object sc
context.getMessageContext.getMessageContex t.SERVLET_CONTEXT;
callbackImpl.publishsc;
10-2 Programming Advanced Features of JAX-WS Web Services for Oracle WebLogic Server
For an example of publishing a Web service endpoint within the context of a callback example, see
Section 11.5, Programming Guidelines for the Callback Client Web Service
. In addition to the steps described in the previous table, you can defined the following
using the javax.xml.ws.Endpoint API methods:
■
Endpoint metadata documents WSDL or XML schema associated with the endpoint. You must define metadata before publishing the Web service endpoint.
■
Endpoint properties.
■
java.util.concurrent.Executor that will be used to dispatch incoming requests to the application see
http:download.oracle.comjavase1.5.0docsapijavautilco ncurrentExecutor.html
. For more information, see the javax.xml.ws.Endpoint Javadoc at
http:download.oracle.comjavaee5apijavaxxmlwsEndpoint.ht ml
. 3
Stop the Web service endpoint to shut it down and prevent
additional requests after processing is complete.
Use the javax.xml.ws.Endpoint stop method to shut down the endpoint and stop
accepting incoming requests. Once stopped, an endpoint cannot be republished.
For example: callbackImpl.stop
Table 10–1 Cont. Steps to Publish a Web Service Endpoint
Step Description
11
Using Callbacks 11-1
11
Using Callbacks
The following sections describe how to use callbacks to notify clients of events:
■
Section 11.1, Overview of Callbacks