GeeCON Prague 2014*
The moose likes Web Services and the fly likes Why cannot my  own  Handler work? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "Why cannot my  own  Handler work? " Watch "Why cannot my  own  Handler work? " New topic
Author

Why cannot my own Handler work?

yefeng Gu
Greenhorn

Joined: Sep 19, 2003
Posts: 5
I have extends BasicHandler in my own web Service ,
here the Handler is MyLogHandler,and i have configured
this Handler in server-config.wsdd,
but when i invoke the web service,my client cannot
get the web service information,
though the Handler worked.
I want to know whether the handler cannot effect on
the web service others handler and response handler?
if so,why my client cannot get the response?

the hanlder code is followed( i have copied this from others)

Handler handler = parm1.getService();
String filename = (String)getOption("filename");
if ((filename == null) || (filename.equals("")))
throw new AxisFault("Server.NoLogFile",
"No log file configured for
the LogHandler!",
null, null);
FileOutputStream fos = new FileOutputStream(filename, true);
PrintWriter writer = new PrintWriter(fos);
Integer counter = (Integer)handler.getOption("accesses");
if (counter == null)
counter = new Integer(0);

counter = new Integer(counter.intValue() + 1);
Date date = new Date();
parm1.getMessage().writeTo(System.out);

String result = "在"+date + ": Web 服务 " +
parm1.getTargetService() +
" 被调用,现在已经共调用了 " + counter + " 次.";
handler.setOption("accesses", counter);
writer.println(result);
writer.close();

So Thanks!
prashant sable
Greenhorn

Joined: Dec 20, 2005
Posts: 3
can u post ur server-config.wsdd ?
-prashant
yefeng Gu
Greenhorn

Joined: Sep 19, 2003
Posts: 5
i have tried the LogHandler is ok,but here something wrong:
i use my own RequestHandler to check the request soap message,if
isn't legal,i responsed with AxisFault,but i find my client can receive
the correct response; and i use repsonseHandler to check the response message,if something wrong,i change the returned soap message,here i also
use AxisFault :
fault= new AxisFault(new QName("env:Receiver"),new QName[]{new QName("303")},"不存在",null, null,null);
parm1.setCurrentMessage(new Message(fault));
but this cannot return axis fault message to client also.
yefeng Gu
Greenhorn

Joined: Sep 19, 2003
Posts: 5
besides this,here also other question:
1) i cannot find subcode of axisFault,server i use axis1.3,client i use soapTest1.4.2
2) the characters "不存在" cannot be recogined


the follow is my server-config.wsdd:

..... <globalConfiguration>
.... <requestFlow>
<handler type="java rg.apache.axis.handlers.JWSHandler">
<parameter name="scope" value="session"/>
</handler>
<handler type="java rg.apache.axis.handlers.JWSHandler">
<parameter name="scope" value="request"/>
<parameter name="extension" value=".jwr"/>
</handler>
<handler name="logging" type="java rg.egs.das.services.LMDtRequestHandler">
</handler>
</requestFlow>
<responseFlow>
<handler name="respHandler" type="java rg.egs.das.services.LMDtResponseHandler"/>
</responseFlow>
</globalConfiguration>
.......
<service name="DataAccess" provider="java:RPC">
<parameter name="allowedMethods" value="*"/>
..... <typeMapping deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" qname="ns1:XFieldReference" serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" type="java rg.egs.das.datatype.XFieldReference" xmlns:ns1="http://www.org.egs.cn/services/DataAccess"/>
.... <requestFlow>
<handler type="java rg.egs.das.services.LMDtRequestHandler"/>
</requestFlow>
<responseFlow>
<handler type="java rg.egs.das.services.LMDtResponseHandler"/>
</responseFlow>
</service>
<transport name="http">
<requestFlow>
<handler type="URLMapper"/>
<handler type="java rg.apache.axis.handlers.http.HTTPAuthHandler"/>
</requestFlow>
</transport>
<transport name="local">
<responseFlow>
<handler type="LocalResponder"/>
</responseFlow>
</transport>
</deployment>
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42047
    
  64
but this cannot return axis fault message to client also

Why not? What happens if you do?

the characters "不存在" cannot be recogined

What exactly does this mean? Are they properly escaped, or encapsulated in a CDATA section when they get sent over the wire? Because otherwise they are not valid XML.

i cannot find subcode of axisFault

subcode is not so new; even Axis 1.2 had that. Are you sure you are using the correct Axis libraries? Or are you saying that you can't find a list of possible subcodes? There is none - you can define and use whatever you like.


Ping & DNS - my free Android networking tools app
yefeng Gu
Greenhorn

Joined: Sep 19, 2003
Posts: 5
1. client received correct response like without use ResponseHandler,though
Response Handler takes effect for i find the log it makes in my pc.

2. the character i use is chinese , but the faultString isn't chinese but
other ascii character without meaning.
The response xml is <?xml version="1.0" encoding="UTF-8"?>
i made nothing except throw AxisFault,so i think the xml is valid.

3. I use is Axis1.3, so i don't know whether the subcode is escaped by
SOAPTest tool or by default,my server return.

I will do test on 2 and 3,but for the 1)question i haven't good methods to
try.

So thx for your recommendtions.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42047
    
  64
To debug problems of this kind it is very helpful to view the actual SOAP/XML that's being sent over the wire. Axis ships with two tools, TCPMon and SOAPMonitor, that let you do this. Documentation for these is here and here.

By the way, since you seem to have submitted the earlier post twice, could you delete one of the copies? You can do this by clicking on the edit button (the one with the pencil and the sheet of paper), and then on the edit page checking the "Delete Post" checkbox.
[ January 06, 2006: Message edited by: Ulf Dittmer ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why cannot my own Handler work?