当前位置: 代码迷 >> J2EE >> axis2怎么返回字符串给客户端
  详细解决方案

axis2怎么返回字符串给客户端

热度:405   发布时间:2016-04-22 02:26:59.0
axis2如何返回字符串给客户端
我服务端的代码是自动生成的,如下,现在客户端调服务端之后,服务端返回一段字符串给客户端,这个代码写在哪?
服务器代码如下
Java code
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);    }


------解决方案--------------------
axis2
  相关解决方案