/** * Inspired by {@link ServiceClient#sendReceive(QName, OMElement)}, * {@link ServiceClient#fireAndForget(QName, OMElement)} and others */ public MessageContext sendReceive2(final QName operation, final OMElement xmlPayload) throws AxisFault { final MessageContext messageContext = new MessageContext(); fillSOAPEnvelope(messageContext, xmlPayload); final OperationClient operationClient = createClient(operation); operationClient.addMessageContext(messageContext); // TODO use operationClient.setCallback(AxisCallback) and do not block // we would first need to add a thread pool to the configuration context to use our thread...? // no it doesn't make sense, if we have to block a thread, so let's block this one... or use the real async // send! (which seems a bit more complex... not sure it's a good idea for now) operationClient.execute(true); return operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE); }
private void addPropertyToOperationClient(OperationClient operationClient, String propertyKey, Object propertyValue) { operationClient.getOptions().setProperty(propertyKey, propertyValue); }
/** * Directly invoke a named operation with an In-Out MEP without waiting for a response. This * method sends your supplied XML with response notification to your callback handler. For more * control, you can instead create a client for the operation and use that client to execute the * exchange. * * @param operation name of operation to be invoked (non-<code>null</code>) * @param elem the data to send (becomes the content of SOAP body) * @param callback a Callback which will be notified upon completion * @throws AxisFault in case of error * @see #createClient(QName) */ public void sendReceiveNonBlocking(QName operation, OMElement elem, AxisCallback callback) throws AxisFault { MessageContext mc = new MessageContext(); fillSOAPEnvelope(mc, elem); OperationClient mepClient = createClient(operation); // here a blocking invocation happens in a new thread, so the // progamming model is non blocking mepClient.setCallback(callback); mepClient.addMessageContext(mc); mepClient.execute(false); }
/** * Send a SOAP request via a MEPClient without attachments. * * @deprecated Please use {@link #sendSOAPRequest(String, String, Map, String, String, String)} * @param endpoint The URL of the endpoint to send the request to. * @param soapRequestFileName Path to the SOAP request file * @param parametersMap A map containing key value pairs to be parameterized in the request. * @return The SOAP Envelope that is returned as a result of the request. * @throws XMLStreamException Thrown on failure to build OM Element from the file's contents. * @throws IOException Thrown on failure to send the request. */ @Deprecated protected SOAPEnvelope sendSOAPRequest(String endpoint, String soapRequestFileName, Map<String, String> parametersMap) throws XMLStreamException, IOException { OMElement requestEnvelope = AXIOMUtil.stringToOM(loadRequestFromFile(soapRequestFileName, parametersMap)); OperationClient mepClient = buildMEPClient(new EndpointReference(endpoint), requestEnvelope); mepClient.execute(true); return mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE).getEnvelope(); }
_operationClient.getOptions().setAction("urn:applySecurity"); _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), applySecurity18, optimizeContent(new javax.xml.namespace.QName("http://service.config.security.carbon.wso2.org", _operationClient.addMessageContext(_messageContext); if ( _operations[0].getMessageReceiver()==null && _operationClient.getOptions().isUseSeparateListener()) { _callbackReceiver = new org.apache.axis2.util.CallbackReceiver(); _operations[0].setMessageReceiver( _operationClient.execute(false);
operationClient.getOptions().setAction("\"\""); operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); getFactory(operationClient.getOptions().getSoapVersionURI()).getDefaultEnvelope(); messageContext = new MessageContext(); messageContext.setEnvelope(soapEnvelope); operationClient.addMessageContext(messageContext); operationClient.getOptions().setTo(new EndpointReference(mexEndpointUrl)); operationClient.getOptions().setTo(bpelMessageContext.getUep()); operationClient.execute(true); operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE); MessageContext faultMessageContext = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_FAULT_VALUE);
/** * Directly invoke a named operation with a Robust In-Only MEP. This method just sends your * supplied XML and possibly receives a fault. For more control, you can instead create a client * for the operation and use that client to execute the send. * * @param operation name of operation to be invoked (non-<code>null</code>) * @param elem XML to send * @throws AxisFault if something goes wrong while sending it or if a fault is received in * response (per the Robust In-Only MEP). * @see #createClient(QName) */ public void sendRobust(QName operation, OMElement elem) throws AxisFault { MessageContext mc = new MessageContext(); fillSOAPEnvelope(mc, elem); OperationClient mepClient = createClient(operation); mepClient.addMessageContext(mc); mepClient.execute(true); }
public Object run() throws AxisFault { operationClient.addMessageContext(requestMC); return null; } });
public Object run() throws AxisFault { operationClient.execute(true); return null; } });
MessageContext getInputMessageContext() throws XdsInternalException, AxisFault { if (operationClient == null) { Object in = serviceClient.getServiceContext() .getLastOperationContext().getMessageContexts().get("In"); if (!(in instanceof MessageContext)) throw new XdsInternalException( "Soap: In MessageContext of type " + in.getClass().getName() + " instead of MessageContext"); MessageContext inMsgCxt = (MessageContext) in; return inMsgCxt; } return operationClient.getMessageContext("In"); }
MessageContext requestMC = operationClient.getMessageContext("Out"); requestMC.getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE); requestMC.getOptions().setTimeOutInMilliSeconds(240000L); operationClient.complete(requestMC); throw (AxisFault)e.getException(); MessageContext responseMC = operationClient.getMessageContext("In"); bindingContext.setAxisInMessageContext(responseMC); operationClient.complete(requestMC);
_operationClient.getOptions().setAction("urn:removeCertFromStore"); _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), removeCertFromStore28, optimizeContent(new javax.xml.namespace.QName("http://service.keystore.security.carbon.wso2.org", _operationClient.addMessageContext(_messageContext); if ( _operations[2].getMessageReceiver()==null && _operationClient.getOptions().isUseSeparateListener()) { _callbackReceiver = new org.apache.axis2.util.CallbackReceiver(); _operations[2].setMessageReceiver( _operationClient.execute(false);
MessageContext mctx = partnerInvocationContext.getInMessageContext(); OperationClient opClient = getOperationClient(partnerInvocationContext, configContext); mctx.getOptions().setParent(opClient.getOptions()); opClient.addMessageContext(mctx); Options operationOptions = opClient.getOptions(); opClient.execute(true); partnerInvocationContext.setOutMessageContext(opClient.getMessageContext( WSDLConstants.MESSAGE_LABEL_IN_VALUE)); partnerInvocationContext.setFaultMessageContext(opClient.getMessageContext( WSDLConstants.MESSAGE_LABEL_FAULT_VALUE));
protected Object invokeTargetOneWay(Message msg) throws AxisFault { WSAxis2BindingContext bindingContext = msg.getBindingContext(); OperationClient operationClient = bindingContext.getAxisOperationClient(); // ensure connections are tracked so that they can be closed by the reference binding MessageContext requestMC = operationClient.getMessageContext("Out"); //requestMC.getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE); Options opt = requestMC.getOptions(); opt.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE); opt.setUseSeparateListener(true); opt.setProperty(HTTPConstants.AUTO_RELEASE_CONNECTION,Boolean.TRUE); operationClient.execute(false); // REVIEW it seems ok to return null return null; }
/** * Directly invoke a named operation with a Robust In-Only MEP. This method just sends your * supplied XML and possibly receives a fault. For more control, you can instead create a client * for the operation and use that client to execute the send. * * @param operation name of operation to be invoked (non-<code>null</code>) * @param elem XML to send * @throws AxisFault if something goes wrong while sending it or if a fault is received in * response (per the Robust In-Only MEP). * @see #createClient(QName) */ public void sendRobust(QName operation, OMElement elem) throws AxisFault { MessageContext mc = new MessageContext(); fillSOAPEnvelope(mc, elem); OperationClient mepClient = createClient(operation); mepClient.addMessageContext(mc); mepClient.execute(true); }
/** * Method to build a MEP Client with an attachment in the method context. * * @deprecated Please use * {@link #buildMEPClient(EndpointReference, OMElement, Map, String, String, String)} instead. * @param endpoint The endpoint to configure the client for. * @param request The request to add as a SOAP envelope. * @param attachmentMap The attachment map. * @return The built MEP Client * @throws AxisFault on failure to initialize the client. */ @Deprecated private OperationClient buildMEPClient(final EndpointReference endpoint, final OMElement request, final Map<String, DataHandler> attachmentMap) throws AxisFault { ServiceClient serviceClient = new ServiceClient(); Options serviceOptions = new Options(); serviceOptions.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE); serviceOptions.setTo(endpoint); serviceOptions.setAction("mediate"); serviceClient.setOptions(serviceOptions); MessageContext messageContext = new MessageContext(); SOAPEnvelope soapEnvelope = TransportUtils.createSOAPEnvelope(request); messageContext.setEnvelope(soapEnvelope); for (String contentId : attachmentMap.keySet()) { messageContext.addAttachment(contentId, attachmentMap.get(contentId)); } OperationClient mepClient = serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP); mepClient.addMessageContext(messageContext); return mepClient; }
WSAxis2BindingContext bindingContext = new WSAxis2BindingContext(); bindingContext.setAxisOperationClient(operationClient); bindingContext.setAxisOutMessageContext(operationClient.getMessageContext("Out"));
_operationClient.getOptions().setAction("urn:addKeyStore"); _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), addKeyStore30, optimizeContent(new javax.xml.namespace.QName("http://service.keystore.security.carbon.wso2.org", _operationClient.addMessageContext(_messageContext); if ( _operations[3].getMessageReceiver()==null && _operationClient.getOptions().isUseSeparateListener()) { _callbackReceiver = new org.apache.axis2.util.CallbackReceiver(); _operations[3].setMessageReceiver( _operationClient.execute(false);
private static MessageContext sendReceive(OMElement llomElement, ServiceClient serviceClient) throws AxisFault { MessageContext messageContext = new MessageContext(); fillSOAPEnvelope(messageContext, llomElement, serviceClient); OperationClient operationClient = serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP); operationClient.addMessageContext(messageContext); operationClient.execute(true); MessageContext response = operationClient .getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE); if (serviceClient.getOptions().isCallTransportCleanup()) { response.getEnvelope().build(); serviceClient.cleanupTransport(); return response; } else { return response; } }
protected MessageContext send(ClientOptions options, AxisMessage message, QName operationQName, boolean block, String resultMessageLabel) throws Exception { OperationClient mepClient = serviceClient.createClient(operationQName); MessageContext mc = new MessageContext(); mc.setProperty(Constants.Configuration.MESSAGE_TYPE, message.getMessageType()); mc.setEnvelope(message.getEnvelope()); Attachments attachments = message.getAttachments(); if (attachments != null) { mc.setAttachmentMap(attachments); mc.setDoingSwA(true); mc.setProperty(Constants.Configuration.ENABLE_SWA, true); } for (AxisTestClientConfigurator configurator : configurators) { configurator.setupRequestMessageContext(mc); } mc.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, options.getCharset()); mc.setServiceContext(serviceClient.getServiceContext()); if (metrics != null) { mc.setProperty(BaseConstants.METRICS_COLLECTOR, metrics); } mepClient.addMessageContext(mc); mepClient.getOptions().setAction(""); mepClient.execute(block); // mepClient.complete(mc); return resultMessageLabel == null ? null : mepClient.getMessageContext(resultMessageLabel); }