httpState = new HttpState();
submitContext.setProperty( SubmitContext.HTTP_STATE_PROPERTY, httpState );
createdState = true;
}
HostConfiguration hostConfiguration = new HostConfiguration();
String localAddress = System.getProperty( "soapui.bind.address", httpRequest.getBindAddress() );
if( localAddress == null || localAddress.trim().length() == 0 )
localAddress = SoapUI.getSettings().getString( HttpSettings.BIND_ADDRESS, null );
if( localAddress != null && localAddress.trim().length() > 0 )
{
try
{
hostConfiguration.setLocalAddress( InetAddress.getByName( localAddress ) );
}
catch( Exception e )
{
SoapUI.logError( e, "Failed to set localAddress to [" + localAddress + "]" );
}
}
submitContext.removeProperty( RESPONSE );
submitContext.setProperty( HTTP_METHOD, httpMethod );
submitContext.setProperty( POST_METHOD, httpMethod );
submitContext.setProperty( HTTP_CLIENT, httpClient );
submitContext.setProperty( REQUEST_CONTENT, httpRequest.getRequestContent() );
submitContext.setProperty( HOST_CONFIGURATION, hostConfiguration );
submitContext.setProperty( WSDL_REQUEST, httpRequest );
submitContext.setProperty( RESPONSE_PROPERTIES, new StringToStringMap() );
for( RequestFilter filter : filters )
{
filter.filterRequest( submitContext, httpRequest );
}
try
{
Settings settings = httpRequest.getSettings();
// custom http headers last so they can be overridden
StringToStringsMap headers = httpRequest.getRequestHeaders();
// first remove so we don't get any unwanted duplicates
for( String header : headers.keySet() )
{
httpMethod.removeRequestHeader( header );
}
// now add
for( String header : headers.keySet() )
{
for( String headerValue : headers.get( header ) )
{
headerValue = PropertyExpander.expandProperties( submitContext, headerValue );
httpMethod.addRequestHeader( header, headerValue );
}
}
// do request
WsdlProject project = ( WsdlProject )ModelSupport.getModelItemProject( httpRequest );
WssCrypto crypto = null;
if( project != null && project.getWssContainer() != null )
{
crypto = project.getWssContainer().getCryptoByName(
PropertyExpander.expandProperties( submitContext, httpRequest.getSslKeystore() ) );
}
if( crypto != null && WssCrypto.STATUS_OK.equals( crypto.getStatus() ) )
{
hostConfiguration.getParams().setParameter( SoapUIHostConfiguration.SOAPUI_SSL_CONFIG,
crypto.getSource() + " " + crypto.getPassword() );
}
// dump file?
httpMethod.setDumpFile( PathUtils.expandPath( httpRequest.getDumpFile(),
( AbstractWsdlModelItem<?> )httpRequest, submitContext ) );
// fix absolute URIs due to peculiarity in httpclient
URI uri = ( URI )submitContext.getProperty( BaseHttpRequestTransport.REQUEST_URI );
if( uri != null && uri.isAbsoluteURI() )
{
hostConfiguration.setHost( uri.getHost(), uri.getPort() );
String str = uri.toString();
int ix = str.indexOf( '/', str.indexOf( "//" ) + 2 );
if( ix != -1 )
{
uri = new URI( str.substring( ix ), true );