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

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


    {
      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 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 multiplart
    Header responseContentTypeHeader = httpMethod.getResponseHeader( "Content-Type" );
    Response response = null;
    if( request instanceof WsdlRequest )
      response = wsdlRequest( context, ( WsdlRequest )request, httpMethod, responseContentTypeHeader, requestContent );
    else if( request instanceof HttpRequestInterface<?> )
      response = httpRequest( context, ( HttpRequestInterface<?> )request, httpMethod, responseContentTypeHeader,
View Full Code Here

public class HttpSettingsRequestFilter extends AbstractRequestFilter
{
  public void filterAbstractHttpRequest( SubmitContext context, AbstractHttpRequest<?> httpRequest )
  {
    ExtendedHttpMethod httpMethod = ( ExtendedHttpMethod )context.getProperty( BaseHttpRequestTransport.HTTP_METHOD );

    // set maxsize
    Settings settings = httpRequest.getSettings();

    // close connections?
    if( settings.getBoolean( HttpSettings.CLOSE_CONNECTIONS ) )
    {
      httpMethod.setRequestHeader( "Connection", "close" );
    }

    // close connections?
    if( settings.getBoolean( HttpSettings.EXPECT_CONTINUE ) && httpMethod instanceof EntityEnclosingMethod )
    {
      httpMethod.getParams().setParameter( HttpMethodParams.USE_EXPECT_CONTINUE, Boolean.TRUE );
    }

    // compress request?
    String compressionAlg = settings.getString( HttpSettings.REQUEST_COMPRESSION, "None" );
    if( !"None".equals( compressionAlg ) )
      httpMethod.setRequestHeader( "Content-Encoding", compressionAlg );

    // accept compressed responses?
    if( settings.getBoolean( HttpSettings.RESPONSE_COMPRESSION ) )
    {
      httpMethod.setRequestHeader( "Accept-Encoding", CompressionSupport.getAvailableAlgorithms( "," ) );
    }

    String httpVersion = settings.getString( HttpSettings.HTTP_VERSION, "1.1" );
    if( httpVersion.equals( HttpSettings.HTTP_VERSION_1_1 ) )
    {
      httpMethod.getParams().setVersion( HttpVersion.HTTP_1_1 );
    }
    else if( httpVersion.equals( HttpSettings.HTTP_VERSION_1_0 ) )
    {
      httpMethod.getParams().setVersion( HttpVersion.HTTP_1_0 );
    }
    else if( httpVersion.equals( HttpSettings.HTTP_VERSION_0_9 ) )
    {
      httpMethod.getParams().setVersion( HttpVersion.HTTP_1_1 );
    }

    // max size..
    long maxSize = httpRequest.getMaxSize();
    if( maxSize == 0 )
      maxSize = settings.getLong( HttpSettings.MAX_RESPONSE_SIZE, 0 );
    if( maxSize > 0 )
      httpMethod.setMaxSize( maxSize );

    // follow redirects is false; handled in transport
    httpMethod.setFollowRedirects( false );

    // apply global settings
    HttpClientSupport.applyHttpSettings( httpMethod, settings );

    String timeout = context.expand( httpRequest.getTimeout() );
    if( StringUtils.hasContent( timeout ) )
    {
      try
      {
        httpMethod.getParams().setSoTimeout( Integer.parseInt( timeout ) );
      }
      catch( NumberFormatException e )
      {
        SoapUI.logError( e );
      }
View Full Code Here

  {
    monitor.fireOnRequest( 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.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() ) );

    monitor.fireAfterProxy( request, response, postMethod, capturedData );

    StringToStringsMap responseHeaders = capturedData.getResponseHeaders();
    // copy headers to response
    HttpServletResponse httpResponse = ( HttpServletResponse )response;
    for( String name : responseHeaders.keySet() )
    {
      for( String header : responseHeaders.get( name ) )
        httpResponse.addHeader( name, header );

    }

    IO.copy( new ByteArrayInputStream( capturedData.getRawResponseBody() ), httpResponse.getOutputStream() );

    postMethod.releaseConnection();

    synchronized( this )
    {
      monitor.addMessageExchange( capturedData );
    }
View Full Code Here

    String compressionAlg = settings.getString( HttpSettings.REQUEST_COMPRESSION, "None" );
    if( !"None".equals( compressionAlg ) )
    {
      try
      {
        ExtendedHttpMethod method = ( ExtendedHttpMethod )context
            .getProperty( BaseHttpRequestTransport.HTTP_METHOD );
        if( method instanceof EntityEnclosingMethod )
        {
          RequestEntity requestEntity = method.getRequestEntity();
          if( requestEntity != null )
          {
            ByteArrayOutputStream tempOut = new ByteArrayOutputStream();
            requestEntity.writeRequest( tempOut );
View Full Code Here

{

  @Override
  public void filterAbstractHttpRequest( SubmitContext context, AbstractHttpRequest<?> request )
  {
    ExtendedHttpMethod httpMethod = ( ExtendedHttpMethod )context.getProperty( BaseHttpRequestTransport.HTTP_METHOD );
    Settings settings = request.getSettings();

    // chunking?
    if( httpMethod.getParams().getVersion().equals( HttpVersion.HTTP_1_1 )
        && httpMethod instanceof EntityEnclosingMethod )
    {
      EntityEnclosingMethod entityEnclosingMethod = ( ( EntityEnclosingMethod )httpMethod );
      long limit = settings.getLong( HttpSettings.CHUNKING_THRESHOLD, -1 );
      RequestEntity requestEntity = entityEnclosingMethod.getRequestEntity();
View Full Code Here

    {
      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

  {
    monitor.fireOnRequest( request, response );
    if( response.isCommitted() )
      return;

    ExtendedHttpMethod method;
    HttpServletRequest httpRequest = ( HttpServletRequest )request;
    if( httpRequest.getMethod().equals( "GET" ) )
      method = new ExtendedGetMethod();
    else
      method = new ExtendedPostMethod();

    method.setDecompress( false );

    // 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.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() ) );
    capturedData.setResponseContent( new String( method.getDecompressedResponseBody() ) );

    monitor.fireAfterProxy( request, response, method, capturedData );

    if( !response.isCommitted() )
    {
View Full Code Here

* @author Ole.Matzura
*/

public class HttpSettingsRequestFilter extends AbstractRequestFilter {
    public void filterAbstractHttpRequest(SubmitContext context, AbstractHttpRequest<?> httpRequest) {
        ExtendedHttpMethod httpMethod = (ExtendedHttpMethod) context.getProperty(BaseHttpRequestTransport.HTTP_METHOD);

        // set maxsize
        Settings settings = httpRequest.getSettings();

        // close connections?
        if (settings.getBoolean(HttpSettings.CLOSE_CONNECTIONS)) {
            httpMethod.setHeader("Connection", "close");
        }

        // close connections?
        if (settings.getBoolean(HttpSettings.EXPECT_CONTINUE) && httpMethod instanceof HttpEntityEnclosingRequest) {
            httpMethod.getParams().setParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, Boolean.TRUE);
        }

        // compress request?
        String compressionAlg = settings.getString(HttpSettings.REQUEST_COMPRESSION, "None");
        if (!"None".equals(compressionAlg)) {
            httpMethod.setHeader("Content-Encoding", compressionAlg);
        }

        // accept compressed responses?
        if (settings.getBoolean(HttpSettings.RESPONSE_COMPRESSION)) {
            httpMethod.setHeader("Accept-Encoding", CompressionSupport.getAvailableAlgorithms(","));
        }

        String httpVersion = settings.getString(HttpSettings.HTTP_VERSION, "1.1");
        if (httpVersion.equals(HttpSettings.HTTP_VERSION_1_1)) {
            httpMethod.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
        } else if (httpVersion.equals(HttpSettings.HTTP_VERSION_1_0)) {
            httpMethod.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_0);
        } else if (httpVersion.equals(HttpSettings.HTTP_VERSION_0_9)) {
            httpMethod.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
        }

        // max size..
        long maxSize = httpRequest.getMaxSize();
        if (maxSize == 0) {
            maxSize = settings.getLong(HttpSettings.MAX_RESPONSE_SIZE, 0);
        }
        if (maxSize > 0) {
            httpMethod.setMaxSize(maxSize);
        }

        // follow redirects is false; handled in transport
        httpMethod.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS, false);

        // apply global settings
        HttpClientSupport.applyHttpSettings(httpMethod, settings);

        String timeout = context.expand(httpRequest.getTimeout());
        if (StringUtils.hasContent(timeout)) {
            try {
                HttpConnectionParams.setSoTimeout(httpMethod.getParams(), Integer.parseInt(timeout));
            } catch (NumberFormatException e) {
                SoapUI.logError(e);
            }
        }
    }
View Full Code Here

public class PostPackagingRequestFilter extends AbstractRequestFilter {

    @Override
    public void filterAbstractHttpRequest(SubmitContext context, AbstractHttpRequest<?> request) {
        ExtendedHttpMethod httpMethod = (ExtendedHttpMethod) context.getProperty(BaseHttpRequestTransport.HTTP_METHOD);
        Settings settings = request.getSettings();

        // chunking?
        if (httpMethod.getProtocolVersion().equals(HttpVersion.HTTP_1_1)
                && httpMethod instanceof HttpEntityEnclosingRequest) {
            HttpEntityEnclosingRequest entityEnclosingMethod = ((HttpEntityEnclosingRequest) httpMethod);
            long limit = settings.getLong(HttpSettings.CHUNKING_THRESHOLD, -1);
            HttpEntity requestEntity = entityEnclosingMethod.getEntity();
            if (requestEntity != null && requestEntity instanceof AbstractHttpEntity) {
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.