package org.jboss.axis.client;
import org.jboss.axis.AxisEngine;
import org.jboss.axis.AxisFault;
import org.jboss.axis.AxisProperties;
import org.jboss.axis.Constants;
import org.jboss.axis.Handler;
import org.jboss.axis.InternalException;
import org.jboss.axis.Message;
import org.jboss.axis.MessageContext;
import org.jboss.axis.attachments.Attachments;
import org.jboss.axis.description.FaultDesc;
import org.jboss.axis.description.OperationDesc;
import org.jboss.axis.description.ParameterDesc;
import org.jboss.axis.encoding.DeserializerFactory;
import org.jboss.axis.encoding.SerializerFactory;
import org.jboss.axis.encoding.TypeMapping;
import org.jboss.axis.encoding.TypeMappingRegistry;
import org.jboss.axis.encoding.XMLType;
import org.jboss.axis.encoding.ser.BaseDeserializerFactory;
import org.jboss.axis.encoding.ser.BaseSerializerFactory;
import org.jboss.axis.enums.Style;
import org.jboss.axis.enums.Use;
import org.jboss.axis.handlers.soap.SOAPService;
import org.jboss.axis.message.RPCElement;
import org.jboss.axis.message.RPCHeaderParam;
import org.jboss.axis.message.RPCParam;
import org.jboss.axis.message.SOAPBodyElementAxisImpl;
import org.jboss.axis.message.SOAPEnvelopeAxisImpl;
import org.jboss.axis.message.SOAPFaultImpl;
import org.jboss.axis.message.SOAPHeaderElementAxisImpl;
import org.jboss.axis.soap.SOAPConstants;
import org.jboss.axis.transport.http.HTTPTransport;
import org.jboss.axis.transport.java.JavaTransport;
import org.jboss.axis.transport.local.LocalTransport;
import org.jboss.axis.utils.ClassUtils;
import org.jboss.axis.utils.JavaUtils;
import org.jboss.axis.utils.Messages;
import org.jboss.axis.wsdl.symbolTable.BindingEntry;
import org.jboss.axis.wsdl.symbolTable.FaultInfo;
import org.jboss.axis.wsdl.symbolTable.Parameter;
import org.jboss.axis.wsdl.symbolTable.Parameters;
import org.jboss.axis.wsdl.symbolTable.SymbolTable;
import org.jboss.axis.wsdl.toJava.Utils;
import org.jboss.logging.Logger;
import javax.wsdl.Binding;
import javax.wsdl.BindingInput;
import javax.wsdl.BindingOperation;
import javax.wsdl.Operation;
import javax.wsdl.Part;
import javax.wsdl.Port;
import javax.wsdl.PortType;
import javax.wsdl.extensions.soap.SOAPAddress;
import javax.wsdl.extensions.soap.SOAPBody;
import javax.wsdl.extensions.soap.SOAPOperation;
import javax.xml.namespace.QName;
import javax.xml.rpc.JAXRPCException;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.holders.Holder;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.Vector;
public class Call implements javax.xml.rpc.Call
{
private static Logger log = Logger.getLogger(Call.class.getName());
private static Logger tlog = Logger.getLogger(Constants.TIME_LOG_CATEGORY);
private boolean parmAndRetReq = true;
private Service service;
private QName portName;
private QName operationName;
protected MessageContext msgContext;
private Hashtable myProperties = new Hashtable();
private String username;
private String password;
private boolean maintainSession;
private boolean useSOAPAction;
private String SOAPActionURI;
private Integer timeout;
private OperationDesc operation;
private boolean operationSetManually;
private boolean invokeOneWay;
private boolean isMsg;
private Transport transport;
private String transportName;
private HashMap outParams;
private ArrayList outParamsList;
private Vector headers;
protected Vector attachmentParts = new Vector();
public static final String SEND_TYPE_ATTR = "send_type_attr";
public static final String TRANSPORT_NAME = "transport_name";
public static final String TRANSPORT_PROPERTY = "java.protocol.handler.pkgs";
public static final String WSDL_SERVICE = "wsdl.service";
public static final String WSDL_PORT_NAME = "wsdl.portName";
public static final String JAXRPC_SERVICE = WSDL_SERVICE;
public static final String JAXRPC_PORTTYPE_NAME = WSDL_PORT_NAME;
public static final boolean FAULT_ON_NO_RESPONSE = false;
public static final String ATTACHMENT_ENCAPSULATION_FORMAT =
"attachment_encapsulation_format";
public static final String ATTACHMENT_ENCAPSULATION_FORMAT_MIME =
"axis.attachment.style.mime";
public static final String ATTACHMENT_ENCAPSULATION_FORMAT_DIME =
"axis.attachment.style.dime";
private static Hashtable transports = new Hashtable();
static ParameterMode[] modes = new ParameterMode[]{null,
ParameterMode.IN,
ParameterMode.OUT,
ParameterMode.INOUT};
private boolean encodingStyleExplicitlySet;
private boolean useExplicitlySet;
public Call(Service service)
{
this.service = service;
maintainSession = service.getMaintainSession();
initialize();
}
public Call(String url) throws MalformedURLException
{
this(new Service());
setTargetEndpointAddress(new URL(url));
}
public Call(URL url)
{
this(new Service());
setTargetEndpointAddress(url);
}
public void setProperty(String name, Object value)
{
if (name == null || value == null)
{
throw new JAXRPCException(Messages.getMessage(name == null ?
"badProp03" : "badProp04"));
}
else if (name.equals(USERNAME_PROPERTY))
{
if (!(value instanceof String))
{
throw new JAXRPCException(Messages.getMessage("badProp00", new String[]{
name, "java.lang.String", value.getClass().getName()}));
}
setUsername((String)value);
}
else if (name.equals(PASSWORD_PROPERTY))
{
if (!(value instanceof String))
{
throw new JAXRPCException(Messages.getMessage("badProp00", new String[]{
name, "java.lang.String", value.getClass().getName()}));
}
setPassword((String)value);
}
else if (name.equals(SESSION_MAINTAIN_PROPERTY))
{
if (!(value instanceof Boolean))
{
throw new JAXRPCException(Messages.getMessage("badProp00", new String[]
{name,
"java.lang.Boolean",
value.getClass().getName()}));
}
setMaintainSession(((Boolean)value).booleanValue());
}
else if (name.equals(OPERATION_STYLE_PROPERTY))
{
if (!(value instanceof String))
{
throw new JAXRPCException(Messages.getMessage("badProp00", new String[]{
name, "java.lang.String", value.getClass().getName()}));
}
setOperationStyle((String)value);
if (getOperationStyle() == Style.DOCUMENT ||
getOperationStyle() == Style.WRAPPED)
{
setOperationUse(Use.LITERAL_STR);
}
else if (getOperationStyle() == Style.RPC)
{
setOperationUse(Use.ENCODED_STR);
}
}
else if (name.equals(SOAPACTION_USE_PROPERTY))
{
if (!(value instanceof Boolean))
{
throw new JAXRPCException(Messages.getMessage("badProp00", new String[]
{name,
"java.lang.Boolean",
value.getClass().getName()}));
}
setUseSOAPAction(((Boolean)value).booleanValue());
}
else if (name.equals(SOAPACTION_URI_PROPERTY))
{
if (!(value instanceof String))
{
throw new JAXRPCException(Messages.getMessage("badProp00", new String[]
{name,
"java.lang.String",
value.getClass().getName()}));
}
setSOAPActionURI((String)value);
}
else if (name.equals(ENCODINGSTYLE_URI_PROPERTY))
{
if (!(value instanceof String))
{
throw new JAXRPCException(Messages.getMessage("badProp00", new String[]
{name,
"java.lang.String",
value.getClass().getName()}));
}
setEncodingStyle((String)value);
}
else if (name.equals(Stub.ENDPOINT_ADDRESS_PROPERTY))
{
if (!(value instanceof String))
{
throw new JAXRPCException(Messages.getMessage("badProp00", new String[]
{name,
"java.lang.String",
value.getClass().getName()}));
}
setTargetEndpointAddress((String)value);
}
else if (name.equals(TRANSPORT_NAME))
{
if (!(value instanceof String))
{
throw new JAXRPCException(Messages.getMessage("badProp00", new String[]{
name, "java.lang.String", value.getClass().getName()}));
}
transportName = (String)value;
if (transport != null)
transport.setTransportName((String)value);
}
else if (name.equals(ATTACHMENT_ENCAPSULATION_FORMAT))
{
if (!(value instanceof String))
{
throw new JAXRPCException(Messages.getMessage("badProp00", new String[]{
name, "java.lang.String", value.getClass().getName()}));
}
if (!value.equals(ATTACHMENT_ENCAPSULATION_FORMAT_MIME) &&
!value.equals(ATTACHMENT_ENCAPSULATION_FORMAT_DIME))
throw new JAXRPCException(Messages.getMessage("badattachmenttypeerr", new String[]{
(String)value, ATTACHMENT_ENCAPSULATION_FORMAT_MIME + " "
+ ATTACHMENT_ENCAPSULATION_FORMAT_DIME}));
}
else if (name.startsWith("java.") || name.startsWith("javax."))
{
throw new JAXRPCException(Messages.getMessage("badProp05", name));
}
myProperties.put(name, value);
}
public Object getProperty(String name)
{
if (Stub.ENDPOINT_ADDRESS_PROPERTY.equals(name))
{
return getTargetEndpointAddress();
}
else if (!isPropertySupported(name))
{
throw new JAXRPCException(name == null ?
Messages.getMessage("badProp03") :
Messages.getMessage("badProp05", name));
}
return myProperties.get(name);
}
public void removeProperty(String name)
{
if (name == null || !isPropertySupported(name))
{
throw new JAXRPCException(name == null ?
Messages.getMessage("badProp03") :
Messages.getMessage("badProp05", name));
}
myProperties.remove(name);
}
public void setScopedProperty(String name, Object value)
{
if (name == null || value == null)
{
throw new JAXRPCException(Messages.getMessage(name == null ?
"badProp03" : "badProp04"));
}
myProperties.put(name, value);
}
public Object getScopedProperty(String name)
{
if (name != null)
{
return myProperties.get(name);
}
return null;
}
public void removeScopedProperty(String name)
{
if (name == null || myProperties == null) return;
myProperties.remove(name);
}
private static ArrayList propertyNames = new ArrayList();
static
{
propertyNames.add(USERNAME_PROPERTY);
propertyNames.add(PASSWORD_PROPERTY);
propertyNames.add(SESSION_MAINTAIN_PROPERTY);
propertyNames.add(ATTACHMENT_ENCAPSULATION_FORMAT);
propertyNames.add(OPERATION_STYLE_PROPERTY);
propertyNames.add(SOAPACTION_USE_PROPERTY);
propertyNames.add(SOAPACTION_URI_PROPERTY);
propertyNames.add(ENCODINGSTYLE_URI_PROPERTY);
propertyNames.add(TRANSPORT_NAME);
propertyNames.add(ATTACHMENT_ENCAPSULATION_FORMAT);
}
public Iterator getPropertyNames()
{
return propertyNames.iterator();
}
public boolean isPropertySupported(String name)
{
boolean isSupported = false;
if (name != null)
{
isSupported = propertyNames.contains(name) || (!name.startsWith("java.") && !name.startsWith("javax."));
}
return isSupported;
}
public void setUsername(String username)
{
this.username = username;
}
public String getUsername()
{
return username;
}
public void setPassword(String password)
{
this.password = password;
}
public String getPassword()
{
return password;
}
public void setMaintainSession(boolean yesno)
{
maintainSession = yesno;
}
public boolean getMaintainSession()
{
return maintainSession;
}
public void setOperationStyle(String operationStyle)
{
Style style = Style.getStyle(operationStyle, Style.DEFAULT);
setOperationStyle(style);
}
public void setOperationStyle(Style operationStyle)
{
if (operation == null)
{
operation = new OperationDesc();
}
operation.setStyle(operationStyle);
if (!useExplicitlySet)
{
if (operationStyle != Style.RPC)
{
operation.setUse(Use.LITERAL);
}
}
if (!encodingStyleExplicitlySet)
{
String encStyle = "";
if (operationStyle == Style.RPC)
{
encStyle = getMessageContext().getSOAPConstants().getEncodingURI();
}
getMessageContext().setEncodingStyle(encStyle);
}
}
public Style getOperationStyle()
{
if (operation != null)
{
return operation.getStyle();
}
return Style.DEFAULT;
}
public void setOperationUse(String operationUse)
{
Use use = Use.getUse(operationUse, Use.DEFAULT);
setOperationUse(use);
}
public void setOperationUse(Use operationUse)
{
useExplicitlySet = true;
if (operation == null)
{
operation = new OperationDesc();
}
operation.setUse(operationUse);
if (!encodingStyleExplicitlySet)
{
String encStyle = "";
if (operationUse == Use.ENCODED)
{
encStyle = getMessageContext().getSOAPConstants().getEncodingURI();
}
getMessageContext().setEncodingStyle(encStyle);
}
}
public Use getOperationUse()
{
if (operation != null)
{
return operation.getUse();
}
return Use.DEFAULT;
}
public void setUseSOAPAction(boolean useSOAPAction)
{
this.useSOAPAction = useSOAPAction;
}
public boolean useSOAPAction()
{
return useSOAPAction;
}
public void setSOAPActionURI(String SOAPActionURI)
throws IllegalArgumentException
{
useSOAPAction = true;
this.SOAPActionURI = SOAPActionURI;
}
public String getSOAPActionURI()
{
return SOAPActionURI;
}
public void setEncodingStyle(String namespaceURI)
{
encodingStyleExplicitlySet = true;
getMessageContext().setEncodingStyle(namespaceURI);
}
public String getEncodingStyle()
{
return getMessageContext().getEncodingStyle();
}
public void setTargetEndpointAddress(String address)
{
URL urlAddress;
try
{
urlAddress = new URL(address);
}
catch (MalformedURLException mue)
{
throw new JAXRPCException(mue);
}
setTargetEndpointAddress(urlAddress);
}
public void setTargetEndpointAddress(java.net.URL address)
{
try
{
if (address == null)
{
setTransport(null);
return;
}
String protocol = address.getProtocol();
if (this.transport != null)
{
String oldAddr = this.transport.getUrl();
if (oldAddr != null && !oldAddr.equals(""))
{
URL tmpURL = new URL(oldAddr);
String oldProto = tmpURL.getProtocol();
if (protocol.equals(oldProto))
{
this.transport.setUrl(address.toString());
return;
}
}
}
Transport transport = service.getTransportForURL(address);
if (transport != null)
{
setTransport(transport);
}
else
{
transport = getTransportForProtocol(protocol);
if (transport == null)
throw new AxisFault("Call.setTargetEndpointAddress",
Messages.getMessage("noTransport01",
protocol), null, null);
transport.setUrl(address.toString());
setTransport(transport);
service.registerTransportForURL(address, transport);
}
}
catch (Exception exp)
{
log.error(Messages.getMessage("exception00"), exp);
}
}
public String getTargetEndpointAddress()
{
try
{
if (transport == null) return (null);
return (transport.getUrl());
}
catch (Exception exp)
{
return (null);
}
}
public Integer getTimeout()
{
return timeout;
}
public void setTimeout(Integer timeout)
{
this.timeout = timeout;
}
public boolean isParameterAndReturnSpecRequired(QName operationName)
{
return parmAndRetReq;
}
public void addParameter(QName paramName, QName xmlType,
ParameterMode parameterMode)
{
Class javaType = null;
TypeMapping tm = getTypeMapping();
if (tm != null)
{
javaType = tm.getClassForQName(xmlType);
}
addParameter(paramName, xmlType, javaType, parameterMode);
}
public void addParameter(QName paramName, QName xmlType,
Class javaType, ParameterMode parameterMode,
boolean inHeader, boolean outHeader)
{
if (operationSetManually)
{
throw new RuntimeException(Messages.getMessage("operationAlreadySet"));
}
if (operation == null)
operation = new OperationDesc();
ParameterDesc param = new ParameterDesc();
param.setQName(paramName);
param.setTypeQName(xmlType);
byte mode = ParameterDesc.IN;
if (parameterMode == ParameterMode.INOUT)
{
mode = ParameterDesc.INOUT;
}
else if (parameterMode == ParameterMode.OUT)
{
mode = ParameterDesc.OUT;
}
param.setMode(mode);
param.setJavaType(javaType);
param.setInHeader(inHeader);
param.setOutHeader(outHeader);
operation.addParameter(param);
parmAndRetReq = true;
}
public void addParameter(QName paramName, QName xmlType,
Class javaType, ParameterMode parameterMode)
{
if (operationSetManually)
{
throw new RuntimeException(Messages.getMessage("operationAlreadySet"));
}
if (operation == null)
operation = new OperationDesc();
ParameterDesc param = new ParameterDesc();
param.setQName(paramName);
param.setTypeQName(xmlType);
param.setJavaType(javaType);
byte mode = ParameterDesc.IN;
if (parameterMode == ParameterMode.INOUT)
{
mode = ParameterDesc.INOUT;
}
else if (parameterMode == ParameterMode.OUT)
{
mode = ParameterDesc.OUT;
}
param.setMode(mode);
operation.addParameter(param);
parmAndRetReq = true;
}
public void addParameter(String paramName, QName xmlType,
ParameterMode parameterMode)
{
Class javaType = null;
TypeMapping tm = getTypeMapping();
if (tm != null)
{
javaType = tm.getClassForQName(xmlType);
}
addParameter(new QName("", paramName), xmlType,
javaType, parameterMode);
}
public void addParameter(String paramName, QName xmlType,
Class javaType, ParameterMode parameterMode)
{
addParameter(new QName("", paramName), xmlType,
javaType, parameterMode);
}
public void addParameterAsHeader(QName paramName, QName xmlType,
Class javaType, ParameterMode parameterMode,
ParameterMode headerMode)
{
if (operationSetManually)
{
throw new RuntimeException(Messages.getMessage("operationAlreadySet"));
}
if (operation == null)
operation = new OperationDesc();
ParameterDesc param = new ParameterDesc();
param.setQName(paramName);
param.setTypeQName(xmlType);
param.setJavaType(javaType);
if (parameterMode == ParameterMode.IN)
{
param.setMode(ParameterDesc.IN);
}
else if (parameterMode == ParameterMode.INOUT)
{
param.setMode(ParameterDesc.INOUT);
}
else if (parameterMode == ParameterMode.OUT)
{
param.setMode(ParameterDesc.OUT);
}
if (headerMode == ParameterMode.IN)
{
param.setInHeader(true);
}
else if (headerMode == ParameterMode.INOUT)
{
param.setInHeader(true);
param.setOutHeader(true);
}
else if (headerMode == ParameterMode.OUT)
{
param.setOutHeader(true);
}
operation.addParameter(param);
parmAndRetReq = true;
}
public QName getParameterTypeByName(String paramName)
{
QName paramQName = new QName("", paramName);
return getParameterTypeByQName(paramQName);
}
public QName getParameterTypeByQName(QName paramQName)
{
ParameterDesc param = operation.getParamByQName(paramQName);
if (param != null)
{
return param.getTypeQName();
}
return (null);
}
public void setReturnType(QName returnType)
{
if (operationSetManually)
{
throw new RuntimeException(Messages.getMessage("operationAlreadySet"));
}
if (operation == null)
operation = new OperationDesc();
while (returnType != null && returnType.getLocalPart().startsWith(">"))
{
log.debug("Removing leading '>' from anonymous type" + returnType);
returnType = new QName(returnType.getNamespaceURI(), returnType.getLocalPart().substring(1));
}
operation.setReturnType(returnType);
TypeMapping tm = getTypeMapping();
operation.setReturnClass(tm.getClassForQName(returnType));
parmAndRetReq = true;
}
public void setReturnType(QName xmlType, Class javaType)
{
setReturnType(xmlType);
operation.setReturnClass(javaType);
}
public void setReturnTypeAsHeader(QName xmlType)
{
setReturnType(xmlType);
operation.setReturnHeader(true);
}
public void setReturnTypeAsHeader(QName xmlType, Class javaType)
{
setReturnType(xmlType, javaType);
operation.setReturnHeader(true);
}
public QName getReturnType()
{
if (operation != null)
return operation.getReturnType();
return null;
}
public void setReturnQName(QName qname)
{
if (operationSetManually)
{
throw new RuntimeException(Messages.getMessage("operationAlreadySet"));
}
if (operation == null)
operation = new OperationDesc();
operation.setReturnQName(qname);
}
public void setReturnClass(Class cls)
{
if (operationSetManually)
{
throw new RuntimeException(Messages.getMessage("operationAlreadySet"));
}
if (operation == null)
operation = new OperationDesc();
operation.setReturnClass(cls);
TypeMapping tm = getTypeMapping();
operation.setReturnType(tm.getTypeQName(cls));
parmAndRetReq = true;
}
public void removeAllParameters()
{
operation = new OperationDesc();
operationSetManually = false;
parmAndRetReq = true;
}
public QName getOperationName()
{
return (operationName);
}
public void setOperationName(QName opName)
{
operationName = opName;
}
public void setOperationName(String opName)
{
operationName = new QName(opName);
}
public void setOperation(String opName)
{
if (service == null)
throw new JAXRPCException(Messages.getMessage("noService04"));
this.setOperationName(opName);
this.setEncodingStyle(null);
this.setReturnType(null);
this.removeAllParameters();
javax.wsdl.Service wsdlService = service.getWSDLService();
if (wsdlService == null)
return;
Port port = wsdlService.getPort(portName.getLocalPart());
if (port == null)
throw new JAXRPCException(Messages.getMessage("noPort00", "" +
portName));
Binding binding = port.getBinding();
PortType portType = binding.getPortType();
if (portType == null)
throw new JAXRPCException(Messages.getMessage("noPortType00", "" +
portName));
List operations = portType.getOperations();
if (operations == null)
throw new JAXRPCException(Messages.getMessage("noOperation01",
opName));
Operation wsdlOp = null;
for (int i = 0; i < operations.size(); i++, wsdlOp = null)
{
wsdlOp = (Operation)operations.get(i);
String wsdlOpName = getWsdlOpName(opName);
if (wsdlOp.getName().equals(wsdlOpName)) break;
}
if (wsdlOp == null)
throw new UnsupportedOperationException(Messages.getMessage("noOperation01", opName));
opName = wsdlOp.getName();
List list = port.getExtensibilityElements();
String opStyle = null;
BindingOperation bop = binding.getBindingOperation(opName,
null, null);
if (bop == null)
throw new JAXRPCException(Messages.getMessage("noOperation02",
opName));
list = bop.getExtensibilityElements();
for (int i = 0; list != null && i < list.size(); i++)
{
Object obj = list.get(i);
if (obj instanceof SOAPOperation)
{
SOAPOperation sop = (SOAPOperation)obj;
opStyle = ((SOAPOperation)obj).getStyle();
String action = sop.getSoapActionURI();
if (action != null)
{
setUseSOAPAction(true);
setSOAPActionURI(action);
}
else
{
setUseSOAPAction(false);
setSOAPActionURI(null);
}
break;
}
}
BindingInput bIn = bop.getBindingInput();
if (bIn != null)
{
list = bIn.getExtensibilityElements();
for (int i = 0; list != null && i < list.size(); i++)
{
Object obj = list.get(i);
if (obj instanceof
javax.wsdl.extensions.mime.MIMEMultipartRelated)
{
javax.wsdl.extensions.mime.MIMEMultipartRelated mpr =
(javax.wsdl.extensions.mime.MIMEMultipartRelated)obj;
Object part = null;
List l = mpr.getMIMEParts();
for (int j = 0; l != null && j < l.size() && part == null; j++)
{
javax.wsdl.extensions.mime.MIMEPart mp
= (javax.wsdl.extensions.mime.MIMEPart)l.get(j);
List ll = mp.getExtensibilityElements();
for (int k = 0; ll != null && k < ll.size() && part == null;
k++)
{
part = ll.get(k);
if (!(part instanceof SOAPBody)) part = null;
}
}
if (null != part) obj = part;
}
if (obj instanceof SOAPBody)
{
SOAPBody sBody = (SOAPBody)obj;
list = sBody.getEncodingStyles();
if (list != null && list.size() > 0)
this.setEncodingStyle((String)list.get(0));
String ns = sBody.getNamespaceURI();
if (ns != null && !ns.equals(""))
setOperationName(new QName(ns, opName));
break;
}
}
}
Service service = this.getService();
SymbolTable symbolTable = service.getWSDLParser().getSymbolTable();
BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName());
Parameters parameters = bEntry.getParameters(bop.getOperation());
for (int j = 0; j < parameters.list.size(); ++j)
{
Parameter p = (Parameter)parameters.list.get(j);
QName paramType = Utils.getXSIType(p);
boolean isInHeader = p.isInHeader();
boolean isOutHeader = p.isOutHeader();
this.addParameter(p.getQName(), paramType, modes[p.getMode()], isInHeader, isOutHeader);
}
Map faultMap = bEntry.getFaults();
ArrayList faults = (ArrayList)faultMap.get(bop);
if (faults == null)
{
return;
}
for (Iterator faultIt = faults.iterator(); faultIt.hasNext();)
{
FaultInfo info = (FaultInfo)faultIt.next();
QName qname = info.getQName();
if (qname == null)
{
continue;
}
try
{
Class clazz = getTypeMapping().getClassForQName(info.getXMLType());
addFault(qname, clazz, info.getXMLType(), true);
}
catch (Exception e)
{
}
}
if (parameters.returnParam != null)
{
QName returnType = Utils.getXSIType(parameters.returnParam);
QName returnQName = parameters.returnParam.getQName();
String javaType = null;
if (parameters.returnParam.getMIMEInfo() != null)
{
javaType = "javax.activation.DataHandler";
}
else
{
javaType = parameters.returnParam.getType().getName();
}
if (javaType == null)
{
javaType = "";
}
else
{
javaType = javaType + ".class";
}
this.setReturnType(returnType);
try
{
this.setReturnClass(ClassUtils.forName(javaType));
}
catch (Exception e)
{
}
this.setReturnQName(returnQName);
}
else
{
this.setReturnType(XMLType.AXIS_VOID);
}
boolean hasMIME = Utils.hasMIME(bEntry, bop);
Use use = bEntry.getInputBodyType(bop.getOperation());
Style style = Style.getStyle(opStyle, bEntry.getBindingStyle());
if (use == Use.LITERAL)
{
setEncodingStyle(null);
setProperty(Call.SEND_TYPE_ATTR, Boolean.FALSE);
}
if (hasMIME || use == Use.LITERAL)
{
setProperty(AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
}
if (style == Style.DOCUMENT && symbolTable.isWrapped())
{
style = Style.WRAPPED;
}
if (style == Style.WRAPPED)
{
Map partsMap = bop.getOperation().getInput().getMessage().getParts();
Part p = (Part)partsMap.values().iterator().next();
QName q = p.getElementName();
setOperationName(q);
}
else
{
QName elementQName =
Utils.getOperationQName(bop, bEntry, symbolTable);
if (elementQName != null)
{
setOperationName(elementQName);
}
}
parmAndRetReq = false;
return;
}
private void addParameter(QName paramName, QName xmlType,
ParameterMode parameterMode, boolean inHeader, boolean outHeader)
{
Class javaType = null;
TypeMapping tm = getTypeMapping();
if (tm != null)
{
javaType = tm.getClassForQName(xmlType);
}
if (parameterMode != ParameterMode.IN && javaType != null && !Holder.class.isAssignableFrom(javaType))
javaType = JavaUtils.getHolderType(javaType);
addParameter(paramName, xmlType, javaType, parameterMode, inHeader, outHeader);
}
protected String getWsdlOpName(String javaOpName)
{
return javaOpName;
}
public void setOperation(QName portName, String opName)
{
if (service == null)
throw new JAXRPCException(Messages.getMessage("noService04"));
this.setPortName(portName);
this.setOperationName(opName);
this.setEncodingStyle(null);
this.setReturnType(null);
this.removeAllParameters();
javax.wsdl.Service wsdlService = service.getWSDLService();
if (wsdlService == null)
return;
this.setTargetEndpointAddress((URL)null);
Port port = wsdlService.getPort(portName.getLocalPart());
if (port == null)
throw new JAXRPCException(Messages.getMessage("noPort00", "" +
portName));
Binding binding = port.getBinding();
PortType portType = binding.getPortType();
if (portType == null)
throw new JAXRPCException(Messages.getMessage("noPortType00", "" +
portName));
List list = port.getExtensibilityElements();
for (int i = 0; list != null && i < list.size(); i++)
{
Object obj = list.get(i);
if (obj instanceof SOAPAddress)
{
try
{
SOAPAddress addr = (SOAPAddress)obj;
URL url = new URL(addr.getLocationURI());
this.setTargetEndpointAddress(url);
}
catch (Exception exp)
{
throw new JAXRPCException(Messages.getMessage("cantSetURI00", "" + exp));
}
}
}
BindingOperation bop = binding.getBindingOperation(opName,
null, null);
if (bop == null)
throw new JAXRPCException(Messages.getMessage("noOperation02",
opName));
list = bop.getExtensibilityElements();
for (int i = 0; list != null && i < list.size(); i++)
{
Object obj = list.get(i);
if (obj instanceof SOAPOperation)
{
SOAPOperation sop = (SOAPOperation)obj;
String action = sop.getSoapActionURI();
if (action != null)
{
setUseSOAPAction(true);
setSOAPActionURI(action);
}
else
{
setUseSOAPAction(false);
setSOAPActionURI(null);
}
break;
}
}
setOperation(opName);
}
public QName getPortName()
{
return (portName);
}
public void setPortName(QName portName)
{
this.portName = portName;
}
public QName getPortTypeName()
{
return portName == null ? new QName("") : portName;
}
public void setPortTypeName(QName portType)
{
setPortName(portType);
}
public void setSOAPVersion(SOAPConstants soapConstants)
{
getMessageContext().setSOAPConstants(soapConstants);
}
public Object invoke(QName operationName, Object[] params)
throws java.rmi.RemoteException
{
QName origOpName = this.operationName;
this.operationName = operationName;
try
{
return this.invoke(params);
}
catch (AxisFault af)
{
this.operationName = origOpName;
if (af.detail != null && af.detail instanceof RemoteException)
{
throw ((RemoteException)af.detail);
}
throw af;
}
catch (java.rmi.RemoteException re)
{
this.operationName = origOpName;
throw re;
}
catch (RuntimeException re)
{
this.operationName = origOpName;
throw re;
}
catch (Error e)
{
this.operationName = origOpName;
throw e;
}
}
public Object invoke(Object[] params) throws java.rmi.RemoteException
{
return invokeInternal(params);
}
private Object invokeInternal(Object[] params) throws java.rmi.RemoteException
{
long t0 = 0, t1 = 0;
if (tlog.isDebugEnabled())
{
t0 = System.currentTimeMillis();
}
SOAPEnvelopeAxisImpl env = null;
boolean isSOAPBodyElement = (params != null && params.length == 1 && params[0] instanceof SOAPBodyElementAxisImpl);
if (isSOAPBodyElement)
{
isMsg = true;
SOAPBodyElementAxisImpl sbElement = (SOAPBodyElementAxisImpl)params[0];
if (sbElement.getParentElement() != null && sbElement.getParentElement().getParentElement() != null)
{
env = (SOAPEnvelopeAxisImpl)sbElement.getParentElement().getParentElement();
}
else
{
env = new SOAPEnvelopeAxisImpl(getMessageContext().getSOAPConstants(), getMessageContext().getSchemaVersion());
env.addBodyElement(sbElement);
}
Message msg = new Message(env);
setRequestMessage(msg);
invoke();
msg = getMessageContext().getResponseMessage();
if (msg == null)
{
if (FAULT_ON_NO_RESPONSE)
{
throw new AxisFault(Messages.getMessage("nullResponse00"));
}
else
{
return null;
}
}
env = msg.getSOAPEnvelope();
Vector bodyElements = env.getBodyElements();
return (bodyElements.size() > 0 ? bodyElements.get(0) : null);
}
if (operationName == null)
throw new AxisFault(Messages.getMessage("noOperation00"));
try
{
Object res = this.invoke(operationName.getNamespaceURI(),
operationName.getLocalPart(), params);
if (tlog.isDebugEnabled())
{
t1 = System.currentTimeMillis();
tlog.debug("axis.Call.invoke: " + (t1 - t0) + " " + operationName);
}
return res;
}
catch (AxisFault af)
{
if (af.detail != null && af.detail instanceof RemoteException)
{
throw ((RemoteException)af.detail);
}
throw af;
}
catch (RuntimeException ex)
{
throw ex;
}
catch (Exception exp)
{
log.debug(Messages.getMessage("toAxisFault00"), exp);
throw new AxisFault(Messages.getMessage("errorInvoking00", "\n" + exp));
}
}
public void invokeOneWay(Object[] params)
{
try
{
invokeOneWay = true;
invokeInternal(params);
}
catch (Exception exp)
{
throw new JAXRPCException(exp.toString());
}
finally
{
invokeOneWay = false;
}
}
public SOAPEnvelopeAxisImpl invoke(SOAPEnvelopeAxisImpl env)
throws java.rmi.RemoteException
{
try
{
Message msg = null;
msg = new Message(env);
setRequestMessage(msg);
invoke();
msg = getMessageContext().getResponseMessage();
if (msg == null)
{
if (FAULT_ON_NO_RESPONSE)
{
throw new AxisFault(Messages.getMessage("nullResponse00"));
}
else
{
return null;
}
}
return (msg.getSOAPEnvelope());
}
catch (AxisFault fault)
{
throw (AxisFault)fault;
}
catch (Exception ex)
{
log.error(Messages.getMessage("toAxisFault00"), ex);
throw AxisFault.makeFault(ex);
}
}
public static void setTransportForProtocol(String protocol,
Class transportClass)
{
if (Transport.class.isAssignableFrom(transportClass))
transports.put(protocol, transportClass);
else
throw new InternalException(transportClass.toString());
}
public static synchronized void initialize()
{
addTransportPackage("transport");
setTransportForProtocol("java", JavaTransport.class);
setTransportForProtocol("local", LocalTransport.class);
setTransportForProtocol("http", HTTPTransport.class);
setTransportForProtocol("https", HTTPTransport.class);
}
private static ArrayList transportPackages = null;
public static synchronized void addTransportPackage(String packageName)
{
if (transportPackages == null)
{
transportPackages = new ArrayList();
String currentPackages =
AxisProperties.getProperty(TRANSPORT_PROPERTY);
if (currentPackages != null)
{
StringTokenizer tok = new StringTokenizer(currentPackages,
"|");
while (tok.hasMoreTokens())
{
transportPackages.add(tok.nextToken());
}
}
}
if (transportPackages.contains(packageName))
return;
transportPackages.add(packageName);
StringBuffer currentPackages = new StringBuffer();
for (Iterator i = transportPackages.iterator(); i.hasNext();)
{
String thisPackage = (String)i.next();
currentPackages.append(thisPackage);
currentPackages.append('|');
}
System.setProperty(TRANSPORT_PROPERTY, currentPackages.toString());
}
private Object[] getParamList(Object[] params)
{
int numParams = 0;
if (log.isDebugEnabled())
{
log.debug("operation=" + operation);
if (operation != null)
log.debug("operation.getNumParams()=" +
operation.getNumParams());
}
if (operation == null || operation.getNumParams() == 0)
return (params);
numParams = operation.getNumInParams();
if (operation.getStyle() == Style.DOCUMENT && params == null && numParams == 1)
{
ParameterDesc param = operation.getParameter(0);
Class javaType = param.getJavaType();
if (javaType != null)
{
try
{
Object obj = javaType.newInstance();
params = new Object[]{obj};
}
catch (Exception e)
{
log.warn("Cannot instanciate: " + javaType);
}
}
}
if (params == null || numParams != params.length)
throw new JAXRPCException("Parameter count mismatch: " + numParams);
log.debug("getParamList number of params: " + params.length);
Vector result = new Vector();
int j = 0;
ArrayList parameters = operation.getParameters();
for (int i = 0; i < parameters.size(); i++)
{
ParameterDesc param = (ParameterDesc)parameters.get(i);
if (param.getMode() != ParameterDesc.OUT)
{
QName paramQName = param.getQName();
RPCParam rpcParam = null;
Object p = params[j++];
if (p instanceof RPCParam)
{
rpcParam = (RPCParam)p;
}
else
{
rpcParam = new RPCParam(paramQName.getNamespaceURI(),
paramQName.getLocalPart(),
p);
}
rpcParam.setParamDesc(param);
if (param.isInHeader())
{
addHeader(new RPCHeaderParam(rpcParam));
}
else
{
result.add(rpcParam);
}
}
}
return (result.toArray());
}
public void setTransport(Transport trans)
{
transport = trans;
if (log.isDebugEnabled())
log.debug(Messages.getMessage("transport00", "" + transport));
}
public Transport getTransportForProtocol(String protocol)
{
Class transportClass = (Class)transports.get(protocol);
Transport ret = null;
if (transportClass != null)
{
try
{
ret = (Transport)transportClass.newInstance();
}
catch (InstantiationException e)
{
}
catch (IllegalAccessException e)
{
}
}
return ret;
}
public void setRequestMessage(Message msg)
{
addAttachmentParts(msg);
getMessageContext().setRequestMessage(msg);
}
protected void addAttachmentParts(Message msg)
{
String attachformat = (String)getProperty(ATTACHMENT_ENCAPSULATION_FORMAT);
if (attachformat != null)
{
Attachments attachments = msg.getAttachmentsImpl();
if (attachments != null)
{
if (attachformat.equals(ATTACHMENT_ENCAPSULATION_FORMAT_MIME))
attachments.setSendType(Attachments.SEND_TYPE_MIME);
else if (attachformat.equals(ATTACHMENT_ENCAPSULATION_FORMAT_DIME))
attachments.setSendType(Attachments.SEND_TYPE_DIME);
}
}
if (attachmentParts.isEmpty() == false)
{
try
{
Attachments attachments = msg.getAttachmentsImpl();
if (attachments != null)
attachments.setAttachmentParts(attachmentParts);
}
catch (AxisFault ex)
{
log.info(Messages.getMessage("axisFault00"), ex);
throw new RuntimeException(ex.getMessage());
}
}
attachmentParts.clear();
}
public Message getResponseMessage()
{
return getMessageContext().getResponseMessage();
}
public MessageContext getMessageContext()
{
if (msgContext == null)
msgContext = new MessageContext(service.getEngine());
return msgContext;
}
public void addHeader(SOAPHeaderElementAxisImpl header)
{
if (headers == null)
{
headers = new Vector();
}
headers.add(header);
}
public void clearHeaders()
{
headers = null;
}
public TypeMapping getTypeMapping()
{
TypeMappingRegistry tmr = getMessageContext().getTypeMappingRegistry();
return tmr.getOrMakeTypeMapping(getEncodingStyle());
}
public void registerTypeMapping(Class javaType, QName xmlType,
SerializerFactory sf,
DeserializerFactory df)
{
registerTypeMapping(javaType, xmlType, sf, df, true);
}
public void registerTypeMapping(Class javaType, QName xmlType,
SerializerFactory sf,
DeserializerFactory df,
boolean force)
{
TypeMapping tm = getTypeMapping();
if (!force && tm.isRegistered(javaType, xmlType))
return;
tm.register(javaType, xmlType, sf, df);
}
public void registerTypeMapping(Class javaType, QName xmlType,
Class sfClass, Class dfClass)
{
registerTypeMapping(javaType, xmlType, sfClass, dfClass, true);
}
public void registerTypeMapping(Class javaType,
QName xmlType,
Class sfClass,
Class dfClass,
boolean force)
{
SerializerFactory sf =
BaseSerializerFactory.createFactory(sfClass, javaType, xmlType);
DeserializerFactory df =
BaseDeserializerFactory.createFactory(dfClass,
javaType,
xmlType);
if (sf != null || df != null)
{
registerTypeMapping(javaType, xmlType, sf, df, force);
}
}
public Object invoke(String namespace, String method, Object[] args)
throws AxisFault
{
if (log.isDebugEnabled())
{
log.debug("Enter: Call::invoke(ns, meth, args)");
}
if (getReturnType() != null && args != null && args.length != 0
&& operation.getNumParams() == 0)
{
throw new AxisFault(Messages.getMessage("mustSpecifyParms"));
}
RPCElement body = new RPCElement(namespace, method, getParamList(args));
Object ret = invoke(body);
if (log.isDebugEnabled())
{
log.debug("Exit: Call::invoke(ns, meth, args)");
}
return ret;
}
public Object invoke(String method, Object[] args) throws AxisFault
{
return invoke("", method, args);
}
public Object invoke(RPCElement body) throws AxisFault
{
if (log.isDebugEnabled())
{
log.debug("Enter: Call::invoke(RPCElement)");
}
if (!invokeOneWay && operation != null &&
operation.getNumParams() > 0 && getReturnType() == null)
{
log.error(Messages.getMessage("mustSpecifyReturnType"));
}
SOAPEnvelopeAxisImpl reqEnv =
new SOAPEnvelopeAxisImpl(getMessageContext().getSOAPConstants(),
getMessageContext().getSchemaVersion());
SOAPEnvelopeAxisImpl resEnv = null;
Message reqMsg = new Message(reqEnv);
Message resMsg = null;
Vector resArgs = null;
Object result = null;
try
{
String encodingStyle = getEncodingStyle();
String bodyEncStyle = reqEnv.getBody().getEncodingStyle();
if (bodyEncStyle.equals(encodingStyle) == false)
{
if (bodyEncStyle.equals(""))
reqEnv.getBody().setEncodingStyle(encodingStyle);
else
log.warn("Mixed encoding styles are not supported: " + bodyEncStyle + "!=" + encodingStyle);
}
setRequestMessage(reqMsg);
reqEnv.addBodyElement(body);
reqEnv.setMessageType(Message.REQUEST);
invoke();
}
catch (Exception e)
{
log.debug(Messages.getMessage("toAxisFault00"), e);
throw AxisFault.makeFault(e);
}
resMsg = getMessageContext().getResponseMessage();
if (resMsg == null)
{
if (FAULT_ON_NO_RESPONSE)
{
throw new AxisFault(Messages.getMessage("nullResponse00"));
}
else
{
return null;
}
}
resEnv = resMsg.getSOAPEnvelope();
SOAPBodyElementAxisImpl bodyEl = resEnv.getFirstBody();
if (bodyEl == null)
{
return null;
}
if (bodyEl instanceof RPCElement)
{
try
{
resArgs = ((RPCElement)bodyEl).getParams();
}
catch (Exception e)
{
log.error(Messages.getMessage("exception00"), e);
throw AxisFault.makeFault(e);
}
if (resArgs != null && resArgs.size() > 0)
{
int outParamStart = 0;
boolean findReturnParam = false;
QName returnParamQName = null;
if (operation != null)
returnParamQName = operation.getReturnQName();
if (!XMLType.AXIS_VOID.equals(getReturnType()))
{
if (returnParamQName == null)
{
RPCParam param = (RPCParam)resArgs.get(0);
result = param.getValue();
outParamStart = 1;
}
else
{
findReturnParam = true;
}
}
for (int i = outParamStart; i < resArgs.size(); i++)
{
RPCParam param = (RPCParam)resArgs.get(i);
Class javaType = getJavaTypeForQName(param.getQName());
Object value = param.getValue();
if (javaType != null && value != null &&
!javaType.isAssignableFrom(value.getClass()))
{
value = JavaUtils.convert(value, javaType);
}
if (javaType == null && value != null)
{
if (value.getClass().isArray())
{
if (!value.getClass().getComponentType().isPrimitive())
{
int len = java.lang.reflect.Array.getLength(value);
Class type = null;
for (int x = 0; x < len; x++)
{
Object o = java.lang.reflect.Array.get(value, x);
if (o != null)
{
if (type == null)
{
type = o.getClass();
}
else
{
if (!type.getName().equals(o.getClass().getName()))
{
type = null;
break;
}
}
}
}
if (type != null)
{
Object convertedArray = java.lang.reflect.Array.newInstance(type, len);
System.arraycopy(value, 0, convertedArray, 0, len);
value = convertedArray;
}
}
}
}
if (findReturnParam && returnParamQName.equals(param.getQName()))
{
result = value;
findReturnParam = false;
}
else
{
outParams.put(param.getQName(), value);
outParamsList.add(value);
}
}
if (findReturnParam)
{
Iterator it = outParams.keySet().iterator();
while (it.hasNext() && findReturnParam)
{
QName qname = (QName)it.next();
ParameterDesc paramDesc = operation.getOutputParamByQName(qname);
if (paramDesc == null)
{
findReturnParam = false;
result = outParams.remove(qname);
}
}
}
if (findReturnParam)
{
String returnParamName = returnParamQName.toString();
throw new AxisFault(Messages.getMessage("noReturnParam",
returnParamName));
}
}
}
else
{
try
{
result = bodyEl.getValueAsType(getReturnType());
}
catch (Exception e)
{
result = bodyEl;
}
}
if (log.isDebugEnabled())
{
log.debug("Exit: Call::invoke(RPCElement)");
}
if (operation != null && operation.getReturnClass() != null)
{
result = JavaUtils.convert(result, operation.getReturnClass());
}
return (result);
}
private Class getJavaTypeForQName(QName name)
{
if (operation == null) return null;
Class javaType = null;
ParameterDesc param = operation.getOutputParamByQName(name);
if (param != null)
{
javaType = param.getJavaType();
log.debug("getJavaTypeForQName: " + name + " -> " + javaType);
}
else
{
log.debug("No output parameter for name: " + name);
}
return javaType;
}
public void setOption(String name, Object value)
{
service.getEngine().setOption(name, value);
}
public void invoke() throws AxisFault
{
if (log.isDebugEnabled())
{
log.debug("Enter: Call::invoke()");
}
outParams = new HashMap();
outParamsList = new ArrayList();
Message reqMsg = null;
SOAPEnvelopeAxisImpl reqEnv = null;
getMessageContext().reset();
getMessageContext().setResponseMessage(null);
getMessageContext().setProperty(MessageContext.CALL, this);
getMessageContext().setProperty(WSDL_SERVICE, service);
getMessageContext().setProperty(WSDL_PORT_NAME, getPortName());
if (isMsg)
getMessageContext().setProperty(MessageContext.IS_MSG, "true");
if (username != null)
{
getMessageContext().setUsername(username);
}
if (password != null)
{
getMessageContext().setPassword(password);
}
getMessageContext().setMaintainSession(maintainSession);
if (operation != null)
{
getMessageContext().setOperation(operation);
operation.setStyle(getOperationStyle());
operation.setUse(getOperationUse());
}
if (useSOAPAction)
{
getMessageContext().setUseSOAPAction(true);
}
if (SOAPActionURI != null)
{
getMessageContext().setSOAPActionURI(SOAPActionURI);
}
if (timeout != null)
{
getMessageContext().setTimeout(timeout.intValue());
}
if (myService != null)
{
getMessageContext().setService(myService);
}
else
{
if (portName != null)
{
getMessageContext().setTargetService(portName.getLocalPart());
}
else
{
reqMsg = getMessageContext().getRequestMessage();
if (reqMsg != null)
{
reqEnv = reqMsg.getSOAPEnvelope();
SOAPBodyElementAxisImpl body = reqEnv.getFirstBody();
if (body != null)
{
if (body.getNamespaceURI() == null)
{
throw new AxisFault("Call.invoke",
Messages.getMessage("cantInvoke00", body.getName()),
null, null);
}
else
{
getMessageContext().setTargetService(body.getNamespaceURI());
}
}
}
}
SOAPService svc = getMessageContext().getService();
if (svc != null)
{
svc.setPropertyParent(myProperties);
}
else
{
getMessageContext().setPropertyParent(myProperties);
}
}
if (log.isDebugEnabled())
{
log.debug(Messages.getMessage("targetService",
getMessageContext().getTargetService()));
}
Message requestMessage = getMessageContext().getRequestMessage();
if (requestMessage != null)
{
reqEnv = requestMessage.getSOAPEnvelope();
for (int i = 0; headers != null && i < headers.size(); i++)
{
SOAPHeaderElementAxisImpl header = (SOAPHeaderElementAxisImpl)headers.get(i);
reqEnv.addHeader(header);
}
}
if (transport != null)
{
transport.setupMessageContext(msgContext, this, service.getEngine());
}
else
{
getMessageContext().setTransportName(transportName);
}
if (!invokeOneWay)
{
invokeEngine(msgContext);
}
else
{
invokeEngineOneWay(msgContext);
}
if (log.isDebugEnabled())
{
log.debug("Exit: Call::invoke()");
}
}
private void invokeEngine(MessageContext msgContext) throws AxisFault
{
service.getEngine().invoke(msgContext);
if (transport != null)
transport.processReturnedMessageContext(msgContext);
Message resMsg = getMessageContext().getResponseMessage();
if (resMsg == null)
{
if (FAULT_ON_NO_RESPONSE)
{
throw new AxisFault(Messages.getMessage("nullResponse00"));
}
else
{
return;
}
}
resMsg.setMessageType(Message.RESPONSE);
SOAPEnvelopeAxisImpl resEnv = resMsg.getSOAPEnvelope();
SOAPBodyElementAxisImpl respBody = resEnv.getFirstBody();
if (respBody instanceof SOAPFaultImpl)
{
if (operation == null ||
operation.getReturnClass() == null ||
operation.getReturnClass() !=
javax.xml.soap.SOAPMessage.class)
throw ((SOAPFaultImpl)respBody).getFault();
}
}
private void invokeEngineOneWay(final MessageContext msgContext)
{
Runnable runnable = new Runnable()
{
public void run()
{
try
{
service.getEngine().invoke(msgContext);
}
catch (AxisFault af)
{
log.debug(Messages.getMessage("exceptionPrinting"), af);
}
}
};
Thread thread = new Thread(runnable);
thread.start();
}
public Map getOutputParams()
{
if (outParams != null)
{
return outParams;
}
else
{
throw new JAXRPCException("Cannot get output parameters before invoke is called.");
}
}
public List getOutputValues()
{
return outParamsList;
}
public Service getService()
{
return this.service;
}
private SOAPService myService = null;
public void setSOAPService(SOAPService service)
{
myService = service;
if (service != null)
{
service.setPropertyParent(myProperties);
service.setEngine(this.service.getAxisClient());
}
}
public void setClientHandlers(Handler reqHandler, Handler respHandler)
{
setSOAPService(new SOAPService(reqHandler, null, respHandler));
}
public void addAttachmentPart(Object attachment)
{
attachmentParts.add(attachment);
}
public void addFault(QName qname, Class cls,
QName xmlType, boolean isComplex)
{
if (operationSetManually)
{
throw new RuntimeException(Messages.getMessage("operationAlreadySet"));
}
if (operation == null)
operation = new OperationDesc();
FaultDesc fault = new FaultDesc();
fault.setQName(qname);
fault.setClassName(cls.getName());
fault.setXmlType(xmlType);
fault.setComplex(isComplex);
operation.addFault(fault);
}
public void setOperation(OperationDesc operation)
{
this.operation = operation;
operationSetManually = true;
}
public OperationDesc getOperation()
{
return operation;
}
public void clearOperation()
{
operation = null;
operationSetManually = false;
}
}