DWR and Web Services

JAX-WS services can be easily accessed via a browser using AJAX technologies like Direct Web Remoting(DWR) to enable client access. The PurchaseOrder web service example discussed previously can easily be accessed from web pages with some simple JavaScript. Simply wrap the service proxy in a JavaBean,include the DWR Jar and configuration file in the WAR and access the JavaBean object in the JavaScript. Details on how to conifgure DWR can be found in the article here For our example the web page looks like


<script type='text/javascript' src='/docliteralfromwsdl-war/dwr/interface/POServiceDAO.js'></script>
<script type='text/javascript' src='/docliteralfromwsdl-war/dwr/engine.js'></script>
<script type='text/javascript' src='/docliteralfromwsdl-war/dwr/util.js'></script>
<script>
function createPO() {
POServiceDAO.createPO(showPO);
}
function showPO(order){
document.getElementById("field1").innerHTML = DWRUtil.toDescriptiveString(order, 2);
sendPO(order);
}
function sendPO(order){
POServiceDAO.sendPO(showStatus,order);
}
function showStatus(status) {
document.getElementById("field2").innerHTML = status.timestamp ;
document.getElementById("field3").innerHTML = status.orderid ;
}
</script>

The full war modified from the previous example fan be downloaded here
The advantages of DWR in particualr is that the proxy is located on the server and is serialized via JavaScript to the client. So architecturally you can have services that are located in the DMZ or even backends that are not exposd to clients directly. The other advantage is performance, when the cilent proxy and service are colocated you can avoid the serialization over the wire and use the JAX-WS local transport.
Ahh the possibilities !!



Comments:

The way you discuss here is to wrap the service proxy in a JavaBean, then expose the javabean to DWR. Can you directly invoking SOAP Web services from within a Web browser using DWR in Spring framework? Thanks, Jin

Posted by Jin on June 14, 2007 at 05:35 AM EDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

sameert

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today