本文整理汇总了Java中org.apache.axis2.transport.http.HttpTransportProperties.ProxyProperties方法的典型用法代码示例。如果您正苦于以下问题:Java HttpTransportProperties.ProxyProperties方法的具体用法?Java HttpTransportProperties.ProxyProperties怎么用?Java HttpTransportProperties.ProxyProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.transport.http.HttpTransportProperties
的用法示例。
在下文中一共展示了HttpTransportProperties.ProxyProperties方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStubs
import org.apache.axis2.transport.http.HttpTransportProperties; //导入方法依赖的package包/类
private Stubs getStubs(String serverUrl) throws Exception
{
final ConfigurationContext ctx = getConfiguration();
final HttpTransportProperties.ProxyProperties proxyProperties = new HttpTransportProperties.ProxyProperties();
final ProxyDetails proxy = configService.getProxyDetails();
if( proxy.isConfigured() && !proxy.isHostExcepted(new URL(serverUrl).getHost()) )
{
proxyProperties.setProxyName(proxy.getHost());
proxyProperties.setProxyPort(proxy.getPort());
ctx.setProperty(HTTPConstants.PROXY, proxyProperties);
}
ctx.setProperty(HTTPConstants.SO_TIMEOUT, 120000);
ctx.setProperty(HTTPConstants.CONNECTION_TIMEOUT, 120000);
return new Stubs(ctx, serverUrl);
}
示例2: initMassSpecAPIStub
import org.apache.axis2.transport.http.HttpTransportProperties; //导入方法依赖的package包/类
protected MassSpecAPIStub initMassSpecAPIStub() throws Exception {
MassSpecAPIStub stub = new MassSpecAPIStub();
stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, false);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT, 3 * 60 * 1000);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, 3 * 60 * 1000);
stub._getServiceClient().getOptions().setCallTransportCleanup(true);
//set proxy if available
if(this.settings.containsKey(VariableNames.CHEMSPIDER_PROXY_SERVER)
&& this.settings.containsKey(VariableNames.CHEMSPIDER_PROXY_PORT)
&& this.settings.get(VariableNames.CHEMSPIDER_PROXY_SERVER) != null
&& this.settings.get(VariableNames.CHEMSPIDER_PROXY_PORT) != null)
{
HttpTransportProperties.ProxyProperties pp = new HttpTransportProperties.ProxyProperties();
try {
pp.setProxyName((String)this.settings.get(VariableNames.CHEMSPIDER_PROXY_SERVER));
pp.setProxyPort(Integer.parseInt((String)this.settings.get(VariableNames.CHEMSPIDER_PROXY_PORT)));
} catch(Exception e) {
e.printStackTrace();
this.logger.error("Error: Could not set proxy settings. Please check input.");
throw new Exception();
}
stub._getServiceClient().getOptions().setProperty(HTTPConstants.PROXY,pp);
}
return stub;
}
示例3: initSearchStub
import org.apache.axis2.transport.http.HttpTransportProperties; //导入方法依赖的package包/类
protected SearchStub initSearchStub() throws Exception {
SearchStub searchStub = new SearchStub();
searchStub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, false);
searchStub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT, 3 * 60 * 1000);
searchStub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, 3 * 60 * 1000);
//set proxy if available
if(this.settings.containsKey(VariableNames.CHEMSPIDER_PROXY_SERVER)
&& this.settings.containsKey(VariableNames.CHEMSPIDER_PROXY_PORT)
&& this.settings.get(VariableNames.CHEMSPIDER_PROXY_SERVER) != null
&& this.settings.get(VariableNames.CHEMSPIDER_PROXY_PORT) != null)
{
HttpTransportProperties.ProxyProperties pp = new HttpTransportProperties.ProxyProperties();
try {
pp.setProxyName((String)this.settings.get(VariableNames.CHEMSPIDER_PROXY_SERVER));
pp.setProxyPort(Integer.parseInt((String)this.settings.get(VariableNames.CHEMSPIDER_PROXY_PORT)));
} catch(Exception e) {
this.logger.error("Error: Could not set proxy settings. Please check input.");
throw new Exception();
}
searchStub._getServiceClient().getOptions().setProperty(HTTPConstants.PROXY,pp);
}
return searchStub;
}
示例4: updateServiceClientOptions
import org.apache.axis2.transport.http.HttpTransportProperties; //导入方法依赖的package包/类
private void updateServiceClientOptions(String trpUrl, String addUrl, String prxUrl) throws AxisFault {
Options options = new Options();
options.setTo(new EndpointReference(trpUrl));
options.setAction("urn:sampleOperation");
options.setTimeOutInMilliSeconds(10000000);
// set addressing, transport and proxy url
if (addUrl != null && !"null".equals(addUrl)) {
serviceClient.engageModule("addressing");
options.setTo(new EndpointReference(addUrl));
}
if (trpUrl != null && !"null".equals(trpUrl)) {
options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl);
} else {
serviceClient.engageModule("addressing");
}
serviceClient.engageModule("addressing");
if (prxUrl != null && !"null".equals(prxUrl)) {
HttpTransportProperties.ProxyProperties proxyProperties =
new HttpTransportProperties.ProxyProperties();
try {
URL url = new URL(prxUrl);
proxyProperties.setProxyName(url.getHost());
proxyProperties.setProxyPort(url.getPort());
proxyProperties.setUserName("");
proxyProperties.setPassWord("");
proxyProperties.setDomain("");
options.setProperty(HTTPConstants.PROXY, proxyProperties);
} catch (MalformedURLException e) {
String msg = "Error while creating proxy URL";
log.error(msg, e);
throw new AxisFault(msg, e);
}
}
serviceClient.setOptions(options);
}
示例5: setupStub
import org.apache.axis2.transport.http.HttpTransportProperties; //导入方法依赖的package包/类
public static void setupStub(final @NotNull Stub stub, final @NotNull Credentials credentials, final @NotNull URI serverUri) {
Options options = stub._getServiceClient().getOptions();
// http params
options.setProperty(HTTPConstants.CHUNKED, Constants.VALUE_FALSE);
options.setProperty(HTTPConstants.MC_ACCEPT_GZIP, Boolean.TRUE);
options.setProperty(HTTPConstants.SO_TIMEOUT, SOCKET_TIMEOUT);
if (Registry.is("tfs.set.connection.timeout", false)) {
options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, SOCKET_TIMEOUT);
}
// credentials
if (credentials.getType() == Credentials.Type.Alternate) {
String basicAuth =
BasicScheme.authenticate(new UsernamePasswordCredentials(credentials.getUserName(), credentials.getPassword()), "UTF-8");
Map<String, String> headers = new HashMap<String, String>();
headers.put(HTTPConstants.HEADER_AUTHORIZATION, basicAuth);
options.setProperty(HTTPConstants.HTTP_HEADERS, headers);
}
else {
HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
auth.setUsername(credentials.getUserName());
auth.setPassword(credentials.getPassword() != null ? credentials.getPassword() : "");
auth.setDomain(credentials.getDomain());
auth.setHost(serverUri.getHost());
options.setProperty(HTTPConstants.AUTHENTICATE, auth);
HttpMethodParams params = new HttpMethodParams();
params.setBooleanParameter(USE_NATIVE_CREDENTIALS, credentials.getType() == Credentials.Type.NtlmNative);
options.setProperty(HTTPConstants.HTTP_METHOD_PARAMS, params);
}
// proxy
final HttpTransportProperties.ProxyProperties proxyProperties;
final HTTPProxyInfo proxy = HTTPProxyInfo.getCurrent();
if (proxy.host != null) {
proxyProperties = new HttpTransportProperties.ProxyProperties();
Pair<String, String> domainAndUser = getDomainAndUser(proxy.user);
proxyProperties.setProxyName(proxy.host);
proxyProperties.setProxyPort(proxy.port);
proxyProperties.setDomain(domainAndUser.first);
proxyProperties.setUserName(domainAndUser.second);
proxyProperties.setPassWord(proxy.password);
}
else {
proxyProperties = null;
}
options.setProperty(HTTPConstants.PROXY, proxyProperties);
}
示例6: testEchoXMLSync
import org.apache.axis2.transport.http.HttpTransportProperties; //导入方法依赖的package包/类
public void testEchoXMLSync() throws Exception {
OMElement payload = TestingUtils.createDummyOMElement();
/**
* Proxy setting in runtime
*/
HttpTransportProperties.ProxyProperties proxyproperties =
new HttpTransportProperties.ProxyProperties();
proxyproperties.setProxyName("localhost");
proxyproperties.setProxyPort(5555);
proxyproperties.setDomain("anonymous");
proxyproperties.setPassWord("anonymous");
proxyproperties.setUserName("anonymous");
Options options = new Options();
options.setProperty(HTTPConstants.PROXY, proxyproperties);
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
ConfigurationContext configContext =
ConfigurationContextFactory.createConfigurationContextFromFileSystem(
null, null);
ServiceClient sender = new ServiceClient(configContext, null);
sender.setOptions(options);
OMElement result = sender.sendReceive(payload);
TestingUtils.compareWithCreatedOMElement(result);
}
示例7: ProxyUtil
import org.apache.axis2.transport.http.HttpTransportProperties; //导入方法依赖的package包/类
public ProxyUtil(String ip, int porta, String usuario,String senha) {
proxyProperties = new HttpTransportProperties.ProxyProperties();
proxyProperties.setProxyName(ip);
proxyProperties.setProxyPort(porta);
proxyProperties.setUserName(usuario);
proxyProperties.setPassWord(senha);
}