Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Spring Web Services handler

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All:

I am using Rad 7, Websphere 6.1.
I used the rpc GenericHandler in Rad7 and it works. But I want to implement a version in Spring or Spring Web Services
Here are the contents of my webservices.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE webservices PUBLIC "-//IBM Corporation, Inc.//DTD J2EE Web services 1.0//EN" "http://www.ibm.com/webservices/dtd/j2ee_web_services_1_0.dtd">

<webservices id="WebServices_1066491732483">
<webservice-description id="WebServiceDescription_1066491732483">
<webservice-description-name>HelloWorldService</webservice-description-name>
<wsdl-file>WEB-INF/wsdl/HelloWorld.wsdl</wsdl-file>
<jaxrpc-mapping-file>WEB-INF/HelloWorld_mapping.xml</jaxrpc-mapping-file>
<port-component id="PortComponent_1066491732483">
<port-component-name>HelloWorld</port-component-name>
<wsdl-port id="WSDLPort_1066491732483">
<namespaceURI>http://pack</namespaceURI>;
<localpart>HelloWorld</localpart>
</wsdl-port>
<service-endpoint-interface>pack.HelloWorld</service-endpoint-interface>
<service-impl-bean id="ServiceImplBean_1066491732483">
<servlet-link>pack_HelloWorld</servlet-link>
</service-impl-bean>
<handler id="Handler_1066493401322">
<handler-name>handler.PerformanceHandler</handler-name>
<handler-class>handler.PerformanceHandler</handler-class>
</handler>
</port-component>
</webservice-description>
</webservices>


Here are my GenericHandler implementation code:
/*
* Created on Oct 18, 2003
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package handler;

import java.util.Date;

import javax.xml.namespace.QName;
import javax.xml.rpc.handler.GenericHandler;
import javax.xml.rpc.handler.HandlerInfo;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;

/**
* @author Andre Tost
*
*/
public class PerformanceHandler extends GenericHandler {

protected HandlerInfo info = null;
protected Logger logger = null;

public boolean handleRequest(MessageContext context) {
try {
Date startTime = new Date();
context.setProperty("startTime", startTime);
} catch (Exception x) {
// insert error handling here
x.printStackTrace();
}
return true;
}

public boolean handleResponse(MessageContext context) {
try {
Date startTime = (Date)context.getProperty("startTime");
Date endTime = new Date();
long elapsedTime = endTime.getTime()-startTime.getTime();
logger.write("Elapsed time is "+elapsedTime+"\n");
} catch (Exception x) {
// insert error handling here
x.printStackTrace();
}
return true;
}


/* (non-Javadoc)
* @see javax.xml.rpc.handler.Handler#getHeaders()
*/
public QName[] getHeaders() {
return info.getHeaders();
}

public void init(HandlerInfo arg) {
info = arg;
logger = Logger.getLogger("c://temp//HelloWorldServiceLog");
}

public void destroy() {
logger.close();
}
}


Does anybody know how I can implement the handler like GenericHandler with Spring or Spring Web Services.
Any suggestions are appreciated it.

Yours,

Frustrated.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Were you able to get this to work? The obvious issue is <jaxrpc-mapping-file> doesn't make sense when trying to get spring-ws to work.
 
If you look closely at this tiny ad, you will see five bicycles and a naked woman:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic