You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by amiteshsingh <am...@accenture.com> on 2010/12/31 15:59:13 UTC
[AXIS2 1.4.1] org.apache.axis2.AxisFault: Exception occurred while
trying to invoke service method
Hi,
I am using axis2 1.4.1 with JDK 1.5, when I am trying to invoke a service
deployed in tomcat, getting the below error
org.apache.axis2.AxisFault: Exception occurred while trying to invoke
service method getSAMLAssertion
at
org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:512)
at
org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370)
at
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
at
org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
at
org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at
com.starwoodone.webservice.SAMLSSOServiceStub.getSAMLAssertion(SAMLSSOServiceStub.java:222)
at com.starwoodone.webservice.WSClient.main(WSClient.java:43)
Below is my code snippet
public
com.starwoodone.webservice.SAMLSSOServiceStub.GetSAMLAssertionResponse
getSAMLAssertion(
com.starwoodone.webservice.SAMLSSOServiceStub.GetSAMLAssertion
getSAMLAssertion1)
throws java.rmi.RemoteException
{
org.apache.axis2.context.MessageContext _messageContext =
null;
try{
org.apache.axis2.client.OperationClient _operationClient =
_serviceClient.createClient(_operations[0].getName());
_operationClient.getOptions().setAction("urn:getSAMLAssertion");
_operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
addPropertyToOperationClient(_operationClient,org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,"&");
// 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()),
getSAMLAssertion1,
optimizeContent(new
javax.xml.namespace.QName("http://webservice.starwoodone.com",
"getSAMLAssertion")));
//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);
*********************************************
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();
java.lang.Object object = fromOM(
_returnEnv.getBody().getFirstElement() ,
com.starwoodone.webservice.SAMLSSOServiceStub.GetSAMLAssertionResponse.class,
getEnvelopeNamespaces(_returnEnv));
return
(com.starwoodone.webservice.SAMLSSOServiceStub.GetSAMLAssertionResponse)object;
}catch(org.apache.axis2.AxisFault f){
org.apache.axiom.om.OMElement faultElt = f.getDetail();
if (faultElt!=null){
if (faultExceptionNameMap.containsKey(faultElt.getQName())){
//make the fault by reflection
try{
java.lang.String exceptionClassName =
(java.lang.String)faultExceptionClassNameMap.get(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(faultElt.getQName());
java.lang.Class messageClass =
java.lang.Class.forName(messageClassName);
java.lang.Object messageObject =
fromOM(faultElt,messageClass,null);
java.lang.reflect.Method m =
exceptionClass.getMethod("setFaultMessage",
new java.lang.Class[]{messageClass});
m.invoke(ex,new java.lang.Object[]{messageObject});
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 {
_messageContext.getTransportOut().getSender().cleanup(_messageContext);
}
}
--
View this message in context: http://old.nabble.com/-AXIS2-1.4.1--org.apache.axis2.AxisFault%3A-Exception-occurred-while-trying-to-invoke-service-method-tp30563899p30563899.html
Sent from the Axis - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org