Class ImplClass = obj.getClass();
//Inject the Message Context if it is asked for
DependencyManager.configureBusinessLogicProvider(obj, msgContext, newmsgContext);
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 (operationElement.getLocalName() != null &&
operationElement.getLocalName().startsWith(
method.getName())) {
omElement = operationElement.getFirstElement();
} else {
throw new AxisFault(Messages.getMessage("AandBdonotmatch","Operation Name","immediate child name",operationElement.getLocalName(),method.getName()));
}
} else {
throw new AxisFault(Messages.getMessage("rpcNeedmatchingChild"));
}
} else {
throw new AxisFault(Messages.getMessage("unknownStyle",style));
}
args = new Object[]{omElement};
} else {
throw new AxisFault(Messages.getMessage("rawXmlProivdeIsLimited"));
}
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(Messages.getMessage("methodNotImplemented",opDesc.getName().toString()));
}
} catch (Exception e) {
throw AxisFault.makeFault(e);
}