Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Web Services and the fly likes Configuring WebService Client Handle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Configuring WebService Client Handle" Watch "Configuring WebService Client Handle" New topic
Author

Configuring WebService Client Handle

anubechara Gupta
Greenhorn

Joined: Jul 05, 2006
Posts: 17
Hello Ranchers,
I am having problem while configuring Client side handler for webservice in Websphere. My handler is not working (not getting intialized) even after making required configuration.
I have following lines in my web.xml file:
<service-ref>
<description>WSDL Service PartyService</description>
<service-ref-name>service/PartyService</service-ref-name>
<service-interface>com.fidintl.xmlns.service.partyservice._0._1.PartyService</service-interface>
<wsdl-file>WEB-INF/wsdl/PartyWebService.wsdl</wsdl-file>
<jaxrpc-mapping-file>WEB-INF/PartyWebService_mapping.xml</jaxrpc-mapping-file>
<service-qname xmlns fx="http://xmlns.fid-intl.com/smt/webservice/party/0.1">pfx artyService</service-qname>
<port-component-ref>
<service-endpoint-interface>com.fidintl.xmlns.service.partyservice._0._1.PartyServiceInterface</service-endpoint-interface>
</port-component-ref>
<handler>
<description>
HeaderHandler</description>
<description>
HeaderHandler</description>
<description>
HeaderHandler</description>
<display-name>
HeaderHandler</display-name>
<display-name>
HeaderHandler</display-name>
<display-name>
HeaderHandler</display-name>
<handler-name>HeaderHandler</handler-name>
<handler-class>com.handler.HeaderHandler</handler-class>
</handler>
</service-ref>
And my handler class is:
package com.handler;

import javax.xml.rpc.handler.Handler;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFactory;
import javax.xml.soap.SOAPHeader;
import javax.xml.namespace.QName;

public class HeaderHandler implements Handler
{
public void init(javax.xml.rpc.handler.HandlerInfo config) {
System.out.println("HI");
}


public QName[] getHeaders ()
{
// Fill in method body
return null;
}

public boolean handleRequest( MessageContext context )
{
// Fill in method body or delete method to use GenericHandler
SOAPMessageContext smc = (SOAPMessageContext) context;
try {
SOAPEnvelope se = smc.getMessage().getSOAPPart().getEnvelope();
// create instance of SOAP factory
SOAPFactory sFactory = SOAPFactory.newInstance();
// create SOAP elements specifying prefix and URI
SOAPElement sHelem1 = sFactory.createElement("authHeader1","a0","www");
SOAPElement sCHelem11 = sFactory.createElement("id","a0","www");
// attach value to id element
sCHelem11.addTextNode("SCOTT");
SOAPElement sCHelem12 = sFactory.createElement("password","a0","www");

// attach value to password element
sCHelem12.addTextNode("TIGER");
//add child elements to the root element
sHelem1.addChildElement(sCHelem11);
sHelem1.addChildElement(sCHelem12);

// create SOAPHeader instance for SOAP envelope
SOAPHeader sh = se.addHeader();
// add SOAP element for header to SOAP header object
sh.addChildElement(sHelem1);
} catch (SOAPException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}

public boolean handleResponse( MessageContext context )
{
System.out.println("HI");
// Fill in method body or delete method to use GenericHandler
return true;
}

public boolean handleFault( MessageContext context )
{
System.out.println("HI");
// Fill in method body or delete method to use GenericHandler
return true;
}


/* (non-Javadoc)
* @see javax.xml.rpc.handler.Handler#destroy()
*/
public void destroy() {
// TODO Auto-generated method stub

}

}


Help will be appreciated. Many Thanks in advance
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Configuring WebService Client Handle
 
Similar Threads
Web service handler could not registered/called in client web service
Service with handlers on JBoss. BIG Problem
Spring Web Services handler
jax-ws handler causing exception
strange soap message creation with plain old java code, any suggestions?