public MessageContext invokeBlocking(OperationDescription axisop, final MessageContext msgctx) throws AxisFault { prepareInvocation(axisop, msgctx);
// The message ID is sent all the time String messageID = String.valueOf(System.currentTimeMillis()); msgctx.setMessageID(messageID); // if (useSeparateListener) { //This mean doing a Request-Response invocation using two channel. If the //transport is two way transport (e.g. http) Only one channel is used (e.g. in http cases //202 OK is sent to say no repsone avalible). Axis2 get blocked return when the response is avalible.
SyncCallBack callback = new SyncCallBack(); //this method call two channel non blocking method to do the work and wait on the callbck invokeNonBlocking(axisop, msgctx, callback); long index = timeOutInMilliSeconds / 100; while (!callback.isComplete()) { //wait till the reponse arrives if (index-- >= 0) { try { Thread.sleep(100); } catch (InterruptedException e) { throw new AxisFault(e); } } else { throw new AxisFault(Messages.getMessage("responseTimeOut")); } } //process the resule of the invocation if (callback.envelope != null) { MessageContext resMsgctx = new MessageContext(serviceContext.getEngineContext()); resMsgctx.setEnvelope(callback.envelope); return resMsgctx; } else { if (callback.error instanceof AxisFault) { throw (AxisFault) callback.error; } else { throw new AxisFault(callback.error); } } } else { //This is the Usual Request-Response Sync implemetation msgctx.setTo(to); msgctx.setServiceContext(serviceContext); ConfigurationContext syscontext = serviceContext.getEngineContext(); msgctx.setConfigurationContext(syscontext);
checkTransport(msgctx);
//find and set the Operation Context ConfigurationContext sysContext = serviceContext.getEngineContext(); AxisConfiguration registry = sysContext.getAxisConfiguration(); msgctx.setOperationContext(OperationContextFactory.createOperationContext(WSDLConstants.MEP_CONSTANT_IN_OUT, axisop, serviceContext)); //Send the SOAP Message and receive a response MessageContext response = TwoWayTransportBasedSender.send(msgctx, listenerTransport);
//check for a fault and return the result SOAPEnvelope resenvelope = response.getEnvelope(); if (resenvelope.getBody().hasFault()) { SOAPFault soapFault = resenvelope.getBody().getFault(); Exception ex = soapFault.getException();
if (isExceptionToBeThrownOnSOAPFault) { //does the SOAPFault has a detail element for Excpetion if (ex != null) { throw new AxisFault(ex); } else { //if detail element not present create a new Exception from the detail String message = "";
并在一下处调用该函数 if (ex != null) { throw new AxisFault(ex); } else { //if detail element not present create a new Exception from the detail String message = "";