Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Spring Web Services handler  RSS feed

 
John Smith
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • 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.
 
Paul oooo
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!