Package com.eviware.soapui.impl.wsdl.monitor

Examples of com.eviware.soapui.impl.wsdl.monitor.CaptureInputStream


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

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

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

      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.addRequestHeader( hdr, sslEndPoint );
          }
        }
        continue;
      }

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

    }

    if( postMethod instanceof ExtendedPostMethod )
      ( ( ExtendedPostMethod )postMethod ).setRequestEntity( new InputStreamRequestEntity( capture, request
          .getContentType() ) );

    HostConfiguration hostConfiguration = new HostConfiguration();

    httpRequest.getProtocol();
    hostConfiguration.getParams().setParameter(
        SoapUIHostConfiguration.SOAPUI_SSL_CONFIG,
        settings.getString( SecurityTabForm.SSLTUNNEL_KEYSTOREPATH, "" ) + " "
            + settings.getString( SecurityTabForm.SSLTUNNEL_KEYSTOREPASSWORD, "" ) );
    hostConfiguration.setHost( new URI( this.prot + sslEndPoint, true ) );

    hostConfiguration = ProxyUtils.initProxySettings( settings, httpState, hostConfiguration, prot + sslEndPoint,
        new DefaultPropertyExpansionContext( project ) );

    if( sslEndPoint.indexOf( "/" ) < 0 )
      postMethod.setPath( "/" );
    else
      postMethod.setPath( sslEndPoint.substring( sslEndPoint.indexOf( "/" ), sslEndPoint.length() ) );

    monitor.fireBeforeProxy( request, response, postMethod, hostConfiguration );

    if( settings.getBoolean( LaunchForm.SSLTUNNEL_REUSESTATE ) )
    {
      if( httpState == null )
        httpState = new HttpState();
      HttpClientSupport.getHttpClient().executeMethod( hostConfiguration, postMethod, httpState );
    }
    else
    {
      HttpClientSupport.getHttpClient().executeMethod( hostConfiguration, postMethod );
    }
    capturedData.stopCapture();

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


    capturedData.setRequestMethod( httpRequest.getMethod() );
    capturedData.setRequestHeader( httpRequest );
    capturedData.setHttpRequestParameters( httpRequest );
    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.indexOf( "keep-alive" ) < 0 && connectionHeader.indexOf( "close" ) < 0 )
        connectionHeader = null;
    }

    // copy headers
    boolean xForwardedFor = false;
    @SuppressWarnings( "unused" )
    long contentLength = -1;
    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.indexOf( lhdr ) >= 0 )
        continue;

      if( "content-length".equals( lhdr ) )
        contentLength = request.getContentLength();

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

    // Proxy headers
    method.setRequestHeader( "Via", "SoapUI Monitor" );
    if( !xForwardedFor )
      method.addRequestHeader( "X-Forwarded-For", request.getRemoteAddr() );

    if( method instanceof ExtendedPostMethod )
      ( ( ExtendedPostMethod )method ).setRequestEntity( new InputStreamRequestEntity( capture, request
          .getContentType() ) );

    HostConfiguration hostConfiguration = new HostConfiguration();

    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() );
      method.setPath( httpRequest.getServletPath() );
      if( httpRequest.getQueryString() != null )
      {
        url.append( "?" + httpRequest.getQueryString() );
        method.setPath( httpRequest.getServletPath() + "?" + httpRequest.getQueryString() );
      }
    }
    hostConfiguration.setHost( new URI( url.toString(), true ) );

    // SoapUI.log("PROXY to:" + url);

    monitor.fireBeforeProxy( request, response, method, hostConfiguration );

    if( settings.getBoolean( LaunchForm.SSLTUNNEL_REUSESTATE ) )
    {
      if( httpState == null )
        httpState = new HttpState();
      HttpClientSupport.getHttpClient().executeMethod( hostConfiguration, method, httpState );
    }
    else
    {
      HttpClientSupport.getHttpClient().executeMethod( hostConfiguration, method );
    }

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

    capturedData.setRequest( capture.getCapturedData() );
    capturedData.setRawResponseBody( method.getResponseBody() );
    capturedData.setResponseHeader( method );
    capturedData.setRawRequestData( getRequestToBytes( request.toString(), method, capture ) );
    capturedData.setRawResponseData( getResponseToBytes( response.toString(), method,
        capturedData.getRawResponseBody() ) );
View Full Code Here

    this.request = request;
    try
    {
      contentType = request.getContentType();
      name = "Request for " + request.getPathInfo();
      capture = new CaptureInputStream( request.getInputStream(), SoapUI.getSettings().getLong(
          UISettings.RAW_REQUEST_MESSAGE_SIZE, 0 ) );
    }
    catch( Exception e )
    {
      SoapUI.logError( e );
View Full Code Here

        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()));
View Full Code Here

    public MockRequestDataSource(HttpServletRequest request) {
        this.request = request;
        try {
            contentType = request.getContentType();
            name = "Request for " + request.getPathInfo();
            capture = new CaptureInputStream(request.getInputStream(), SoapUI.getSettings().getLong(
                    UISettings.RAW_REQUEST_MESSAGE_SIZE, 0));
        } catch (Exception e) {
            SoapUI.logError(e);
        }
    }
View Full Code Here

TOP

Related Classes of com.eviware.soapui.impl.wsdl.monitor.CaptureInputStream

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.