View Javadoc

1   /*
2    * Copyright  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.kandula.wscoor;
18  
19  import org.apache.axiom.om.OMElement;
20  import org.apache.axiom.soap.SOAPEnvelope;
21  import org.apache.axis2.AxisFault;
22  import org.apache.axis2.description.AxisOperation;
23  import org.apache.axis2.engine.DependencyManager;
24  import org.apache.kandula.Constants;
25  
26  /***
27   * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
28   */
29  public class ActivationPortTypeRawXMLSyncMessageReceiver extends
30  		org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver {
31  
32  	public void invokeBusinessLogic(
33  			org.apache.axis2.context.MessageContext msgContext,
34  			org.apache.axis2.context.MessageContext newMsgContext)
35  			throws org.apache.axis2.AxisFault {
36  
37  		try {
38  
39  			// get the implementation class for the Web Service
40  			Object obj = getTheImplementationObject(msgContext);
41  
42  			// Inject the Message Context if it is asked for
43  			DependencyManager.configureBusinessLogicProvider(obj, msgContext
44  					.getOperationContext());
45  
46  			ActivationPortTypeRawXMLSkeleton skel = (ActivationPortTypeRawXMLSkeleton) obj;
47  			// Out Envelop
48  			SOAPEnvelope envelope = null;
49  			// Find the operation that has been set by the Dispatch phase.
50  			AxisOperation op = msgContext.getOperationContext()
51  					.getAxisOperation();
52  
53  			String methodName;
54  			if (op.getName() != null
55  					& (methodName = op.getName().getLocalPart()) != null) {
56  				if (("createCoordinationContextOperation").equals(methodName)) {
57  					OMElement response = null;
58  
59  					// doc style
60  					response = skel
61  							.createCoordinationContextOperation((OMElement) msgContext
62  									.getEnvelope().getBody().getFirstElement()
63  									.detach());
64  
65  					// Create a default envelop
66  					envelope = getSOAPFactory(msgContext).getDefaultEnvelope();
67  					// Create a Omelement of the result if a result exist
68  
69  					envelope.getBody().setFirstChild(response);
70  				}
71  				newMsgContext.setEnvelope(envelope);
72  				newMsgContext
73  						.setWSAAction(Constants.WS_COOR_CREATE_COORDINATIONCONTEXT_RESPONSE);
74  				newMsgContext.setRelationships(null);
75  			}
76  		} catch (Exception e) {
77  			throw AxisFault.makeFault(e);
78  		}
79  
80  	}
81  
82  }