public void setDoingPOX(boolean b) { axis2MessageContext.setDoingREST(b); }
public void setDoingPOX(boolean b) { axis2MessageContext.setDoingREST(b); }
public void setDoingGET(boolean b) { if(b) { axis2MessageContext.setDoingREST(b); axis2MessageContext.setProperty(Constants.Configuration.HTTP_METHOD, Constants.Configuration.HTTP_METHOD_GET); } else { axis2MessageContext.removeProperty(Constants.Configuration.HTTP_METHOD); } }
public void setDoingGET(boolean b) { if (b) { axis2MessageContext.setDoingREST(b); axis2MessageContext.setProperty(Constants.Configuration.HTTP_METHOD, Constants.Configuration.HTTP_METHOD_GET); } else { axis2MessageContext.removeProperty(Constants.Configuration.HTTP_METHOD); } }
public OMElement processDocument(InputStream inputStream, String contentType, MessageContext msgContext) throws AxisFault { msgContext.setDoingREST(true); OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = factory.createOMNamespace("", ""); byte[] bytes; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); BufferUtils.inputStream2OutputStream(inputStream, baos); baos.flush(); bytes = baos.toByteArray(); } catch (IOException e) { throw AxisFault.makeFault(e); } ByteArrayDataSourceEx ds = new ByteArrayDataSourceEx(bytes, contentType); return factory.createOMElement(ds, "dummy", ns); }
public OMElement processDocument(InputStream inputStream, String contentType, MessageContext msgContext) throws AxisFault { msgContext.setDoingREST(true); OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = factory.createOMNamespace("", ""); byte[] bytes; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOUtils.copy(inputStream, baos, -1); baos.flush(); bytes = baos.toByteArray(); } catch (IOException e) { throw AxisFault.makeFault(e); } ByteArrayDataSourceEx ds = new ByteArrayDataSourceEx(bytes, contentType); return factory.createOMElement(ds, "dummy", ns); }
public static boolean isDoingREST(MessageContext msgContext) { boolean enableREST = false; // check whether isDoingRest is already true in the message context if (msgContext.isDoingREST()) { return true; } Object enableRESTProperty = msgContext.getProperty(Constants.Configuration.ENABLE_REST); if (enableRESTProperty != null) { enableREST = JavaUtils.isTrueExplicitly(enableRESTProperty); } msgContext.setDoingREST(enableREST); return enableREST; }
public static boolean isDoingREST(MessageContext msgContext) { boolean enableREST = false; // check whether isDoingRest is already true in the message context if (msgContext.isDoingREST()) { return true; } Object enableRESTProperty = msgContext.getProperty(Constants.Configuration.ENABLE_REST); if (enableRESTProperty != null) { enableREST = JavaUtils.isTrueExplicitly(enableRESTProperty); } msgContext.setDoingREST(enableREST); return enableREST; }
return false; } else { msgContext.setDoingREST(true); msgContext.setEnvelope(envelope); AxisEngine.receive(msgContext);
/** * Processes the HTTP GET request and builds the SOAP info-set of the REST message * * @param msgContext The MessageContext of the Request Message * @param out The output stream of the response * @param soapAction SoapAction of the request * @param requestURI The URL that the request came to * @throws AxisFault - Thrown in case a fault occurs */ public static void processURLRequest(MessageContext msgContext, OutputStream out, String soapAction, String requestURI) throws AxisFault { if ((soapAction != null) && soapAction.startsWith("\"") && soapAction.endsWith("\"")) { soapAction = soapAction.substring(1, soapAction.length() - 1); } msgContext.setSoapAction(soapAction); msgContext.setTo(new EndpointReference(requestURI)); msgContext.setProperty(MessageContext.TRANSPORT_OUT, out); msgContext.setServerSide(true); msgContext.setDoingREST(true); msgContext.setEnvelope(new SOAP11Factory().getDefaultEnvelope()); msgContext.setProperty(NhttpConstants.NO_ENTITY_BODY, Boolean.TRUE); AxisEngine.receive(msgContext); }
/** * Adding REST related properties to the message context if request is REST * @param msgContext Axis2MessageContext of the request * @param method HTTP Method of the request * @return whether request is REST or SOAP */ public boolean isRESTRequest(MessageContext msgContext, String method){ if(msgContext.getProperty (PassThroughConstants.REST_GET_DELETE_INVOKE) != null && (Boolean)msgContext.getProperty (PassThroughConstants.REST_GET_DELETE_INVOKE)){ msgContext.setProperty(HTTPConstants.HTTP_METHOD, method); msgContext.setServerSide(true); msgContext.setDoingREST(true); return true; } return false; }
public void processNonEntityEnclosingRESTHandler(SOAPEnvelope soapEnvelope, MessageContext msgContext, boolean injectToAxis2Engine) { String soapAction = request.getHeaders().get(SOAP_ACTION_HEADER); if ((soapAction != null) && soapAction.startsWith("\"") && soapAction.endsWith("\"")) { soapAction = soapAction.substring(1, soapAction.length() - 1); } msgContext.setSoapAction(soapAction); msgContext.setTo(new EndpointReference(request.getUri())); msgContext.setServerSide(true); msgContext.setDoingREST(true); if (!(request.isEntityEnclosing())) { msgContext.setProperty(PassThroughConstants.NO_ENTITY_BODY, Boolean.TRUE); } try { if(soapEnvelope == null){ msgContext.setEnvelope(new SOAP11Factory().getDefaultEnvelope()); }else{ msgContext.setEnvelope(soapEnvelope); } if (injectToAxis2Engine) { AxisEngine.receive(msgContext); } } catch (AxisFault axisFault) { handleException("Error processing " + request.getMethod() + " request for : " + request.getUri(), axisFault); } catch (Exception e) { String encodedURL = StringEscapeUtils.escapeHtml(request.getUri()); handleException("Error processing " + request.getMethod() + " request for : " + encodedURL + ". ", e); } }
throws AxisFault { try { msgContext.setDoingREST(true); String charSetEncoding = BuilderUtil.getCharSetEncoding(contentType); msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEncoding);
/** * Send via http. * * @param httpMethod * the http method * @param soapAction * the soap action * @param address * the address * @param rest * the rest * @throws IOException * Signals that an I/O exception has occurred. */ protected void sendViaHTTP(String httpMethod, String soapAction, String address, boolean rest) throws IOException { httpSender = getHTTPSender(); MessageContext msgContext = new MessageContext(); ConfigurationContext configContext = ConfigurationContextFactory .createEmptyConfigurationContext(); OperationContext opContext = new OperationContext(); msgContext.setConfigurationContext(configContext); msgContext.setEnvelope(getEnvelope()); msgContext.setDoingREST(rest); msgContext.setProperty(Constants.Configuration.HTTP_METHOD, httpMethod); msgContext.setOperationContext(opContext); URL url = new URL(address); httpSender.send(msgContext, url, soapAction); }
/** * Get the OMOutput format for the given message * @param msgContext the axis message context * @return the OMOutput format to be used */ public static OMOutputFormat getOMOutputFormat(MessageContext msgContext) { OMOutputFormat format = new OMOutputFormat(); msgContext.setDoingMTOM(TransportUtils.doWriteMTOM(msgContext)); msgContext.setDoingSwA(TransportUtils.doWriteSwA(msgContext)); msgContext.setDoingREST(TransportUtils.isDoingREST(msgContext)); format.setSOAP11(msgContext.isSOAP11()); format.setDoOptimize(msgContext.isDoingMTOM()); format.setDoingSWA(msgContext.isDoingSwA()); format.setCharSetEncoding(TransportUtils.getCharSetEncoding(msgContext)); Object mimeBoundaryProperty = msgContext.getProperty(Constants.Configuration.MIME_BOUNDARY); if (mimeBoundaryProperty != null) { format.setMimeBoundary((String) mimeBoundaryProperty); } return format; }
responseMsgCtx.setDoingREST(outMsgCtx.isDoingREST()); responseMsgCtx.setProperty( MessageContext.TRANSPORT_IN, outMsgCtx.getProperty(MessageContext.TRANSPORT_IN));
/** * Retirn the OMOutputFormat to be used for the message context passed in * @param msgContext the message context * @return the OMOutputFormat to be used */ public static OMOutputFormat getOMOutputFormat(MessageContext msgContext) { OMOutputFormat format = new OMOutputFormat(); msgContext.setDoingMTOM(TransportUtils.doWriteMTOM(msgContext)); msgContext.setDoingSwA(TransportUtils.doWriteSwA(msgContext)); msgContext.setDoingREST(TransportUtils.isDoingREST(msgContext)); format.setSOAP11(msgContext.isSOAP11()); format.setDoOptimize(msgContext.isDoingMTOM()); format.setDoingSWA(msgContext.isDoingSwA()); format.setCharSetEncoding(TransportUtils.getCharSetEncoding(msgContext)); Object mimeBoundaryProperty = msgContext.getProperty(Constants.Configuration.MIME_BOUNDARY); if (mimeBoundaryProperty != null) { format.setMimeBoundary((String) mimeBoundaryProperty); } return format; }
/** * Get the OMOutput format for the given message * @param msgContext the axis message context * @return the OMOutput format to be used */ public static OMOutputFormat getOMOutputFormat(MessageContext msgContext) { OMOutputFormat format = new OMOutputFormat(); msgContext.setDoingMTOM(TransportUtils.doWriteMTOM(msgContext)); msgContext.setDoingSwA(TransportUtils.doWriteSwA(msgContext)); msgContext.setDoingREST(TransportUtils.isDoingREST(msgContext)); format.setSOAP11(msgContext.isSOAP11()); format.setDoOptimize(msgContext.isDoingMTOM()); format.setDoingSWA(msgContext.isDoingSwA()); format.setCharSetEncoding(TransportUtils.getCharSetEncoding(msgContext)); Object mimeBoundaryProperty = msgContext.getProperty(Constants.Configuration.MIME_BOUNDARY); if (mimeBoundaryProperty != null) { format.setMimeBoundary((String) mimeBoundaryProperty); } return format; }
msgContext.setDoingREST(TransportUtils.isDoingREST(msgContext));
responseMessageContext.setDoingREST(msgContext.isDoingREST());