Java开发网 |
注册 |
登录 |
帮助 |
搜索 |
排行榜 |
发帖统计
|
您没有登录 |
» Java开发网 » WebService/XML/JSON/SOAP/SOA
打印话题 寄给朋友 订阅主题 |
作者 | Creating SOAP Message Handlers to Intercept the SOAP Message [Re:charleszq] |
charleszq
发贴: 36 积分: 0 |
于 2003-12-02 23:27
Thank you, toString! Let's continue with a new topic on weblogic web service: Creating SOAP Message Handlers to Intercept the SOAP Message. In weblogic edocs site, we can get very clear explanation about this: http://edocs.bea.com/wls/docs81/webserv/interceptors.html#1052635. Please go for it for detail information. Here I just did some test according to the document. First, let's write such a Handler class: package xdoclet; import java.util.Iterator; import javax.xml.rpc.handler.Handler; import javax.xml.rpc.handler.MessageContext; import javax.xml.rpc.handler.HandlerInfo; import javax.xml.rpc.handler.soap.SOAPMessageContext; import javax.xml.namespace.QName; public class TestSoapMessageHandler implements Handler { public void destroy() {} public QName[] getHeaders() { return null; } public boolean handleFault( MessageContext context ) { return true; } public boolean handleRequest( MessageContext context ) { for( Iterator it = context.getPropertyNames(); it.hasNext(); ) { String propertyName = (String)it.next(); System.out.println( "Property name: " + propertyName ); } return true; } public boolean handleResponse( MessageContext context ) { return true; } public void init( HandlerInfo config ) {} } We just do something in the method 'handleRequest', which is, just print out some useless information here. To compile this class, be sure to get weblogic.jar and jaxrpc.jar in your classpath, because in weblogic.jar, you can find QName, while in jaxrpc.jar, you can find those classes in javax.xml.rpc.handler package, such as Handler, MessageContext, etc. You can download jaxrpc.jar from sun.java.com, weblogic seems already has this file, but i don't which it is. then, we can run 'ant compile-ejbs' and 'ant ejb-jar'. Then copy the helloworld.jar into the folder 'staging' mentioned in the document. Modify the 2nd build.xml as this: <servicegen destEar="ws_basic_statelessSession.ear" contextURI="WebServices"> <classpath refid="class.path"/> <service ejbJar="HelloWorld.jar" targetNamespace="http://www.bea.com/webservices/basic/statelesSession" serviceName="HelloWorldEJB" serviceURI="/HelloWorldEJB" generateTypes="True" expandMethods="True" typeMappingFile="types.xml" style="rpc" > <handlerChain name="myChain" handlers="xdoclet.TestSoapMessageHandler" /> </service> that is, just add an element 'handlerChain' in the 1st 'service' element, then run 'ant' to generate the web service ear file. then you can examine the web-service.xml packaged in the ear file, you can see a handler chain is defined in it and the web service 'sayHello' references it. To test the handler chain, just redeploy the ear file in weblogic, then in IE, type 'http://localhost:7001/WebServices/HelloWorldEJB' to invoke the sayHello service. In weblogic console, you can just see the print-out of the handler, like this: Property name: weblogic.webservice.context Property name: __BEA_PRIVATE_BINDING_PROP Another thing, when I was trying to test this handler, I thought maybe we can let weblogic know where to find the 'jaxrpc.jar'. But finally, it turned out that weblogc does have this jar file in its classpath. So, if you're trying to find out the class load process of weblogic, please search in edocs.weblogic.com for 'classloader', there is a short-but-clear article about this. It seems that there are a lot of things to know about the handler process of weblogic web serivce. Still on this....... 菜鸟请教,基本程序调试不通,急急急急急急!!! |
话题树型展开 |
人气 | 标题 | 作者 | 字数 | 发贴时间 |
16461 | Weblogic Web Service学习笔记(XDoclet, Ant) | charleszq | 155 | 2003-11-30 18:37 |
9360 | Re:Weblogic Web Service学习笔记(XDoclet, Ant) | charleszq | 112 | 2003-11-30 18:40 |
9291 | Continue, Implement non-built-in types | charleszq | 1157 | 2003-12-01 23:44 |
9400 | Re:Weblogic Web Service学习笔记(XDoclet, Ant) | charleszq | 2760 | 2003-12-01 23:58 |
9390 | Re:Weblogic Web Service学习笔记(XDoclet, Ant) | charleszq | 1197 | 2003-12-02 00:04 |
9124 | Re:Weblogic Web Service学习笔记(XDoclet, Ant) | toString | 24 | 2003-12-02 04:27 |
9258 | Creating SOAP Message Handlers to Intercept the SOAP Message | charleszq | 3952 | 2003-12-02 23:27 |
9060 | Have to do some other things these days, update this later. | charleszq | 2 | 2003-12-03 22:16 |
9565 | Re:Weblogic Web Service学习笔记(XDoclet, Ant) | find11 | 6 | 2003-12-06 11:01 |
已读帖子 新的帖子 被删除的帖子 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |