001 /**
002 *
003 * Copyright 2003-2004 The Apache Software Foundation
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.geronimo.axis.client;
018
019 import java.io.Serializable;
020 import java.rmi.RemoteException;
021
022 import javax.xml.namespace.QName;
023
024 import org.apache.axis.description.OperationDesc;
025 import org.apache.axis.description.FaultDesc;
026 import org.apache.axis.client.Call;
027 import org.apache.axis.soap.SOAPConstants;
028 import org.apache.axis.AxisFault;
029 import net.sf.cglib.core.Signature;
030
031 /**
032 * @version $Rev: 356022 $ $Date: 2005-12-11 12:58:34 -0800 (Sun, 11 Dec 2005) $
033 */
034 public class OperationInfo implements Serializable {
035
036 private final OperationDesc operationDesc;
037 private final boolean useSOAPAction;
038 private final String soapActionURI;
039 private final SOAPConstants soapVersion;
040 private final QName operationName;
041 private final String methodName;
042 private final String methodDesc;
043
044 public OperationInfo(OperationDesc operationDesc, boolean useSOAPAction, String soapActionURI, SOAPConstants soapVersion, QName operationName, String methodName, String methodDesc) {
045 this.operationDesc = operationDesc;
046 this.useSOAPAction = useSOAPAction;
047 this.soapActionURI = soapActionURI;
048 this.soapVersion = soapVersion;
049 this.operationName = operationName;
050 this.methodName = methodName;
051 this.methodDesc = methodDesc;
052 }
053
054 public Signature getSignature() {
055 return new Signature(methodName, methodDesc);
056 }
057
058 public OperationDesc getOperationDesc() {
059 return operationDesc;
060 }
061
062 public boolean isUseSOAPAction() {
063 return useSOAPAction;
064 }
065
066 public String getSoapActionURI() {
067 return soapActionURI;
068 }
069
070 public SOAPConstants getSoapVersion() {
071 return soapVersion;
072 }
073
074 public QName getOperationName() {
075 return operationName;
076 }
077
078 public void prepareCall(Call call) {
079 call.setOperation(operationDesc);
080 call.setUseSOAPAction(useSOAPAction);
081 call.setSOAPActionURI(soapActionURI);
082 call.setSOAPVersion(soapVersion);
083 call.setOperationName(operationName);
084 //GAH!!!
085 call.setOperationStyle(operationDesc.getStyle());
086 call.setOperationUse(operationDesc.getUse());
087 }
088
089 public Throwable unwrapFault(RemoteException re) {
090 if (re instanceof AxisFault && re.getCause() != null) {
091 Throwable t = re.getCause();
092 if (operationDesc.getFaultByClass(t.getClass()) != null) {
093 return t;
094 }
095 }
096 return re;
097 }
098 }