KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > transport > java > JavaSender


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.axis.transport.java;
18
19 import org.apache.axis.AxisFault;
20 import org.apache.axis.MessageContext;
21 import org.apache.axis.client.Call;
22 import org.apache.axis.components.logger.LogFactory;
23 import org.apache.axis.description.OperationDesc;
24 import org.apache.axis.constants.Scope;
25 import org.apache.axis.handlers.BasicHandler;
26 import org.apache.axis.handlers.soap.SOAPService;
27 import org.apache.axis.providers.java.MsgProvider;
28 import org.apache.axis.providers.java.RPCProvider;
29 import org.apache.commons.logging.Log;
30
31 public class JavaSender extends BasicHandler {
32     protected static Log log =
33         LogFactory.getLog(JavaSender.class.getName());
34
35     public void invoke(MessageContext msgContext) throws AxisFault {
36         if (log.isDebugEnabled()) {
37             log.debug("Enter: JavaSender::invoke");
38         }
39
40         SOAPService service = null ;
41         SOAPService saveService = msgContext.getService();
42         OperationDesc saveOp = msgContext.getOperation();
43
44         Call call = (Call) msgContext.getProperty( MessageContext.CALL );
45         String JavaDoc url = call.getTargetEndpointAddress();
46         String JavaDoc cls = url.substring(5);
47   
48         msgContext.setService( null );
49         msgContext.setOperation( null );
50
51         if ( msgContext.getProperty(MessageContext.IS_MSG) == null )
52           service = new SOAPService(new RPCProvider());
53         else
54           service = new SOAPService(new MsgProvider());
55
56         if ( cls.startsWith("//") ) cls = cls.substring(2);
57         service.setOption(RPCProvider.OPTION_CLASSNAME, cls);
58         service.setEngine(msgContext.getAxisEngine());
59   
60         service.setOption( RPCProvider.OPTION_ALLOWEDMETHODS, "*" );
61         service.setOption( RPCProvider.OPTION_SCOPE, Scope.DEFAULT.getName());
62         service.getInitializedServiceDesc( msgContext );
63         service.init();
64   
65         msgContext.setService( service );
66
67         service.invoke( msgContext );
68   
69         msgContext.setService( saveService );
70         msgContext.setOperation( saveOp );
71
72         if (log.isDebugEnabled()) {
73             log.debug("Exit: JavaSender::invoke");
74         }
75     }
76 }
77
Popular Tags