org.apache.axis2.wsdl.template.java.InterfaceImplementationTemplate.xsl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of axis2-codegen Show documentation
Show all versions of axis2-codegen Show documentation
Axis2 Code Generation module
/**
* .java
*
* This file was auto-generated from WSDL
* by the Apache Axis2 version: #axisVersion# #today#
*/
package ;
/*
* java implementation
*/
.
public class extends org.apache.axis2.client.Stub
implements {
protected org.apache.axis2.description.AxisOperation[] _operations;
//hashmaps to keep the fault mapping
private java.util.HashMap faultExceptionNameMap = new java.util.HashMap();
private java.util.HashMap faultExceptionClassNameMap = new java.util.HashMap();
private java.util.HashMap faultMessageMap = new java.util.HashMap();
private static int counter = 0;
private static synchronized java.lang.String getUniqueSuffix(){
// reset the counter if it is greater than 99999
if (counter > 99999){
counter = 0;
}
counter = counter + 1;
return java.lang.Long.toString(java.lang.System.currentTimeMillis()) + "_" + counter;
}
private void populateAxisService() throws org.apache.axis2.AxisFault {
//creating the Service with a unique name
_service = new org.apache.axis2.description.AxisService(" " + getUniqueSuffix());
addAnonymousOperations();
//creating the operations
org.apache.axis2.description.AxisOperation __operation;
_operations = new org.apache.axis2.description.AxisOperation[ ];
__operation = new org.apache.axis2.description.OutOnlyAxisOperation();
__operation = new org.apache.axis2.description.RobustOutOnlyAxisOperation();
__operation = new org.apache.axis2.description.OutInAxisOperation();
__operation.setName(new javax.xml.namespace.QName(" ", " "));
_service.addOperation(__operation);
(__operation).getMessage(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_OUT_VALUE).getPolicySubject().attachPolicy(getPolicy(" "));
(__operation).getMessage(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE).getPolicySubject().attachPolicy(getPolicy(" "));
_operations[ ]=__operation;
}
//populates the faults
private void populateFaults(){
faultExceptionNameMap.put(new org.apache.axis2.client.FaultMapKey(new javax.xml.namespace.QName(" "," "), " ")," ");
faultExceptionClassNameMap.put(new org.apache.axis2.client.FaultMapKey(new javax.xml.namespace.QName(" "," "), " ")," ");
faultMessageMap.put(new org.apache.axis2.client.FaultMapKey(new javax.xml.namespace.QName(" "," "), " ")," ");
}
/**
*Constructor that takes in a configContext
*/
public (org.apache.axis2.context.ConfigurationContext configurationContext,
java.lang.String targetEndpoint)
throws org.apache.axis2.AxisFault {
this(configurationContext,targetEndpoint,false);
}
/**
* Constructor that takes in a configContext and useseperate listner
*/
public (org.apache.axis2.context.ConfigurationContext configurationContext,
java.lang.String targetEndpoint, boolean useSeparateListener)
throws org.apache.axis2.AxisFault {
//To populate AxisService
populateAxisService();
populateFaults();
_serviceClient = new org.apache.axis2.client.ServiceClient(configurationContext,_service);
_service.applyPolicy();
_serviceClient.getOptions().setTo(new org.apache.axis2.addressing.EndpointReference(
targetEndpoint));
_serviceClient.getOptions().setUseSeparateListener(useSeparateListener);
//Set the soap version
_serviceClient.getOptions().setSoapVersionURI(org.apache.axiom.soap.SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
}
/**
* Default Constructor
*/
public (org.apache.axis2.context.ConfigurationContext configurationContext) throws org.apache.axis2.AxisFault {
this(configurationContext," " );
//this(configurationContext," " );
}
/**
* Default Constructor
*/
public () throws org.apache.axis2.AxisFault {
this(" " );
//this(" " );
}
/**
* Constructor taking the target endpoint
*/
public (java.lang.String targetEndpoint) throws org.apache.axis2.AxisFault {
this(null,targetEndpoint);
}
/**
* Auto generated method signature
*
* @see . #
* @param
* @throws :
*/
public void
(
,
,
)
public
void
void
(
,
,
,
)
throws java.rmi.RemoteException
,
{
org.apache.axis2.context.MessageContext _messageContext = null;
try{
org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[ ].getName());
_operationClient.getOptions().setAction(" ");
_operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
addPropertyToOperationClient(_operationClient, , );
// create a message context
_messageContext = new org.apache.axis2.context.MessageContext();
// create SOAP envelope with that payload
org.apache.axiom.soap.SOAPEnvelope env = null;
env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
wrap ( ),
optimizeContent(new javax.xml.namespace.QName(" ",
" ")));
dummyWrappedType = null;
env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
,
dummyWrappedType,
optimizeContent(new javax.xml.namespace.QName(" ",
" ")));
env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
,
optimizeContent(new javax.xml.namespace.QName(" ", " ")),
new javax.xml.namespace.QName(" ", " ")
null
);
env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()));
env.build();
// add the children only if the parameter is not null
if ( !=null){
org.apache.axiom.om.OMElement omElement = toOM( , optimizeContent(new javax.xml.namespace.QName(" ", " ")));
addHeader(omElement ,env,true);
org.apache.axiom.om.OMElement omElement = toOM( , optimizeContent(new javax.xml.namespace.QName(" ", " ")));
addHeader(omElement ,env);
}
// add the children only if the parameter is not null
if ( !=null){
addHttpHeader(_messageContext," ", );
}
//Unknown style detected !! No code is generated
//Style is taken to be "rpc". No input parameters
org.apache.axiom.soap.SOAPFactory factory = getFactory(_operationClient.getOptions().getSoapVersionURI());
env = factory.getDefaultEnvelope();
env.getBody().addChild(factory.createOMElement(" ", " ", ""));
//Style is taken to be "document". No input parameters
// according to the WS-Basic profile in this case we have to send an empty soap message
org.apache.axiom.soap.SOAPFactory factory = getFactory(_operationClient.getOptions().getSoapVersionURI());
env = factory.getDefaultEnvelope();
//Unknown style detected !! No code is generated
//adding SOAP soap_headers
_serviceClient.addHeadersToEnvelope(env);
// set the message context with that soap envelope
_messageContext.setEnvelope(env);
// add the message contxt to the operation client
_operationClient.addMessageContext(_messageContext);
//execute the operation client
_operationClient.execute(true);
return;
org.apache.axis2.context.MessageContext _returnMessageContext = _operationClient.getMessageContext(
org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE);
org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope();
return toByte(_returnEnv.getBody().getFirstElement());
return toChar(_returnEnv.getBody().getFirstElement());
return toDouble(_returnEnv.getBody().getFirstElement());
return toFloat(_returnEnv.getBody().getFirstElement());
return toInt(_returnEnv.getBody().getFirstElement());
return toLong(_returnEnv.getBody().getFirstElement());
return toShort(_returnEnv.getBody().getFirstElement());
return toBoolean(_returnEnv.getBody().getFirstElement());
java.lang.Object object = fromOM(
_returnEnv.getBody().getFirstElement() ,
.class);
return get (( )object);
return get (( )object);
return;
return ( )object;
//Unknown style detected !! No code is generated
}catch(org.apache.axis2.AxisFault f){
org.apache.axiom.om.OMElement faultElt = f.getDetail();
if (faultElt!=null){
if (faultExceptionNameMap.containsKey(new org.apache.axis2.client.FaultMapKey(faultElt.getQName()," "))){
//make the fault by reflection
try{
java.lang.String exceptionClassName = (java.lang.String)faultExceptionClassNameMap.get(new org.apache.axis2.client.FaultMapKey(faultElt.getQName()," "));
java.lang.Class exceptionClass = java.lang.Class.forName(exceptionClassName);
java.lang.reflect.Constructor constructor = exceptionClass.getConstructor(java.lang.String.class);
java.lang.Exception ex = (java.lang.Exception) constructor.newInstance(f.getMessage());
//message class
java.lang.String messageClassName = (java.lang.String)faultMessageMap.get(new org.apache.axis2.client.FaultMapKey(faultElt.getQName()," "));
java.lang.Class messageClass = java.lang.Class.forName(messageClassName);
java.lang.Object messageObject = fromOM(faultElt,messageClass);
java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage",
new java.lang.Class[]{messageClass});
m.invoke(ex,new java.lang.Object[]{messageObject});
if (ex instanceof ){
throw ( )ex;
}
throw new java.rmi.RemoteException(ex.getMessage(), ex);
}catch(java.lang.ClassCastException e){
// we cannot intantiate the class - throw the original Axis fault
throw f;
} catch (java.lang.ClassNotFoundException e) {
// we cannot intantiate the class - throw the original Axis fault
throw f;
}catch (java.lang.NoSuchMethodException e) {
// we cannot intantiate the class - throw the original Axis fault
throw f;
} catch (java.lang.reflect.InvocationTargetException e) {
// we cannot intantiate the class - throw the original Axis fault
throw f;
} catch (java.lang.IllegalAccessException e) {
// we cannot intantiate the class - throw the original Axis fault
throw f;
} catch (java.lang.InstantiationException e) {
// we cannot intantiate the class - throw the original Axis fault
throw f;
}
}else{
throw f;
}
}else{
throw f;
}
} finally {
if (_messageContext.getTransportOut() != null) {
_messageContext.getTransportOut().getSender().cleanup(_messageContext);
}
}
}
/**
* Auto generated method signature for Asynchronous Invocations
*
* @see . #start
* @param
*/
public void start (
,
,
,
final . callback)
throws java.rmi.RemoteException{
org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[ ].getName());
_operationClient.getOptions().setAction(" ");
_operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
addPropertyToOperationClient(_operationClient, , );
// create SOAP envelope with that payload
org.apache.axiom.soap.SOAPEnvelope env=null;
final org.apache.axis2.context.MessageContext _messageContext = new org.apache.axis2.context.MessageContext();
//Style is Doc.
dummyWrappedType = null;
env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
,
dummyWrappedType,
optimizeContent(new javax.xml.namespace.QName(" ",
" ")));
env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
,
optimizeContent(new javax.xml.namespace.QName(" ", " ")),
new javax.xml.namespace.QName(" ", " ")
null
);
env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()));
// add the soap_headers only if they are not null
if ( !=null){
org.apache.axiom.om.OMElement omElement = toOM( , optimizeContent(new javax.xml.namespace.QName(" ", " ")));
addHeader(omElement ,env,true);
org.apache.axiom.om.OMElement omElement = toOM( , optimizeContent(new javax.xml.namespace.QName(" ", " ")));
addHeader(omElement ,env);
}
// add the children only if the parameter is not null
if ( !=null){
addHttpHeader(_messageContext," ", );
}
//Unknown style detected !! No code is generated
//Style is Doc. No input parameters
org.apache.axiom.soap.SOAPFactory factory = getFactory(_operationClient.getOptions().getSoapVersionURI());
env = factory.getDefaultEnvelope();
env.getBody().addChild(factory.createOMElement(" ", " ", ""));
//Style is taken to be "document". No input parameters
// according to the WS-Basic profile in this case we have to send an empty soap message
org.apache.axiom.soap.SOAPFactory factory = getFactory(_operationClient.getOptions().getSoapVersionURI());
env = factory.getDefaultEnvelope();
//Unknown style detected !! No code is generated
// adding SOAP soap_headers
_serviceClient.addHeadersToEnvelope(env);
// create message context with that soap envelope
_messageContext.setEnvelope(env);
// add the message context to the operation client
_operationClient.addMessageContext(_messageContext);
// Nothing to pass as the callback!!!
_operationClient.setCallback(new org.apache.axis2.client.async.AxisCallback() {
public void onMessage(org.apache.axis2.context.MessageContext resultContext) {
try {
org.apache.axiom.soap.SOAPEnvelope resultEnv = resultContext.getEnvelope();
callback.receiveResult (toByte(resultEnv.getBody().getFirstElement()));
callback.receiveResult (toChar(resultEnv.getBody().getFirstElement()));
callback.receiveResult (toDouble(resultEnv.getBody().getFirstElement()));
callback.receiveResult (toFloat(resultEnv.getBody().getFirstElement()));
callback.receiveResult (toInt(resultEnv.getBody().getFirstElement()));
callback.receiveResult (toLong(resultEnv.getBody().getFirstElement()));
callback.receiveResult (toShort(resultEnv.getBody().getFirstElement()));
callback.receiveResult (toBoolean(resultEnv.getBody().getFirstElement()));
java.lang.Object object = fromOM(resultEnv.getBody().getFirstElement(),
.class);
callback.receiveResult (
);
get (( )object));
( )object);
);
( )object);
} catch (org.apache.axis2.AxisFault e) {
callback.receiveError (e);
}
}
public void onError(java.lang.Exception error) {
if (error instanceof org.apache.axis2.AxisFault) {
org.apache.axis2.AxisFault f = (org.apache.axis2.AxisFault) error;
org.apache.axiom.om.OMElement faultElt = f.getDetail();
if (faultElt!=null){
if (faultExceptionNameMap.containsKey(new org.apache.axis2.client.FaultMapKey(faultElt.getQName()," "))){
//make the fault by reflection
try{
java.lang.String exceptionClassName = (java.lang.String)faultExceptionClassNameMap.get(new org.apache.axis2.client.FaultMapKey(faultElt.getQName()," "));
java.lang.Class exceptionClass = java.lang.Class.forName(exceptionClassName);
java.lang.reflect.Constructor constructor = exceptionClass.getConstructor(java.lang.String.class);
java.lang.Exception ex = (java.lang.Exception) constructor.newInstance(f.getMessage());
//message class
java.lang.String messageClassName = (java.lang.String)faultMessageMap.get(new org.apache.axis2.client.FaultMapKey(faultElt.getQName()," "));
java.lang.Class messageClass = java.lang.Class.forName(messageClassName);
java.lang.Object messageObject = fromOM(faultElt,messageClass);
java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage",
new java.lang.Class[]{messageClass});
m.invoke(ex,new java.lang.Object[]{messageObject});
if (ex instanceof ){
callback.receiveError (( )ex);
return;
}
callback.receiveError (new java.rmi.RemoteException(ex.getMessage(), ex));
} catch(java.lang.ClassCastException e){
// we cannot intantiate the class - throw the original Axis fault
callback.receiveError (f);
} catch (java.lang.ClassNotFoundException e) {
// we cannot intantiate the class - throw the original Axis fault
callback.receiveError (f);
} catch (java.lang.NoSuchMethodException e) {
// we cannot intantiate the class - throw the original Axis fault
callback.receiveError (f);
} catch (java.lang.reflect.InvocationTargetException e) {
// we cannot intantiate the class - throw the original Axis fault
callback.receiveError (f);
} catch (java.lang.IllegalAccessException e) {
// we cannot intantiate the class - throw the original Axis fault
callback.receiveError (f);
} catch (java.lang.InstantiationException e) {
// we cannot intantiate the class - throw the original Axis fault
callback.receiveError (f);
} catch (org.apache.axis2.AxisFault e) {
// we cannot intantiate the class - throw the original Axis fault
callback.receiveError (f);
}
} else {
callback.receiveError (f);
}
} else {
callback.receiveError (f);
}
} else {
callback.receiveError (error);
}
}
public void onFault(org.apache.axis2.context.MessageContext faultContext) {
org.apache.axis2.AxisFault fault = org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(faultContext);
onError(fault);
}
public void onComplete() {
try {
_messageContext.getTransportOut().getSender().cleanup(_messageContext);
} catch (org.apache.axis2.AxisFault axisFault) {
callback.receiveError (axisFault);
}
}
});
org.apache.axis2.util.CallbackReceiver _callbackReceiver = null;
if ( _operations[ ].getMessageReceiver()==null && _operationClient.getOptions().isUseSeparateListener()) {
_callbackReceiver = new org.apache.axis2.util.CallbackReceiver();
_operations[ ].setMessageReceiver(
_callbackReceiver);
}
//execute the operation client
_operationClient.execute(false);
}
/**
* Auto generated method signature
*
* @throws :
*/
public void (
,
,
,
) throws java.rmi.RemoteException
,
{
org.apache.axis2.context.MessageContext _messageContext = null;
try {
org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[ ].getName());
_operationClient.getOptions().setAction(" ");
_operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
addPropertyToOperationClient(_operationClient, , );
_operationClient.getOptions().setAction(" ");
org.apache.axiom.soap.SOAPEnvelope env = null;
_messageContext = new org.apache.axis2.context.MessageContext();
//Style is Doc.
dummyWrappedType = null;
env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
,
dummyWrappedType,
optimizeContent(new javax.xml.namespace.QName(" ",
" ")));
env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
,
optimizeContent(new javax.xml.namespace.QName(" ", " ")),
new javax.xml.namespace.QName(" ", " ")
null
);
env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()));
// add the children only if the parameter is not null
if ( !=null){
org.apache.axiom.om.OMElement omElement = toOM( , optimizeContent(new javax.xml.namespace.QName(" ", " ")));
addHeader(omElement ,env,true);
org.apache.axiom.om.OMElement omElement = toOM( , optimizeContent(new javax.xml.namespace.QName(" ", " ")));
addHeader(omElement ,env);
}
// add the children only if the parameter is not null
if ( !=null){
addHttpHeader(_messageContext," ", );
}
//Unknown style detected !! No code is generated
//Style is taken to be "document". No input parameters
org.apache.axiom.soap.SOAPFactory factory = getFactory(_operationClient.getOptions().getSoapVersionURI());
env = factory.getDefaultEnvelope();
env.getBody().addChild(factory.createOMElement(" ", " ", ""));
//Style is taken to be "document". No input parameters
// according to the WS-Basic profile in this case we have to send an empty soap message
org.apache.axiom.soap.SOAPFactory factory = getFactory(_operationClient.getOptions().getSoapVersionURI());
env = factory.getDefaultEnvelope();
//Unknown style detected !! No code is generated
//adding SOAP soap_headers
_serviceClient.addHeadersToEnvelope(env);
// create message context with that soap envelope
_messageContext.setEnvelope(env);
// add the message contxt to the operation client
_operationClient.addMessageContext(_messageContext);
_operationClient.execute(true);
}catch(org.apache.axis2.AxisFault f){
org.apache.axiom.om.OMElement faultElt = f.getDetail();
if (faultElt!=null){
if (faultExceptionNameMap.containsKey(new org.apache.axis2.client.FaultMapKey(faultElt.getQName()," "))){
//make the fault by reflection
try{
java.lang.String exceptionClassName = (java.lang.String)faultExceptionClassNameMap.get(new org.apache.axis2.client.FaultMapKey(faultElt.getQName()," "));
java.lang.Class exceptionClass = java.lang.Class.forName(exceptionClassName);
java.lang.Exception ex=
(java.lang.Exception) exceptionClass.newInstance();
//message class
java.lang.String messageClassName = (java.lang.String)faultMessageMap.get(new org.apache.axis2.client.FaultMapKey(faultElt.getQName()," "));
java.lang.Class messageClass = java.lang.Class.forName(messageClassName);
java.lang.Object messageObject = fromOM(faultElt,messageClass);
java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage",
new java.lang.Class[]{messageClass});
m.invoke(ex,new java.lang.Object[]{messageObject});
if (ex instanceof ){
throw ( )ex;
}
throw new java.rmi.RemoteException(ex.getMessage(), ex);
}catch(java.lang.ClassCastException e){
// we cannot intantiate the class - throw the original Axis fault
throw f;
} catch (java.lang.ClassNotFoundException e) {
// we cannot intantiate the class - throw the original Axis fault
throw f;
}catch (java.lang.NoSuchMethodException e) {
// we cannot intantiate the class - throw the original Axis fault
throw f;
} catch (java.lang.reflect.InvocationTargetException e) {
// we cannot intantiate the class - throw the original Axis fault
throw f;
} catch (java.lang.IllegalAccessException e) {
// we cannot intantiate the class - throw the original Axis fault
throw f;
} catch (java.lang.InstantiationException e) {
// we cannot intantiate the class - throw the original Axis fault
throw f;
}
}else{
throw f;
}
}else{
throw f;
}
} finally {
if (_messageContext.getTransportOut() != null) {
_messageContext.getTransportOut().getSender().cleanup(_messageContext);
}
}
if (_messageContext.getTransportOut() != null) {
_messageContext.getTransportOut().getSender().cleanup(_messageContext);
}
return;
}
////////////////////////////////////////////////////////////////////////
private static org.apache.neethi.Policy getPolicy (java.lang.String policyString) {
return org.apache.neethi.PolicyEngine.getPolicy(org.apache.axiom.om.OMXMLBuilderFactory.createOMBuilder(
new java.io.StringReader(policyString)).getDocument().getXMLStreamReader(false));
}
/////////////////////////////////////////////////////////////////////////
private javax.xml.namespace.QName[] opNameArray = null;
private boolean optimizeContent(javax.xml.namespace.QName opName) {
setOpNameArray();
if (opNameArray == null) {
return false;
}
for (int i = 0; i < opNameArray.length; i++) {
if (opName.equals(opNameArray[i])) {
return true;
}
}
return false;
}
//interface-implementation
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy