Package com.eviware.soapui.impl.wsdl.submit.transports.http

Examples of com.eviware.soapui.impl.wsdl.submit.transports.http.ExtendedHttpMethod


        String content = (String) context.getProperty(BaseHttpRequestTransport.REQUEST_CONTENT);
        if (content == null) {
            log.warn("Missing request content in context, skipping ws-addressing");
        } else {
            ExtendedHttpMethod httpMethod = (ExtendedHttpMethod) context
                    .getProperty(BaseHttpRequestTransport.HTTP_METHOD);
            WsdlOperation operation = ((WsdlRequest) wsdlRequest).getOperation();
            // TODO check UsingAddressing for particular endpoint when running a
            // request
            // ((WsdlRequest)wsdlRequest).getEndpoint();
View Full Code Here


    public void filterAbstractHttpRequest(SubmitContext context, AbstractHttpRequest<?> httpRequest) {
        Settings settings = httpRequest.getSettings();
        String compressionAlg = settings.getString(HttpSettings.REQUEST_COMPRESSION, "None");
        if (!"None".equals(compressionAlg)) {
            try {
                ExtendedHttpMethod method = (ExtendedHttpMethod) context
                        .getProperty(BaseHttpRequestTransport.HTTP_METHOD);
                if (method instanceof HttpEntityEnclosingRequest) {
                    HttpEntity requestEntity = ((HttpEntityEnclosingRequest) method).getEntity();
                    if (requestEntity != null) {
                        ByteArrayOutputStream tempOut = new ByteArrayOutputStream();
View Full Code Here

        String content = (String) context.getProperty(BaseHttpRequestTransport.REQUEST_CONTENT);
        if (content == null) {
            log.warn("Missing request content in context, skipping ws-addressing");
        } else {
            ExtendedHttpMethod httpMethod = (ExtendedHttpMethod) context
                    .getProperty(BaseHttpRequestTransport.HTTP_METHOD);
            WsdlOperation operation = ((WsdlRequest) wsdlRequest).getOperation();
            // TODO check UsingAddressing for particular endpoint when running a
            // request
            // ((WsdlRequest)wsdlRequest).getEndpoint();
View Full Code Here

import com.eviware.soapui.model.iface.SubmitContext;

public class HttpPackagingResponseFilter extends AbstractRequestFilter {
    @Override
    public void afterAbstractHttpResponse(SubmitContext context, AbstractHttpRequestInterface<?> request) {
        ExtendedHttpMethod httpMethod = (ExtendedHttpMethod) context.getProperty(BaseHttpRequestTransport.HTTP_METHOD);
        String requestContent = (String) context.getProperty(BaseHttpRequestTransport.REQUEST_CONTENT);

        // check content-type for multipart
        Header responseContentTypeHeader = null;
        if (httpMethod.hasHttpResponse()) {
            Header[] headers = httpMethod.getHttpResponse().getHeaders("Content-Type");
            if (headers != null && headers.length > 0) {
                responseContentTypeHeader = headers[0];
            }
        }
        Response response = null;
View Full Code Here

        currentTestCaseRunLogTestStepConfig.setTimeTaken(Long.toString(result.getTimeTaken()));
        currentTestCaseRunLogTestStepConfig.setStatus(result.getStatus().toString());
        currentTestCaseRunLogTestStepConfig.setMessageArray(result.getMessages());
        currentTestCaseRunLogTestStepConfig.setTimestamp(SoapUIMetrics.formatTimestamp(result.getTimeStamp()));

        ExtendedHttpMethod httpMethod = (ExtendedHttpMethod) runContext
                .getProperty(BaseHttpRequestTransport.HTTP_METHOD);

        if (httpMethod != null && result.getTestStep() instanceof HttpRequestTestStep) {
            currentTestCaseRunLogTestStepConfig.setEndpoint(httpMethod.getURI().toString());

            SoapUIMetrics metrics = httpMethod.getMetrics();
            currentTestCaseRunLogTestStepConfig.setTimestamp(metrics.getFormattedTimeStamp());
            currentTestCaseRunLogTestStepConfig.setHttpStatus(String.valueOf(metrics.getHttpStatus()));
            currentTestCaseRunLogTestStepConfig.setContentLength(String.valueOf(metrics.getContentLength()));
            currentTestCaseRunLogTestStepConfig.setReadTime(String.valueOf(metrics.getReadTimer().getDuration()));
            currentTestCaseRunLogTestStepConfig.setTotalTime(String.valueOf(metrics.getTotalTimer().getDuration()));
View Full Code Here

        listenerCallBack.fireOnRequest(project, request, response);
        if (response.isCommitted()) {
            return;
        }

        ExtendedHttpMethod method;
        HttpServletRequest httpRequest = (HttpServletRequest) request;
        if (httpRequest.getMethod().equals("GET")) {
            method = new ExtendedGetMethod();
        } else if (httpRequest.getMethod().equals("POST")) {
            method = new ExtendedPostMethod();
        } else if (httpRequest.getMethod().equals("PUT")) {
            method = new ExtendedPutMethod();
        } else if (httpRequest.getMethod().equals("HEAD")) {
            method = new ExtendedHeadMethod();
        } else if (httpRequest.getMethod().equals("OPTIONS")) {
            method = new ExtendedOptionsMethod();
        } else if (httpRequest.getMethod().equals("TRACE")) {
            method = new ExtendedTraceMethod();
        } else if (httpRequest.getMethod().equals("PATCH")) {
            method = new ExtendedPatchMethod();
        } else {
            method = new ExtendedGenericMethod(httpRequest.getMethod());
        }

        method.setDecompress(false);

        ByteArrayOutputStream requestBody = null;
        if (method instanceof HttpEntityEnclosingRequest) {
            requestBody = Tools.readAll(request.getInputStream(), 0);
            ByteArrayEntity entity = new ByteArrayEntity(requestBody.toByteArray());
            entity.setContentType(request.getContentType());
            ((HttpEntityEnclosingRequest) method).setEntity(entity);
        }

        // for this create ui server and port, properties.
        JProxyServletWsdlMonitorMessageExchange capturedData = new JProxyServletWsdlMonitorMessageExchange(project);
        capturedData.setRequestHost(httpRequest.getServerName());
        capturedData.setRequestMethod(httpRequest.getMethod());
        capturedData.setRequestHeader(httpRequest);
        capturedData.setHttpRequestParameters(httpRequest);
        capturedData.setQueryParameters(httpRequest.getQueryString());
        capturedData.setTargetURL(httpRequest.getRequestURL().toString());

        //    CaptureInputStream capture = new CaptureInputStream( httpRequest.getInputStream() );

        // check connection header
        String connectionHeader = httpRequest.getHeader("Connection");
        if (connectionHeader != null) {
            connectionHeader = connectionHeader.toLowerCase();
            if (!connectionHeader.contains("keep-alive") && !connectionHeader.contains("close")) {
                connectionHeader = null;
            }
        }

        // copy headers
        boolean xForwardedFor = false;
        @SuppressWarnings("unused")
        Enumeration<?> headerNames = httpRequest.getHeaderNames();
        while (headerNames.hasMoreElements()) {
            String hdr = (String) headerNames.nextElement();
            String lhdr = hdr.toLowerCase();

            if (dontProxyHeaders.contains(lhdr)) {
                continue;
            }
            if (connectionHeader != null && connectionHeader.contains(lhdr)) {
                continue;
            }

            Enumeration<?> vals = httpRequest.getHeaders(hdr);
            while (vals.hasMoreElements()) {
                String val = (String) vals.nextElement();
                if (val != null) {
                    method.setHeader(lhdr, val);
                    xForwardedFor |= "X-Forwarded-For".equalsIgnoreCase(hdr);
                }
            }
        }

        // Proxy headers
        method.setHeader("Via", "SoapUI Monitor");
        if (!xForwardedFor) {
            method.addHeader("X-Forwarded-For", request.getRemoteAddr());
        }

        StringBuffer url = new StringBuffer("http://");
        url.append(httpRequest.getServerName());
        if (httpRequest.getServerPort() != 80) {
            url.append(":" + httpRequest.getServerPort());
        }

        if (httpRequest.getServletPath() != null) {
            url.append(httpRequest.getServletPath());
            try {
                method.setURI(new java.net.URI(url.toString().replaceAll(" ", "%20")));
            } catch (URISyntaxException e) {
                SoapUI.logError(e);
            }

            if (httpRequest.getQueryString() != null) {
                url.append("?" + httpRequest.getQueryString());
                try {
                    method.setURI(new java.net.URI(url.toString()));
                } catch (URISyntaxException e) {
                    SoapUI.logError(e);
                }
            }
        }

        method.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS, false);
        setProtocolversion(method, request.getProtocol());
        ProxyUtils.setForceDirectConnection(method.getParams());
        listenerCallBack.fireBeforeProxy(project, request, response, method);

        if (settings.getBoolean(LaunchForm.SSLTUNNEL_REUSESTATE)) {
            if (httpState == null) {
                httpState = new BasicHttpContext();
            }
            HttpClientSupport.execute(method, httpState);
        } else {
            HttpClientSupport.execute(method);
        }

        // wait for transaction to end and store it.
        capturedData.stopCapture();

        capturedData.setRequest(requestBody == null ? null : requestBody.toByteArray());
        capturedData.setRawResponseBody(method.getResponseBody());
        capturedData.setResponseHeader(method.getHttpResponse());
        capturedData.setRawRequestData(getRequestToBytes(request.toString(), requestBody));
        capturedData.setRawResponseData(getResponseToBytes(method, capturedData.getRawResponseBody()));
        byte[] decompressedResponseBody = method.getDecompressedResponseBody();
        capturedData.setResponseContent(decompressedResponseBody != null ? new String(decompressedResponseBody) : "");
        capturedData.setResponseStatusCode(method.hasHttpResponse() ? method.getHttpResponse().getStatusLine()
                .getStatusCode() : null);
        capturedData.setResponseStatusLine(method.hasHttpResponse() ? method.getHttpResponse().getStatusLine()
                .toString() : null);

        listenerCallBack.fireAfterProxy(project, request, response, method, capturedData);

        ((HttpServletResponse) response).setStatus(method.hasHttpResponse() ? method.getHttpResponse()
                .getStatusLine().getStatusCode() : null);

        if (!response.isCommitted()) {
            StringToStringsMap responseHeaders = capturedData.getResponseHeaders();
            // capturedData = null;
View Full Code Here

    }

    @Test
    public void noContentTypeMatchesRequestWithNoContentType() {
        proxyServlet.setIncludedContentTypes(ContentTypes.of(""));
        ExtendedHttpMethod request = createRequestWithContentTypes();
        assertThat(proxyServlet.contentTypeMatches(request), is(true));
    }
View Full Code Here

        ExtendedHttpMethod request = createRequestWithContentTypes();
        assertThat(proxyServlet.contentTypeMatches(request), is(true));
    }

    private ExtendedHttpMethod createRequestWithContentTypes(String... contentTypes) {
        ExtendedHttpMethod method = mock(ExtendedHttpMethod.class);
        HttpResponse httpResponse = mock(HttpResponse.class);
        when(method.hasHttpResponse()).thenReturn(true);
        when(method.getHttpResponse()).thenReturn(httpResponse);
        Header[] headers = new Header[contentTypes.length];
        for (int i = 0; i < headers.length; i++) {
            headers[i] = new BasicHeader("Content-Type", contentTypes[i]);
        }
        when(httpResponse.getHeaders(eq("Content-Type"))).thenReturn(headers);
View Full Code Here

        listenerCallBack.fireOnRequest(project, request, response);
        if (response.isCommitted()) {
            return;
        }

        ExtendedHttpMethod postMethod;

        // for this create ui server and port, properties.
        InetSocketAddress inetAddress = new InetSocketAddress(sslEndPoint, sslPort);
        HttpServletRequest httpRequest = (HttpServletRequest) request;
        if (httpRequest.getMethod().equals("GET")) {
            postMethod = new ExtendedGetMethod();
        } else {
            postMethod = new ExtendedPostMethod();
        }

        JProxyServletWsdlMonitorMessageExchange capturedData = new JProxyServletWsdlMonitorMessageExchange(project);
        capturedData.setRequestHost(httpRequest.getRemoteHost());
        capturedData.setRequestHeader(httpRequest);
        capturedData.setHttpRequestParameters(httpRequest);
        capturedData.setTargetURL(this.prot + inetAddress.getHostName());

        CaptureInputStream capture = new CaptureInputStream(httpRequest.getInputStream());

        long contentLength = -1;
        // copy headers
        Enumeration<?> headerNames = httpRequest.getHeaderNames();
        while (headerNames.hasMoreElements()) {
            String hdr = (String) headerNames.nextElement();
            String lhdr = hdr.toLowerCase();

            if ("content-length".equals(lhdr)) {
                String val = httpRequest.getHeader(hdr);
                contentLength = Long.parseLong(val);
                continue;
            }

            if ("transfer-encoding".equals(lhdr)) {
                continue;
            }

            if ("host".equals(lhdr)) {
                Enumeration<?> vals = httpRequest.getHeaders(hdr);
                while (vals.hasMoreElements()) {
                    String val = (String) vals.nextElement();
                    if (val.startsWith("127.0.0.1")) {
                        postMethod.addHeader(hdr, sslEndPoint);
                    }
                }
                continue;
            }

            Enumeration<?> vals = httpRequest.getHeaders(hdr);
            while (vals.hasMoreElements()) {
                String val = (String) vals.nextElement();
                if (val != null) {
                    postMethod.addHeader(hdr, val);
                }
            }
        }

        if (postMethod instanceof ExtendedPostMethod) {
            InputStreamEntity entity = new InputStreamEntity(capture, contentLength);
            entity.setContentType(request.getContentType());
            ((ExtendedPostMethod) postMethod).setEntity(entity);
        }

        java.net.URI uri = null;
        try {
            uri = new java.net.URI(this.prot + sslEndPoint);
        } catch (URISyntaxException e) {
            SoapUI.logError(e);
        }

        postMethod.getParams().setParameter(
                SoapUIHttpRoute.SOAPUI_SSL_CONFIG,
                settings.getString(SecurityTabForm.SSLTUNNEL_KEYSTOREPATH, "") + " "
                        + settings.getString(SecurityTabForm.SSLTUNNEL_KEYSTOREPASSWORD, ""));

        setProtocolversion(postMethod, request.getProtocol());

        String path = null;
        if (!sslEndPoint.contains("/")) {
            path = "/";
        } else {
            path = sslEndPoint.substring(sslEndPoint.indexOf("/"), sslEndPoint.length());
        }

        if (uri != null) {
            try {
                postMethod.setURI(URIUtils.createURI(uri.getScheme(), uri.getHost(), uri.getPort(), path, uri.getQuery(),
                        uri.getFragment()));
            } catch (URISyntaxException e) {
                SoapUI.logError(e);
            }
        }

        listenerCallBack.fireBeforeProxy(project, request, response, postMethod);

        if (settings.getBoolean(LaunchForm.SSLTUNNEL_REUSESTATE)) {
            if (httpState == null) {
                httpState = new BasicHttpContext();
            }
            HttpClientSupport.execute(postMethod, httpState);
        } else {
            HttpClientSupport.execute(postMethod);
        }
        capturedData.stopCapture();

        capturedData.setRequest(capture.getCapturedData());
        capturedData.setRawResponseBody(postMethod.getResponseBody());
        capturedData.setResponseHeader(postMethod.getHttpResponse());
        capturedData.setRawRequestData(getRequestToBytes(request.toString(), postMethod, capture));
        capturedData.setRawResponseData(getResponseToBytes(response.toString(), postMethod,
                capturedData.getRawResponseBody()));

        listenerCallBack.fireAfterProxy(project, request, response, postMethod, capturedData);
View Full Code Here

                }

            } // while intermediate response

            if (original instanceof ExtendedHttpMethod) {
                ExtendedHttpMethod extendedHttpMethod = (ExtendedHttpMethod) original;
                extendedHttpMethod.afterReadResponse(((SoapUIMultiThreadedHttpConnectionManager.SoapUIBasicPooledConnAdapter) conn).getSSLSession());
            }

            return response;
        }
View Full Code Here

TOP

Related Classes of com.eviware.soapui.impl.wsdl.submit.transports.http.ExtendedHttpMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.