You are on page 1of 59

Oracle WebLogic Server Web

WebLogic Web
Oracle WebLogic Server 10.3.4 Web
WebLogic Server

Java Web
WSDL Web
Web
MTOM SOAP
JAX-WS
Web
SAML
Web
Web
Web
WLS Web Service
WebLogic Web Web Services for Java EE 1.2
(http://www.jcp.org/en/jsr/detail?id=109) Java Web
Java EE Java EE Web
WebLogic Web
JDK 5.0
http://java.sun.com/developer/technicalArticles/releases/j2se15/
Java Ant Java
Java Web Service (JWS) Web
Web Java JWS Web
Java JWS JWS Web Services
Metadata for the Java Platform (http://www.jcp.org/en/jsr/detail?id=181)
Hands-on Lab:Web Services development and
WebLogic
deployment with Oracle WebLogic Server 11g
Web
Oracle IDE Web

Oracle Jdeveloper Oracle Java IDE Web


Java EJB Web
Oracle WebLogic Server Web
WSDL Web Jdeveloper
JDeveloper Ant Ant

Oracle Enterprise Pack for Eclipse (OEPE) Eclipse IDE


WebLogic Web OEPE WebLogic Web

Java WSDL Web


WSDL
1 Web
<LabHome>
<LabHome>\resources
<LabWorkspace>

MiddlewareHome
WebLogicHome
LabDomain
OEPEHome
LabHome
LabWorkspace

/labs/wls1034
<MiddlewareHome>/wlserver_10.3
<WebLogicHome>/domains/wlsWebServiceLab
<MiddlewareHome>/oepe_11gR1PS3/eclipse
/home/oracle/labs/WS_labs
<LabHome>/WLS_OEPE_WS

HelloWS
HelloWS_solution

com.library.ws

Web

o
o
o
o
o
o

billiards
slick
tfoolery
clist
wtell
itel

o
o
o
o
o

A brief history of time


A briefer history of time
The Stand
Twilight
Harry Potter and the Chamber of Secrets

OEPE Eclipse

<LabDomain> WLS

JAX-WS Web

OEPE WebLogic Server


1.1

<LabDomain> WebLogic Server

1.2

1.3

Ctrl + c

OEPE Eclipse
1.4

Eclipse

1.5

<LabWorkspace>

1.12

Package Explorer Project Explorer New > Project

1.13

New Project WebLogic Web Services Web Service


Project NextWebLogic Web WebLogic Web
facet Web

1.14

New Web Services Project 1 Target


Runtime Configuration 11g R1 PS3 New Runtime

1.15

New Server Runtime Environment select Oracle WebLogic


Server 11gR1PS3 Next

1.16

1 <WebLogicHome> Browse WebLogic Home


JDK Finish

1.17

Finish Web
Open Associated Perspective Yes

OEPE WebLogic Server


1.18

Server

1.19

Overview <LabDomain>

1.20

Server Start

1.21

Console
<Aug 18, 2010 9:25:28 AM PDT> <Notice> <WebLogicServer> <BEA-000360>
<Server started in RUNNING mode>

1.22

Server
[Started, Synchronized]

1.23

Server Stop

Java
1.24

Project Explorer src

1.25

src New > Package


1 Finish

1.26

New > WLS Web Service


(com.library.ws) (HelloWS) Finish

1.27

hello
public String sayHello(String s) {
String result = hello;
if ( s == null || s.isEmpty()) {
return result + unknown!;
}
return result + + s;
}

1.28

package com.library.ws;
import javax.jws.*;
@WebService
public class HelloWS {
@WebMethod

public String sayHello( String s) {


String result = hello;
if (s == null || s.isEmpty()) {
return result + unknown;
}
return result + + s;
}
}
PDF /

1.29
(

Web
1.30

HelloWS.java Run
As > Run on Server

1.31

Run on Server Finish


WebLogic Test Client

1.32

string arg0 sayHello

1.33

Web

1.34

Server Stop

1.35

Project Explorer HelloWS Close Project

2 Java JAX-WS Web


WebLogic ServerJAX-WS 2.0 OEPE Eclipse
Web Web
WebLogic Server Web

Web

Eclipse WebLogic Server

Eclipse Web

2 2 Web

BottomUP

BottomUp_solution

com.library.ws

OEPE Eclipse

Java

Web

OEPE Eclipse
2.1

Eclipse

2.2

<LabWorkspace>
Use this as the default checkbox OK

java
2.3

Package Explorer BottomUp

2.4

WebContent>WEB-INF>lib

2.5
2.6
2.7
2.8

lib support.jar jar


Import support.jar <LabHome>/resources

BQResult setter
2.9

BQResult.java

2.10

BQResult( String_)
public BQResult() {
init();
}

2.11

setter Eclipse java setter

2.12

Select Setters OK

setter
public void setBook(Book book) {
this.book = book; }
public void setUserName(String userName) {this.userName =
userName; }
public void setUId(int id) { this.uId = id; }
public void setError(String error) {
this.error =
error; }
2.13

Web Book Query


2.14

BookQuery.java
OEPE Eclipse

Control +
2.15

WebService

@WebService (serviceName ="BookQueryService",


targetNamespace="http://www.library.com/" )

@WebService WebLogic Web Service Annotation

2.16

getBookDetails
@WebMethod
@WebMethod (operationName = "BookQuery")

2.17

WebResult
@WebResult(name = "BookResult")

2.18

WebParam
public BQResult getBookDetails (
@WebParam(name="UserName")String uName,
@WebParam(name="Title")String title,
@WebParam(name="Isbn")String ISBN)

POJO Web
2.19

Project Explorer BookQuery.java Run As >


Run on Server

2.20

Run on Server Finish


WebLogic Test Client

2.21

BookQuery

2.22

3 WSDL JAX-WS Web


Oracle Enterprise Pack for Eclipse (OEPE) WSDL
Web JAX-WS 2.x
WSDL Web
Web
OEPE JAX-WS 2.x Java Web

WSDL Web

WSDL Web
Web
Web
3 3 Web

TopDown

TopDown_solution

com.library.ws

OEPE Eclipse

WSDL Web

Web

Web

OEPE Eclipse
3.1

Eclipse

3.2

Server Oracle WebLogic Server Start


WLS

java
3.3

Package Explorer TopDown

3.4

WebContent>WEB-INF>lib

3.5
3.6
3.7

lib support.jar jar


Import support.jar <LabHome>/resources

WSDL Web
3.8

Project Explorer BottomUp\WSDL

3.9

libraryCheckoutService.wsdl WebLogic Web Services >


Generate Web Service

3.10

Java Finish

Web
3.11

java Java
Resources>lib>Web App Libraries jar
(libraryCheckoutService_wsdl.jar) WSDL JAX-WS

3.12

java
(libraryCheckoutService_libraryCheckoutPortImpl.java)

3.13

exists 0
[ctrl] + shift + O (

A. QuerySupport
B. exists id
C. -1

public int exists (String name) {


if ( name == null || name.length() == 0)
return -1;

QuerySupport qs = new QuerySupport();


Book b = qs.exists(name);
if ( b == null)
return -1;
return b.getId();
}
3.14

checkout 0

A. UserSupport
-1
B. ReservationSupport
id -2
C. id

public int checkout(int bookId, String username) {


if ( bookId < 1 || username == null || username.length() ==
0 ) {
return -1;
}
UserSupport us = new UserSupport();
User u = us.find(username);
if ( u == null) {
return -2;
}
ReservationSupport rs = new ReservationSupport();
int rId = rs.reserve(bookId, u.getId());
if (rId < 1)
return -2;
return rId;
}

Web
3.15

Project Explorer com.library.ws libraryCheckoutServer

3.16

Run As > Run on Server

3.17

Run On Server Oracle WebLogic Server Finish


WebLogic Test Client

3.18

exists brief
exists

3.19

id
1 ID

3.20

id
id

WSDL JAX-WS
Web

Web
Web



Web

4 4 Web

SynchClient

SynchClient_solution

com.library.ws.client, com.library.ws.servlet

WSDL

jar

JEE

JSE

WebLogic Server
4.1

WebLogic Server

POJO Web
4.2

Project Explorer BottomUp_solution BookQuery.java


Run As > Run on Server

4.3

Run on Server Finish


WebLogic Test Client

4.4

BookQuery

4.5

WSDL Web
4.6

Project Explorer SynchClient SynchClient\WSDL

4.7

BookQueryService.wsdl WebLogic Web Services >


Generate Web Service Client

4.8

Finish

4.9

BookQueryService.wsdl.jar Java Resources\Libraries\Web App


Libraries & WebContent\WEB-INF\lib)

JEE
4.10

src>com.library.ws.servlet>
BookQueryServiceClientServlet.java main

4.11

main
a) @WebServiceRef BookQueryService
b) BookQueryService BookQueryPort BookQuery
c) BookQuery briefwtell
d) printBookQuery BqResult

public class BookQueryServiceClientServlet extends HttpServlet


{

private static final long serialVersionUID = 1L;


private static final String CONTENT_TYPE = "text/html;
charset=windows-1252";
@WebServiceRef
private BookQueryService bqs;
/**
* @see HttpServlet#HttpServlet()
*/
public BookQueryServiceClientServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
BookQuery bqp = bqs.getBookQueryPort();
BqResult bqr = bqp.bookQuery("wtell","brief", null);
String responseMsg;
if ( bqr == null ) {
responseMsg = "Got null from bookQuery!";
} else {
responseMsg= printBookQuery(bqr);
}
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>WS_ClientServlet</title></head>");
out.println("<body>");
out.println("<p>response :" + responseMsg + ".</p>");
out.println("</body></html>");
out.close();
}
..
}

JEE
4.12

Project Navigation Panel Servlet Run As > Run On


Server

4.13

JSE
4.14

src>com.library.ws.client>
BookQueryServiceClientClient.java main

4.15

main
e) BookQueryService
f) BookQueryService BookQueryPort
BookQuery
g) BookQuery briefwtell
h) printBookQuery BqResult

public class BookQueryServiceClient {


public static void main(String[] args) {
BookQueryService bqs = new
BookQueryService(Thread.currentThread().getContextClassLoader().getRe
source("META-INF/wsdls/BookQueryService.wsdl"), new
QName("http://www.library.com/", "BookQueryService"));
BookQuery bqp = bqs.getBookQueryPort();
BqResult bqr = bqp.bookQuery("wtell","brief", null);
if ( bqr == null ) {
System.out.println("Got null from bookQuery!");
} else {
System.out.println("Got " + printBookQuery(bqr));
}
}

JSE
4.16

main Run As > Java Application

4.17

NoClassDefFoundError

4.18

main Run As > Run configurations

4.19

JRE Source Classpath

4.20

Bootstrap Entries WebLogic Systems Libraries Remove


OEPE WLS Web Service JSE
Apply Run Configurations

4.21

main Run As > Java Application

4.22

4.23

5 JAX-WS
Web
Web
Web

Web Web

Web @HandlerChain

5 5 Web

Handlers

Handlers_solution

com.library.ws

javax.xml.ws.handler.LogicalHandler<LogicalMessageContext>

handleMessage

Web XML

Web

Web

javax.xml.ws.handler.LogicalHandler<LogicalMessageContext>
5.1

Eclipse Handlers

5.2

Application Navigator com.library.ws New >

Class
5.3

HWLogicalHandler Java

5.4

. . .
public class HWLogicalHandler implements
LogicalHandler<LogicalMessageContext> {
public boolean handleMessage(LogicalMessageContext messageContext) {
}
public boolean handleFault(LogicalMessageContext messageContext) {
System.out.println("HWLogicalHandler.handleFault called. with
'"+messageContext+"'.\n");
return true;
}
public void close(MessageContext messageContext) {
System.out.println("HWLogicalHandler.close called. with
'"+messageContext+"'.\n");
}
. . .
}

control + shift + O ws.handler.MessageContext


5.5

Save This method must return a result of type Boolean

handleMessage
5.6

handleMessage printTime

printTime(handleMessage: );

5.7

printTime
MESSAGE_OUTBOUND_PROPERTY messageContext.get()
Boolean

Boolean outboundProperty =
(Boolean)messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outboundProperty.booleanValue()) {
System.out.println("\nOutbound message:");
} else {

System.out.println("\nInbound message:");
}

5.8

printSource Source

LogicalMessage lm =messageContext.getMessage();
Source payload = lm.getPayload();

LogicalMessage lm =messageContext.getMessage();
Source payload = lm.getPayload();
printSource(payload);

5.9

package com.library.ws;
import java.util.Set;
import java.util.Collections;
import
import
import
import
import
import
import

javax.xml.namespace.QName;
javax.xml.ws.handler.LogicalHandler;
javax.xml.ws.handler.MessageContext;
javax.xml.ws.handler.LogicalMessageContext;
javax.xml.ws.LogicalMessage;
javax.xml.transform.Source;
javax.xml.transform.dom.DOMSource;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class HWLogicalHandler implements
LogicalHandler<LogicalMessageContext> {
public Set<QName> getHeaders() {
System.out.println("HWLogicalHandler.getHeanders called.\n");
return Collections.emptySet();
}
public boolean handleMessage(LogicalMessageContext messageContext) {
System.out.println("HWLogicalHandler.handleMessage called. with
'"+messageContext+"'.\n");
Boolean outboundProperty =
(Boolean)messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)
;
if (outboundProperty.booleanValue()) {
System.out.println("\nOutbound message:");
} else {
System.out.println("\nInbound message:");
}
LogicalMessage lm =messageContext.getMessage();

Source payload = lm.getPayload();


printSource(payload);
System.out.println("** Response: " +
messageContext.getMessage().toString());
return true;
}
public boolean handleFault(LogicalMessageContext messageContext) {
System.out.println("HWLogicalHandler.handleFault called. with
'"+messageContext+"'.\n");
return true;
}
public void close(MessageContext messageContext) {
System.out.println("HWLogicalHandler.close called. with
'"+messageContext+"'.\n");
}
private void printSource(Source payload) {
System.out.println("Payload of message = '"+payload+"'");
if (!(payload instanceof DOMSource)) return;
DOMSource ds = (DOMSource)payload;
printNode(0,ds.getNode() );
}
private void printNode(int depth,Node node) {
if ( node == null) return;
for ( int j = 0; j < depth; j++) System.out.print("\t");
System.out.println("" + node);
NodeList children = node.getChildNodes();
if ( children == null ) return;
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
printNode(depth+1,child);
}
}
}

Web XML
5.10

com.library.ws handler-chain.xml XML

a. com.library.ws
b. New > Other
c. XML > XML
d. handler-chain.xml

5.11

<?xml version="1.0" encoding="UTF-8" ?>


<handler-chains xmlns="http://java.sun.com/xml/ns/javaee">
<handler-chain>
<handler>
<handler-class>com.library.ws.HWLogicalHandler</handler-class>
</handler>
</handler-chain>
</handler-chains>

Web
5.12

HelloWS Web

5.13

HandlerChain handler-chain.xml

@HandlerChain(file="handler-chain.xml")
public class HellowWS

5.14

BookQuery Web

Web
5.15

Project Explorer HelloWS Web Run As > Run on


Server

5.16

WebLogic Test sayHello

5.17

Console

Inbound message:
Payload of message = 'javax.xml.transform.dom.DOMSource@1e428b2'
[#document:null]
[sayHello:null]
[#text:
]
[arg0:null]
[#text:Oracle]
[#text:
]
** Response:com.sun.xml.ws.handler.LogicalMessageImpl@2bec39
HWLogicalHandler.handleMessage called. with
'com.sun.xml.ws.handler.LogicalMessageContextImpl@1d03ef'.
Outbound message:
Payload of message = 'javax.xml.transform.dom.DOMSource@e37fa6'
[#document:null]
[ns2:sayHelloResponse:null]
[return:null]
[#text:hello Oracle]
** Response:com.sun.xml.ws.handler.LogicalMessageImpl@1d18b8b

5.18

BookQuery wtell brief

5.19

Console

6 MTOM
XML SOA Internet
(MIME) Internet (DIME)
Web (Message Transmission Optimization
Method) MTOM XML (XOP)

Web Web MTOM XOP

Web MTOM
Web java MTOM

6 6 Web

MTOMSrvice, MTOMClient

MTOMService_solution, MTOMClient_solution

com.library.ws

Property Inspector Web

MTOM Web

MTOM Web

MTOM Web

MTOM
6.1

Eclipse MTOMService

6.2

Project Explorer com.library.ws.BookQuery.java

Web MTOM
6.3

BookQuery.java

6.4

128 @MTOM
@MTOM(threshold=128)
Public class BookQuery

JEE MTOM
6.5

MTOM Client src>com.library.ws.servlet>


BookQueryServiceClientServlet.java main

6.6

BookQuery bqp = bqs.getBookQueryPort();

BookQuery bqp = bqs.getBookQueryPort(new MTOMFeature());


import import javax.xml.ws.soap.MTOMFeature;

6.7

byte[] data = getStoredArtifact("brief.txt");

try {
String storeName = bqp.storeRelatedArtifact(data,
"brief2.txt");
System.out.println("Data stored as:"+ storeName);
} catch (Exception e) {
System.out.println("Unexpected exception" +
e.getMessage());
}

6.8

String artifact = bqp.returnArtifact("brief2.txt");


System.out.println("artifact:"+ artifact);

JEE
6.9

Project Navigation Panel Servlet Run As > Run On


Server 404 MTOM Solution

6.10

JSE MTOM
6.11

src>com.library.ws.client> BookQueryServiceClient.java
main

6.12

BookQuery bqp = bqs.getBookQueryPort();

BookQuery bqp = bqs.getBookQueryPort(new MTOMFeature());


import
import javax.xml.ws.soap.MTOMFeature;

6.13

byte[] data = getStoredArtifact("brief.txt");

try {
String storeName = bqp.storeRelatedArtifact(data,
"brief2.txt");
System.out.println("Data stored as:"+ storeName);
} catch (Exception e) {
System.out.println("Unexpected exception" +
e.getMessage());
}

6.14

String artifact = bqp.returnArtifact("brief2.txt");


System.out.println("artifact:"+ artifact);
BookQuery.java BookQueryServiceClient.java
D:/docs/webservicePM...
/home/oracle/labs/WS_Labs/labHome/resources/

JSE
6.15

WebLogic Server Ignore


compilation errors when deploying main
Run As > Java Application

6.16

NoClassDefFoundError

6.17

main Run As > Run configurations

6.18

JRE Source Classpath

6.19

Bootstrap Entries WebLogic Systems Libraries Remove


OEPE WLS Web Service JSE
Apply Run Configurations

6.20

main Run As > Java Application

6.21

6.22

8 RESTful Web
SOAP Web RESTful Web
AJAX Web 2.0 REST

JAX-WS POJO REST Web


Provider API
JAX-RS API RESTful Web
JerseyJAX-RS REST Web WLS
JAX-WS API JAX-RS API
8 8 Web

REST

REST_solution

com.ws.rest

Eclipse

REST JAX-WS Web

OEPE WebLogic Server


8.1

<LabDomain> WebLogic Server

8.2

8.3

Ctrl + c

OEPE Eclipse
8.4

Eclipse

8.5

<LabWorkspace>

8.6

Package Explorer New > Project

8.7

New Project WebLogic Web Services Web Service Project


Next

8.8

New Web Services Project 8 Target


Runtime New

8.9

New Server Runtime Environment Oracle WebLogic Server


11gR1 Next

8.10

8 <WebLogicHome> Browse WebLogic Home


Finish

8.11

Finish Web
Open Associated Perspective Yes

Java
8.12

Project Explorer src

8.13

src New > Package


1 Finish

8.14

New > WLS Web Service


(com.ws.rest) (HelloRest) Finish

8.15

import java.io.ByteArrayInputStream;
import java.util.StringTokenizer;

import
import
import
import
import
import
import
import
import
import

8.16

javax.annotation.Resource;
javax.xml.transform.Source;
javax.xml.transform.stream.StreamSource;
javax.xml.ws.Provider;
javax.xml.ws.WebServiceContext;
javax.xml.ws.WebServiceProvider;
javax.xml.ws.handler.MessageContext;
javax.xml.ws.http.HTTPException;
javax.xml.ws.http.HTTPBinding;
javax.xml.ws.BindingType;.

@WebServiceProvider @Bindingtype
@webservice Provider<Source>
@WebServiceProvider(
targetNamespace="http://example.org",
serviceName = "HelloRestService")
@BindingType(value = HTTPBinding.HTTP_BINDING)
public class HelloRest implements Provider<Source> {

.
8.17

@ Resource WebServiceContext
@Resource(type=Object.class)
protected WebServiceContext wsContext;

8.18

invoke() queryString
public Source invoke(Source source) {
try {
MessageContext messageContext =
wsContext.getMessageContext();
String query =
(String)messageContext.get(MessageContext.QUERY_STRING);
if (query != null && query.contains("name=")) {
return createSource(query);
} else {
System.err.println("Query String = "+query);
throw new HTTPException(404);
}
} catch(Exception e) {
e.printStackTrace();
throw new HTTPException(500);
}
}

8.19

xml createSource()
private Source createSource(String str) throws Exception {
StringTokenizer st = new StringTokenizer(str, "=&/");
st.nextToken();
String name = st.nextToken();
String body = "<ns:HelloRest
xmlns:ns=\"http://example.org\"><greeting>"

+"hello " + name +"</greeting>"+ "</ns:HelloRest>";


return new StreamSource(new
ByteArrayInputStream(body.getBytes()));
}

8.20

package com.ws.rest;
import java.io.ByteArrayInputStream;
import java.util.StringTokenizer;
import
import
import
import
import
import
import
import
import
import

javax.annotation.Resource;
javax.xml.transform.Source;
javax.xml.transform.stream.StreamSource;
javax.xml.ws.Provider;
javax.xml.ws.WebServiceContext;
javax.xml.ws.WebServiceProvider;
javax.xml.ws.handler.MessageContext;
javax.xml.ws.http.HTTPException;
javax.xml.ws.http.HTTPBinding;
javax.xml.ws.BindingType;

/**
* Example request
url:http://localhost:7001/REST/HelloRestService?name=oracle
*/
@WebServiceProvider(
targetNamespace="http://example.org",
serviceName = "HelloRestService")
@BindingType(value = HTTPBinding.HTTP_BINDING)
public class HelloRest implements Provider<Source> {
@Resource(type=Object.class)
protected WebServiceContext wsContext;
public Source invoke(Source source) {
try {
MessageContext messageContext =
wsContext.getMessageContext();
String query =
(String)messageContext.get(MessageContext.QUERY_STRING);
if (query != null && query.contains("name=")) {
return createSource(query);
} else {
System.err.println("Query String = "+query);
throw new HTTPException(404);
}
} catch(Exception e) {
e.printStackTrace();
throw new HTTPException(500);
}
}
private Source createSource(String str) throws Exception {
StringTokenizer st = new StringTokenizer(str, "=&/");

st.nextToken();
String name = st.nextToken();
String body = "<ns:HelloRest
xmlns:ns=\"http://example.org\"><greeting>"
+"hello " + name +"</greeting>"+ "</ns:HelloRest>";
return new StreamSource(new
ByteArrayInputStream(body.getBytes()));
}
}

8.21
(

Web
8.22

HelloRest.java
Run As > Run on Server

8.23

Run on Server Finish

8.24

console RESTful Web


(UTC)

8.25

Web URL
http://localhost:7001/REST/HelloRestService?name=oracle

8.26

8.27

(REST_solution) NearbyCity.java

http://localhost:7001/REST_solution/NearbyCityService?lat=32&long=-122

9 JAX-WS Web

WebLogic Web

Web Services Atomic Transaction (WS-AtomicTransaction) Versions 1.0, 1.1


1.2http://docs.oasis-open.org/ws-tx/wstx-wsat-1.2-spec-cs01/wstx-wsat-1.2-spec-cs-01.html

Web Services Coordination (WS-Coordination) Versions 1.01.1 1.2


http://docs.oasis-open.org/ws-tx/wstx-wscoor-1.2-spec-cs-01/wstxwscoor-1.2-spec-cs-01.html

Web

WebLogic Server Web


WebLogic Web

JTA JTA
Web
JTA
JTA

Web Web

Java Web
@weblogic.wsee.wstx.wsat.Transactional Using
the @Transactional Annotation in Your JWS File
WSDL wsdlc WSDL
Web WSDL WS-AtomicTransaction
wsdlc Web WSDL
Enabling Web Services Atomic Transactions Starting From WSDL
WebLogic Server Web
Web Configuring Web
Services Atomic Transactions Using the Administration Console

@Transactional JAX-WS
WS-AT
Web Web

9 9 Web

WSATervice, WSATClient

WSATService_solution, WSATClient_solution

examples.webservices.jaxws.wsat.service,
examples.webservices.jaxws.wsat.client

Web

WSDL WS-AT

Web WS-AT

Web
9.1

Eclipse WSATService WebLogic Server

9.2

examples.webservices.jaxws.wsat.service
WsatBankTransferService

9.3

@WebService @Transactional
WsatBankTransferService
@Transactional(value=Transactional.TransactionFlowType.MANDATORY,
version=weblogic.wsee.wstx.wsat.Transactional.Version.WSAT10)
public class WsatBankTransferService {

9.4

Web

9.5

JDBC DataSources Service/Data


Source Weblogicwelcome1

WSDL WS-AT
9.6

Project Explorer WsatBankTransferService Run


As > Run on Server Finish

9.7

WebLogic Test Client Web

9.8

WLS_UTC WSDL URL WSAT10

Web WS-AT
9.9

Eclipse WSATClient

9.10

examples.webservices.jaxws.wsat.client
WsatBankTransferServlet servlet WsatBankTransfer.jsp

9.11

JAX-WS TransactionFeature
AddressingFeature getWebService WSAT
// Passing the TransactionalFeature to the Client
private WsatBankTransferService getWebService(URL wsdlURL) {
TransactionalFeature feature = new TransactionalFeature();
feature.setFlowType(TransactionFlowType.MANDATORY);
feature.setVersion(Version.WSAT10);
WsatBankTransferService_Service service =
new WsatBankTransferService_Service(wsdlURL,
new QName("http://tempuri.org/", "WsatBankTransferService"));
return service.getWSHttpBindingIService(new
javax.xml.ws.soap.AddressingFeature(), feature);
}

PDF
9.12

Save

9.13

WebContent WsatBankTransfer.jsp Run As > Run On


Server Finish


9.13

Derby DOS
2010-08-13 17:46:320.555 GMT :Security manager installed using the Basic server
security policy.
2010-08-13 17:46:36.755 GMT :Apache Derby Network Server - 10.6.1.0 - (938214)
started and ready to accept connections on port 1527

9.14

Derby
WS-AT Web create account
No Amount Submit
1

9.15

list all account balances Submit

9.16

transfer money No Amount Submit

9.17

list all account balances Submit

9.18

10 JAX-WS Web
Web
Web WSReliableMessaging
Web

@ Policy JAX-WS
WLS SAF WS-RM

WS-RM

10 10 Web

WSRMService, WSRMProxyService, WSRMClient

WSRMService_solution, WSRMProxyService_solution,
WSRMClient_solution
wsrm_jaxws.example.service, wsrm_jaxws.example.client,
wsrm_jaxws.example

Web

WSDL WS-RM

Web WS-RM


Web
10.1

Eclipse WSRMService

10.2

wsrm_jaxws.example.service ReliableEchoServiceImpl

10.3

@WebService @Policy
ReliableEchoServiceImpl weblogic.jar

@WebService(portName = "ReliableEchoPort",
serviceName = "ReliableEchoService",
targetNamespace = "http://wsrm_jaxws.example/"
)
@Policy(uri="policy:Reliability1.0_1.1")
public class ReliableEchoServiceImpl {

10.4

Web

10.5

SAF JMS Services/Messaging/{JMS


Servers, Store-and-Forward Agents, JMS modules}
\wlserver_10.3\common\templates\applications\ wls_webservice_jaxws.jar

WSDL WS-RM -{}10.6

Project Explorer ReliableEchoServiceImpl


Run As > Run on Server Finish

10.7

WebLogic Test Client Web

10.8

WLS_UTC WSDL URL Reliability1.0_1.1

Web WS-RM
10.9

WSRMProxyService

10.10 wsrm_jaxws.example ClientServiceImpl JAX-WS


Web WebLogic

10.11 JAX-WS WS-RM


initFeatures() WS-RM

@WebServiceRef
@PostConstruct
public void initFeatures() {
String clientId =
"WsrmJaxws_example_Service_Client_AsyncBuffered";
WsrmClientInitFeature rmInitFeature = new
WsrmClientInitFeature(true);
rmInitFeature.setNonBufferedSource(false);
rmInitFeature.setNonBufferedDestination(false);
features.add(rmInitFeature);
Container c =
ContainerResolver.getInstance().getContainer();
ServletContext servletContext =
c.getSPI(ServletContext.class);
AsyncClientTransportFeature asyncFeature =
new AsyncClientTransportFeature(servletContext);
features.add(asyncFeature);
ReliableEchoServiceImplAsyncHandler asyncHandler =new
MyAsyncHandler();
AsyncClientHandlerFeature achf = new
AsyncClientHandlerFeature(asyncHandler);
features.add(achf);
ClientIdentityFeature clientIdFeature = new
ClientIdentityFeature(clientId);
features.add(clientIdFeature);
mPort =
service.getReliableEchoPort((WebServiceFeature[])features.toArray(new
WebServiceFeature[features.size()]));
}

10.12 Save
10.13
private class MyAsyncHandler
implements ReliableEchoServiceImplAsyncHandler {
public void onEchoResponse(Response<EchoResponse>
echoResponseResponse) {
System.out.println("testing...................\n\n\n\n");
// Find our saved/persistent request ID in the
persistent context.
Map<String, Serializable> persistentContext =
(Map<String, Serializable>)echoResponseResponse.

getContext().get(JAXWSProperties.PERSISTENT_CONTEXT);
String requestId =
(String)persistentContext.get("RequestID");
if (requestId == null) {
say("NO RequestID property on
persistentContext for response!!!!");
try {
String response =
echoResponseResponse.get().getReturn();
say("Got uncorrelatable response:" +
response);
} catch (Throwable t) {
say("Got uncorrelatable error:" +
t.toString());
t.printStackTrace();
}

10.14 ClientServiceImpl Run As > Run On Server


Finish

10.15 WSRMClient
10.16 wsrm_jaxws.example.client WsrmJaxwsExampleRequest
Java SE

10.17 Run As > Java Application

10.18

11 JAX-WS Web

Web SOAP
SOAP
Web

X.509 SAML

SAML Token Profile 1.1 (http://docs.oasis-open.org/wss/v1.1/wss-v1.1-specos-SAMLTokenProfile.pdf) WS-Security


SAML Web WebLogic Server SAML Token Profile
1.1 SAML 2.0 SAML 1.1 SAML Token Profile 1.1
SAML Token Profile 1.0
SAML WebLogic Server
WebLogic Server Web
Web Web
SAML WS-Trust
SAML

@ Policy JAX-WS
Web
SAML
SAML Sender Vouches
SAML

11 11 Web

SAML20SVPartnerService, SAML20SVProxyService,
SAML20SVClient
SAML20SVPartnerService_solution,
SAML20SVProxyService_solution, SAML20SVClient_solution
examples.webservices.saml.saml20sv

Web SAML Sender Vouches

WSDL SAML Sender Vouches

Web SAML Sender Vouches

Web SAML Sender Vouches


11.1

Eclipse SAML20SVPartnerService

11.2

examples.webservices.saml.saml20sv PartnerService

11.3

@WebService @Policies @Policy


PartnerService weblogic.jar
SAML

@Policies(
{
@Policy(uri = "policy:Wssp1.2-2007-Saml2.0-SenderVouchesWss1.1.xml"),
@Policy(uri = "policy:Wssp1.2-2007-SignBody.xml"),
@Policy(uri = "policy:Wssp1.2-2007-EncryptBody.xml")
}
)
@WebService(serviceName = "PartnerService", name = "IPartner",
targetNamespace = "http://www.oracle.com/2008/12/interop")
public class PartnerService{

11.4

Web checkSamlAttributesFromRequestMessage()
SAML SAML

11.5

Web SAML
wlsWebServiceLab/Web Service Security Web
Security realm/myrealm/Credential Mappings/PKI
Security realm/myrealm/Providers/Authentication
Security realm/myrealm/Providers/Credential Mapping
WLST

WSDL SAML Sender Vouches


11.6

Project Explorer PartnerService Run As >


Run on Server Finish

11.7

WebLogic Test Client Echo


Web

11.8

WLS_UTC WSDL URL

Web SAML Sender Vouches


11.9

SAML20SVProxyService

11.10 examples.webservices.saml.saml20sv ProxyService


JAX-WS Web SAML
WS-Trust WebLogic
11.11 @WebService @Policies @Policy

ProxyService weblogic.jar

@Policies(
{
@Policy(uri = "policy:Wssp1.2-2007-Wss1.1-UsernameToken-PlainEncryptedKey-Basic128.xml"),
@Policy(uri = "policy:Wssp1.2-2007-SignBody.xml"),
@Policy(uri = "policy:Wssp1.2-2007-EncryptBody.xml")

}
)
@WebService(serviceName = "ProxyService", name = "IProxy",
targetNamespace = "http://www.oracle.com/2008/12/interop")
public class ProxyService{

11.12 Save
11.13 JAX-WS BindingProvider
try{
PartnerService service =
new PartnerService(new URL(partenerWsdlURL),
new QName("http://www.oracle.com/2008/12/interop",
"PartnerService"));
IPartner port = service.getIPartnerPort();
BindingProvider provider = (BindingProvider) port;
Map context = provider.getRequestContext();
context.put(WLStub.SAML_ATTRIBUTE_ONLY, "True");
context.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://localhost:7001/partnerservice/partnerservice");
List credProviders = buildCredentialProviderList();
context.put(WSSecurityContext.CREDENTIAL_PROVIDER_LIST,
credProviders);
String result = port.echo(hello);
return result+" I'm ProxyService Echo!\n";
} catch(Exception ex ){
throw new RuntimeException(ex);
}

11.14 SAML
private static class MySAMLCredentialProvider1 extends
SAML2CredentialProvider {
public SAMLAttributeStatementData getSAMLAttributeData(Subject
subject) {
System.out.println(" Providing SAML Attributes from
MySAMLCredentialProvider1 for Subject =" + subject);
// There are four types of attributes in this test
SAMLAttributeStatementData attributes = new
SAMLAttributeStatementDataImpl();
String xmlns = "www.oracle.com/webservices/saml/test";
// 1. The attribute without value
SAMLAttributeData attribute1 = new SAMLAttributeDataImpl();
attribute1.setAttributeName("test.no.value.attribute");
// Friendly name is optional.It is set in this example.

attribute1.setAttributeFriendlyName("Type 1 - No Value");
attribute1.setAttributeNameSpace(xmlns);
attributes.addAttributeInfo(attribute1);
// 2. Static attribute that has static value
SAMLAttributeData attribute2 = new SAMLAttributeDataImpl();
attribute2.setAttributeName("test.static.attribute");
attribute2.setAttributeFriendlyName("Type 2 - Static Attribute");
attribute2.setAttributeNameSpace(xmlns);
attribute2.addAttributeValue("static.attribute.value");
attributes.addAttributeInfo(attribute2);

11.15 ProxyService Run As > Run On Server


Finish

11.16 SAML20SVClient
11.17 examples.webservices.saml.saml20sv EchoClientServlet
servlet
partner
11.18 BST UNT
private static CredentialProvider getClientBSTCredentialProvider()
throws Exception {
InputStream clientKeyInputStream =
EchoClientServlet.class.getResourceAsStream("/Alice.prv");
InputStream clientCertInputStream =
EchoClientServlet.class.getResourceAsStream("/Alice.cer");
InputStream serverCertInputStream =
EchoClientServlet.class.getResourceAsStream("/Bob.cer");
X509Certificate clientCert =
CertUtils.getCertificate(clientCertInputStream);
PrivateKey clientPrivateKey =
CertUtils.getPKCS8PrivateKey(clientKeyInputStream);
X509Certificate serverCert =
CertUtils.getCertificate(serverCertInputStream);

return new
ClientBSTCredentialProvider(clientCert, clientPrivateKey,
serverCert);
}
private static CredentialProvider
getClientUNTCredentialProvider() throws Exception {

String username = "Alice";


String password = "ecilA1a!";
return new ClientUNTCredentialProvider(username.getBytes(),
password.getBytes());
}

11.19 Run As > Run On Server Finish

WebLogic Server
<Aug 16, 2010 5:24:02 PM PDT> <Info> <> <BEA-000000> <[SignatureValidationResult
:
[status:true]
[signature:5rCpLSOmi/Dp/WhoDZF2WV3CZOg=]
[keySelectorResult:[KeySelectorResultImpl:
[Key:javax.crypto.spec.SecretKeySpec@15c94]
[Message:null]
[SecurityToken:weblogic.xml.crypto.wss11.internal.enckey.EncryptedKeyToken@1430
2aa]]]
[refValidationResults:
[ReferenceImpl.ValidateResultImpl:
[refURI:#Timestamp_eX9z7AamQMFJQQLS]
[status:true]
[digestValue:0E30E22A2CBAB6E27F4046458E1F10EE86BAF48E]
[unmarshalledDigestValue:0E30E22A2CBAB6E27F4046458E1F10EE86BAF48E]]
[ReferenceImpl.ValidateResultImpl:
[refURI:#Body_mIVU7ho7V5VVzQry]
[status:true]
[digestValue:0141CF80B6822BA3B0CEBE4596EEC426122AF9DE]
[unmarshalledDigestValue:0141CF80B6822BA3B0CEBE4596EEC426122AF9DE]]
[ReferenceImpl.ValidateResultImpl:
[refURI:#sigconf_SkB4gPhv1aiUDzZ5]
[status:true]
[digestValue:F453FFD632F21EC6013D1D3E58109946DF1CBEAB]
[unmarshalledDigestValue:F453FFD632F21EC6013D1D3E58109946DF1CBEAB]]]]>
<WSEE:15>WSEE[MONITORING[Invocation[DispatchTime=619316840][ExecutionTime
=0][Res
ponseTime=619316841]]]<WseeBaseOperationRuntimeData.reportInvocation:185>
<WSEE:15>set Message called:com.sun.xml.internal.messaging.saaj.soap.ver1_1.Mes
sage1_1Impl@1f7571<SoapMessageContext.setMessage:65>
<WSEE:15>Parsed header {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-

wssecurity-secext-1.0.xsd}Security:<name={http://docs.oasis-open.org/wss/2004/0
1/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security> <role=null> <mustUndersta
nd=true><SoapMsgHeaders.parseHeaders:202>
<WSEE:15>isCompatMSFT set to false<SecurityPolicyBlueprintPlotter.drawPolicyComp
atibilityPreference:110>
<WSEE:15>policyNamespaceUri is http://docs.oasis-open.org/ws-sx/ws-securitypolic
y/200702<SecurityPolicyBlueprintPlotter.drawPolicyCompatibilityPreference:111>
<WSEE:15>Inspecting message age ...<SecurityMessageInspector.checkMessage:168>
<Aug 16, 2010 5:24:02 PM PDT> <Info> <> <BEA-000000> <*************TIMESTAMP
VAL
IDATION: >
<Aug 16, 2010 5:24:02 PM PDT> <Info> <> <BEA-000000> <created = Mon Aug 16
17:24
:02 PDT 2010>
<Aug 16, 2010 5:24:02 PM PDT> <Info> <> <BEA-000000> <now = Mon Aug 16
17:24:02
PDT 2010>
<Aug 16, 2010 5:24:02 PM PDT> <Info> <> <BEA-000000> <expiry = Mon Aug 16
17:25:
02 PDT 2010>
<Aug 16, 2010 5:24:02 PM PDT> <Info> <> <BEA-000000> <longCreated =
128200464200
0>
<Aug 16, 2010 5:24:02 PM PDT> <Info> <> <BEA-000000> <longNow =
1282004642920>
<Aug 16, 2010 5:24:02 PM PDT> <Info> <> <BEA-000000> <clockSkew used = 60000>
<Aug 16, 2010 5:24:02 PM PDT> <Info> <> <BEA-000000> <clockSkew = 60000>
<Aug 16, 2010 5:24:02 PM PDT> <Info> <> <BEA-000000> <clockPrecision = 60000>
<Aug 16, 2010 5:24:02 PM PDT> <Info> <> <BEA-000000> <useClockSkew = true>
<Aug 16, 2010 5:24:02 PM PDT> <Info> <> <BEA-000000> <clockSynchronized = true>
<Aug 16, 2010 5:24:02 PM PDT> <Info> <> <BEA-000000> <maxProcessingDelay = -1>
<Aug 16, 2010 5:24:02 PM PDT> <Info> <> <BEA-000000> <TIMESTAMP
VALIDATION: >
<Aug 16, 2010 5:24:02 PM PDT> <Info> <> <BEA-000000> <created = Mon Aug 16
17:24
:02 PDT 2010>
<Aug 16, 2010 5:24:02 PM PDT> <Info> <> <BEA-000000> <now = Mon Aug 16
17:24:02
PDT 2010>
<Aug 16, 2010 5:24:02 PM PDT> <Info> <> <BEA-000000> <expiry = Mon Aug 16
17:25:
02 PDT 2010>
<Aug 16, 2010 5:24:02 PM PDT> <Info> <> <BEA-000000> <clockSkew used = 60000>
<WSEE:15> timestamp(maxAgesSecs=60)
verified<SecurityMessageInspector.doMessageAge:756>
<WSEE:15>Inspecting message authentication identity ...<SecurityMessageInspector

.checkMessage:176>
<WSEE:15>Identity is not required.<SecurityMessageInspector.inspectIdentity:804>
<WSEE:15>Inspecting signature confirmation ...<SecurityMessageInspector.checkMes
sage:187>
<WSEE:15>Inspecting signature and encryption ..., request =false<SecurityMessage
11.20

You might also like