日期:2014-05-20 浏览次数:20936 次
public void startcompleteTask(ServerAllServiceStub.CompleteTask completeTask8, final ServerAllServiceCallbackHandler callback) throws java.rmi.RemoteException { OperationClient _operationClient = _serviceClient.createClient(_operations[4].getName()); _operationClient.getOptions().setAction("\"\""); _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); addPropertyToOperationClient(_operationClient, WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, "&"); // create SOAP envelope with that payload SOAPEnvelope env = null; final MessageContext _messageContext = new MessageContext(); // Style is Doc. env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), completeTask8, optimizeContent(new javax.xml.namespace.QName( "http://portal.zj.sgcc.com.cn/axisServer/services/axis", "completeTask"))); // 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); _operationClient.setCallback(new org.apache.axis2.client.async.AxisCallback() { public void onMessage(org.apache.axis2.context.MessageContext resultContext) { ServerAllServiceStub.CompleteTaskResponse ct = new CompleteTaskResponse(); ct.setCompleteTaskReturn("server return"); callback.receiveResultcompleteTask(ct); try { String fileName = "onMessage" + System.currentTimeMillis() + ""; IOUtils.write("", new FileOutputStream(new File("c:/axis2/" + fileName + ".txt"))); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public void onError(java.lang.Exception 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.receiveErrorcompleteTask(axisFault); } } }); org.apache.axis2.util.CallbackReceiver _callbackReceiver = null; if (_operations[4].getMessageReceiver() == null && _operationClient.getOptions().isUseSeparateListener()) { _callbackReceiver = new org.apache.axis2.util.CallbackReceiver(); _operations[4].setMessageReceiver(_callbackReceiver); } _operationClient.execute(false); }