Class ImplClass = obj.getClass();
//Inject the Message Context if it is asked for
DependencyManager.configureBusinussLogicProvider(obj, msgContext);
OperationDescription opDesc = msgContext.getOperationContext().getAxisOperation();
Method method = findOperation(opDesc, ImplClass);
if (method != null) {
String style = msgContext.getOperationContext().getAxisOperation().getStyle();
Class[] parameters = method.getParameterTypes();
Object[] args = null;
if (parameters == null || parameters.length == 0) {
args = new Object[0];
} else if (parameters.length == 1) {
OMElement omElement = null;
if (WSDLService.STYLE_DOC.equals(style)) {
omElement = msgContext.getEnvelope().getBody().getFirstElement();
} else if (WSDLService.STYLE_RPC.equals(style)) {
OMElement operationElement = msgContext.getEnvelope().getBody().getFirstElement();
if (operationElement != null) {
if (method.getName().equals(operationElement.getLocalName())
|| operationElement.getLocalName() != null && operationElement.getLocalName().startsWith(method.getName()) ) {
omElement = operationElement.getFirstElement();
} else {
throw new AxisFault("Operation Name does not match the immediate child name, expected "+ method.getName() + " but get " + operationElement.getLocalName());
}
} else {
throw new AxisFault("rpc style expect the immediate child of the SOAP body ");
}
} else {
throw new AxisFault("Unknown style ");
}
args = new Object[] { omElement };
} else {
throw new AxisFault(
"Raw Xml provider supports only the methods bearing the signature public OMElement "
+ "<method-name>(OMElement) where the method name is anything");
}
OMElement result = (OMElement) method.invoke(obj, args);
OMElement bodyContent = null;
if (WSDLService.STYLE_RPC.equals(style)) {
OMNamespace ns = getSOAPFactory().createOMNamespace("http://soapenc/", "res");
bodyContent =
getSOAPFactory().createOMElement(method.getName() + "Response", ns);
bodyContent.addChild(result);
}else{
bodyContent = result;
}
SOAPEnvelope envelope = getSOAPFactory().getDefaultEnvelope();
if(bodyContent!= null){
envelope.getBody().addChild(bodyContent);
}
newmsgContext.setEnvelope(envelope);
} else {
throw new AxisFault(
"Implementation class does not define a method called" + opDesc.getName());
}
} catch (Exception e) {
throw AxisFault.makeFault(e);
}