本文整理汇总了Java中org.springframework.ws.transport.http.HttpComponentsMessageSender类的典型用法代码示例。如果您正苦于以下问题:Java HttpComponentsMessageSender类的具体用法?Java HttpComponentsMessageSender怎么用?Java HttpComponentsMessageSender使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpComponentsMessageSender类属于org.springframework.ws.transport.http包,在下文中一共展示了HttpComponentsMessageSender类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GOClient
import org.springframework.ws.transport.http.HttpComponentsMessageSender; //导入依赖的package包/类
@Builder
private GOClient(
@NonNull final GOClientConfig config,
final GOClientLogger goClientLogger)
{
this.config = config;
this.goClientLogger = goClientLogger != null ? goClientLogger : SLF4JGOClientLogger.instance;
final HttpComponentsMessageSender messageSender = createMessageSender(config.getAuthUsername(), config.getAuthPassword());
final Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setPackagesToScan(de.metas.shipper.gateway.go.schema.ObjectFactory.class.getPackage().getName());
webServiceTemplate = new WebServiceTemplate();
webServiceTemplate.setDefaultUri(config.getUrl());
webServiceTemplate.setMessageSender(messageSender);
webServiceTemplate.setMarshaller(marshaller);
webServiceTemplate.setUnmarshaller(marshaller);
}
示例2: createMessageSender
import org.springframework.ws.transport.http.HttpComponentsMessageSender; //导入依赖的package包/类
private static HttpComponentsMessageSender createMessageSender(final String authUsername, final String authPassword)
{
final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(authUsername, authPassword);
final HttpComponentsMessageSender messageSender = new HttpComponentsMessageSender();
messageSender.setCredentials(credentials);
try
{
messageSender.afterPropertiesSet(); // to make sure credentials are set to HttpClient
}
catch (Exception ex)
{
throw AdempiereException.wrapIfNeeded(ex);
}
return messageSender;
}
示例3: afterPropertiesSet
import org.springframework.ws.transport.http.HttpComponentsMessageSender; //导入依赖的package包/类
public void afterPropertiesSet() throws Exception {
if (null==this.ws) {throw new IllegalStateException("null==ws");}
if (null==this.credentials) {throw new IllegalStateException("null==credentials");}
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
AuthScope authScope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT); //new UsernamePasswordCredentials(this.credentials.getUserPrincipal().getName(), this.credentials.getPassword()) ;
credentialsProvider.setCredentials( authScope, this.credentials );
org.apache.http.impl.client.CloseableHttpClient client =
org.apache.http.impl.client.HttpClients.custom()
.addInterceptorFirst( new PayRaiseWebServiceClientImpl.ContentLengthHeaderRemover() )
.addInterceptorFirst( new PayRaiseWebServiceClientImpl.PreemptiveAuthAdder() )
.setDefaultCredentialsProvider(credentialsProvider)
.setUserAgent( this.userAgent )
.build() ;
HttpComponentsMessageSender ms = new HttpComponentsMessageSender( client ) ;
//ms.setAuthScope(authScope);
//ms.setCredentials( this.credentials );
this.ws.setMessageSender(ms);
}
示例4: initGateway
import org.springframework.ws.transport.http.HttpComponentsMessageSender; //导入依赖的package包/类
@Override
protected void initGateway() throws Exception {
super.initGateway();
WebServiceMessageSender [] senders = getWebServiceTemplate().getMessageSenders();
for(WebServiceMessageSender sender: senders) {
if(sender instanceof HttpComponentsMessageSender) {
HttpComponentsMessageSender hSender = (HttpComponentsMessageSender) sender;
ClientConnectionManager connectionManager = hSender.getHttpClient().getConnectionManager();
SchemeRegistry schemeRegistry = connectionManager.getSchemeRegistry();
SSLSocketFactory sf = new SSLSocketFactory(keyStore, safeToString(keyStorePassword), trustStore);
Scheme https = new Scheme("https", 443, sf);
schemeRegistry.register(https);
log.info("initGateway connection manager with https scheme");
}
}
}
示例5: createAndInitWebServiceMessageSender
import org.springframework.ws.transport.http.HttpComponentsMessageSender; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private HttpComponentsMessageSender createAndInitWebServiceMessageSender(QName webServiceIdentifier) {
HttpComponentsMessageSender webServiceMessageSender = new HttpComponentsMessageSender();
webServiceMessageSender.setConnectionTimeout(30000); // 30 seconds connection timeout
webServiceMessageSender.setReadTimeout(120000); // 2 minutes read timeout on socket
if (config.getHttpForwardProxy(webServiceIdentifier) != null) {
Pair<String, Integer> forwardProxy = config.getHttpForwardProxy(webServiceIdentifier);
webServiceMessageSender
.getHttpClient()
.getParams()
.setParameter(org.apache.http.conn.params.ConnRoutePNames.DEFAULT_PROXY,
new HttpHost(forwardProxy.getLeft(), forwardProxy.getRight()));
}
return webServiceMessageSender;
}
示例6: createTemplate
import org.springframework.ws.transport.http.HttpComponentsMessageSender; //导入依赖的package包/类
private static WebServiceTemplate createTemplate(SaajSoapMessageFactory factory, Jaxb2Marshaller marshaller, EbmsAktoer remoteParty,
HttpComponentsMessageSender httpSender, ClientInterceptor[] interceptors) {
EbmsContextAwareWebServiceTemplate template = new EbmsContextAwareWebServiceTemplate(factory, remoteParty);
template.setMarshaller(marshaller);
template.setUnmarshaller(marshaller);
template.setFaultMessageResolver(new MessageSenderFaultMessageResolver(marshaller));
template.setMessageSender(httpSender);
template.setInterceptors(interceptors);
return template;
}
示例7: setHttpAuthenticationCredentials
import org.springframework.ws.transport.http.HttpComponentsMessageSender; //导入依赖的package包/类
public void setHttpAuthenticationCredentials(String username,String password){
sender=new HttpComponentsMessageSender();
UsernamePasswordCredentials credentials=new UsernamePasswordCredentials(username,password);
sender.setCredentials(credentials);
try {
sender.afterPropertiesSet();
} catch (Exception e) {
throw new RuntimeException(e);
}
this.getWebServiceTemplate().setMessageSender(sender);
}
示例8: webServiceMessageSender
import org.springframework.ws.transport.http.HttpComponentsMessageSender; //导入依赖的package包/类
@Bean
public WebServiceMessageSender webServiceMessageSender() {
HttpComponentsMessageSender httpComponentsMessageSender = new HttpComponentsMessageSender();
// timeout for creating a connection
httpComponentsMessageSender.setConnectionTimeout(timeout);
// when you have a connection, timeout the read blocks for
httpComponentsMessageSender.setReadTimeout(timeout);
return httpComponentsMessageSender;
}
示例9: prepareMessageSenders
import org.springframework.ws.transport.http.HttpComponentsMessageSender; //导入依赖的package包/类
private void prepareMessageSenders(SpringWebserviceConfiguration configuration) {
// Skip this whole thing if none of the relevant config options are set.
if (!(configuration.getTimeout() > -1) && configuration.getSslContextParameters() == null) {
return;
}
WebServiceTemplate webServiceTemplate = configuration.getWebServiceTemplate();
WebServiceMessageSender[] messageSenders = webServiceTemplate.getMessageSenders();
for (int i = 0; i < messageSenders.length; i++) {
WebServiceMessageSender messageSender = messageSenders[i];
if (messageSender instanceof HttpComponentsMessageSender) {
if (configuration.getSslContextParameters() != null) {
LOG.warn("Not applying SSLContextParameters based configuration to HttpComponentsMessageSender. "
+ "If you are using this MessageSender, which you are not by default, you will need "
+ "to configure SSL using the Commons HTTP 3.x Protocol registry.");
}
if (configuration.getTimeout() > -1) {
if (messageSender.getClass().equals(HttpComponentsMessageSender.class)) {
((HttpComponentsMessageSender) messageSender).setReadTimeout(configuration.getTimeout());
} else {
LOG.warn("Not applying timeout configuration to HttpComponentsMessageSender based implementation. "
+ "You are using what appears to be a custom MessageSender, which you are not doing by default. "
+ "You will need configure timeout on your own.");
}
}
} else if (messageSender.getClass().equals(HttpUrlConnectionMessageSender.class)) {
// Only if exact match denoting likely use of default configuration. We don't want to get
// sub-classes that might have been otherwise injected.
messageSenders[i] = new AbstractHttpWebServiceMessageSenderDecorator((HttpUrlConnectionMessageSender) messageSender, configuration, getEndpoint().getCamelContext());
} else {
// For example this will be the case during unit-testing with the net.javacrumbs.spring-ws-test API
LOG.warn("Ignoring the timeout and SSLContextParameters options for {}. You will need to configure "
+ "these options directly on your custom configured WebServiceMessageSender", messageSender);
}
}
}
示例10: getHttpComponentsMessageSender
import org.springframework.ws.transport.http.HttpComponentsMessageSender; //导入依赖的package包/类
private HttpComponentsMessageSender getHttpComponentsMessageSender() {
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
connectionManager.setValidateAfterInactivity((int)validateAfterInactivity.toMillis());
connectionManager.setMaxTotal(maxTotal);
connectionManager.setDefaultMaxPerRoute(defaultMaxPerRoute);
RequestConfig.Builder requestConfigBuilder = RequestConfig.copy(RequestConfig.DEFAULT).setSocketTimeout(socketTimeout)
.setConnectTimeout(connectTimeout).setConnectionRequestTimeout(connectionRequestTimeout)
.setCookieSpec(CookieSpecs.IGNORE_COOKIES);
if (httpHost != null) {
requestConfigBuilder.setProxy(httpHost);
}
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
SocketConfig socketConfig = SocketConfig.custom().setSoTimeout(connectTimeout).build();
httpClientBuilder.setDefaultSocketConfig(socketConfig);
for (HttpRequestInterceptor httpRequestInterceptor : httpRequestInterceptors) {
httpClientBuilder.addInterceptorFirst(httpRequestInterceptor);
}
for (HttpResponseInterceptor httpResponseInterceptor : httpResponseInterceptors) {
httpClientBuilder.addInterceptorFirst(httpResponseInterceptor);
}
CloseableHttpClient client = httpClientBuilder.addInterceptorFirst(new RemoveContentLengthInterceptor())
.setConnectionManager(connectionManager).setDefaultRequestConfig(requestConfigBuilder.build()).build();
return new HttpComponentsMessageSender(client);
}