use of org.apache.axis2.client.Options in project tdi-studio-se by Talend.
the class SforceManagementUtil method needCompression.
public static void needCompression(SforceServiceStub stub, boolean needCompression) {
if (!needCompression) {
return;
}
Options options = stub._getServiceClient().getOptions();
options.setProperty(HTTPConstants.MC_ACCEPT_GZIP, Boolean.TRUE);
options.setProperty(HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE);
}
use of org.apache.axis2.client.Options in project tdi-studio-se by Talend.
the class SforceManagementUtil method setTimeout.
public static void setTimeout(SforceServiceStub stub, int timeout) {
Options options = stub._getServiceClient().getOptions();
options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, timeout);
options.setProperty(HTTPConstants.SO_TIMEOUT, timeout);
}
use of org.apache.axis2.client.Options in project tdi-studio-se by Talend.
the class SforceManagementUtil method setHttpProxy.
public static void setHttpProxy(SforceServiceStub stub) {
Options options = stub._getServiceClient().getOptions();
String httpsHost = System.getProperty("https.proxyHost");
String httpsPort = System.getProperty("https.proxyPort");
String httpsUser = System.getProperty("https.proxyUser");
String httpsPwd = System.getProperty("https.proxyPassword");
if (httpsHost != null) {
ProxyProperties proxyProperties = new ProxyProperties();
proxyProperties.setProxyName(httpsHost);
if (httpsPort != null) {
proxyProperties.setProxyPort(Integer.parseInt(httpsPort));
}
if (httpsUser != null && !"".equals(httpsUser)) {
proxyProperties.setUserName(httpsUser);
}
if (httpsPwd != null && !"".equals(httpsPwd)) {
proxyProperties.setPassWord(httpsPwd);
}
options.setProperty(HTTPConstants.PROXY, proxyProperties);
} else {
String host = System.getProperty("http.proxyHost");
String port = System.getProperty("http.proxyPort");
String user = System.getProperty("http.proxyUser");
String pwd = System.getProperty("http.proxyPassword");
if (host != null) {
ProxyProperties proxyProperties = new ProxyProperties();
proxyProperties.setProxyName(host);
if (port != null) {
proxyProperties.setProxyPort(Integer.parseInt(port));
}
if (user != null && !"".equals(user)) {
proxyProperties.setUserName(user);
}
if (pwd != null && !"".equals(pwd)) {
proxyProperties.setPassWord(pwd);
}
options.setProperty(HTTPConstants.PROXY, proxyProperties);
} else {
String socksHost = System.getProperty("socksProxyHost");
String socksPort = System.getProperty("socksProxyPort");
String socksUser = System.getProperty("java.net.socks.username");
String socksPwd = System.getProperty("java.net.socks.password");
if (socksHost != null) {
ProxyProperties proxyProperties = new ProxyProperties();
proxyProperties.setProxyName(socksHost);
if (socksPort != null) {
proxyProperties.setProxyPort(Integer.parseInt(socksPort));
}
if (socksUser != null && !"".equals(socksUser)) {
proxyProperties.setUserName(socksUser);
}
if (socksPwd != null && !"".equals(socksPwd)) {
proxyProperties.setPassWord(socksPwd);
}
options.setProperty(HTTPConstants.PROXY, proxyProperties);
}
}
}
// options.setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_PROTOCOL_VERSION,
// HTTPConstants.HEADER_PROTOCOL_10);
}
use of org.apache.axis2.client.Options in project tdi-studio-se by Talend.
the class MSCRMClient method setServiceClientOptions.
private static void setServiceClientOptions(ServiceClient sc, SecurityData securityData) throws AxisFault, XMLStreamException {
Options options = sc.getOptions();
options.setMessageId("urn:uuid:" + UUID.randomUUID().toString());
EndpointReference endPoint = new EndpointReference("http://www.w3.org/2005/08/addressing/anonymous");
options.setReplyTo(endPoint);
sc.setOptions(options);
sc.addHeader(createCRMSecurityHeaderBlock(securityData));
HttpTransportProperties.ProxyProperties proxyProps = getProxyProperties();
if (proxyProps != null) {
sc.getOptions().setProperty(HTTPConstants.PROXY, proxyProps);
}
try {
sc.engageModule("addressing");
} catch (AxisFault e) {
logger.error(e.getMessage());
throw e;
}
}
use of org.apache.axis2.client.Options in project tdi-studio-se by Talend.
the class MSCRMClient method doGetOnlineConnection.
/**
* URL for the Discovery Service For North America Microsoft account, discovery service url is
* https://dev.crm.dynamics.com/XRMServices/2011/Discovery.svc Microsoft office 365, discovery service url is
* https://disco.crm.dynamics.com/XRMServices/2011/Discovery.svc To use appropriate discovery service url for other
* environments refer http://technet.microsoft.com/en-us/library/gg309401.aspx
*
* @throws Exception
*/
public OrganizationServiceStub doGetOnlineConnection(String discoveryServiceURL) throws Exception {
try {
// Retrieve the authentication policy for the discovery service.
OnlineAuthenticationPolicy discoveryPolicy = new OnlineAuthenticationPolicy(discoveryServiceURL + FlatWSDLSuffix);
WsdlTokenManager discoeryTokenManager = new WsdlTokenManager();
// Authenticate the user using the discovery authentication policy.
SecurityData discoverySecurityData = discoeryTokenManager.authenticate(discoveryServiceURL, username, password, discoveryPolicy.getAppliesTo(), discoveryPolicy.getPolicy(), discoveryPolicy.getIssuerUri());
// Retrieve discovery stub using organization URL with the security data.
DiscoveryServiceStub discoveryServiceStub = createDiscoveryServiceStub(discoveryServiceURL, discoverySecurityData);
// Retrieve organization service url using discovery stub.
String orgUrl = discoverOrganizationUrl(discoveryServiceStub, orgName);
// The discovery service stub cannot be reused against the organization service
// as the Issuer and AppliesTo may differ between the discovery and organization services.
// Retrieve the authentication policy for the organization service.
OnlineAuthenticationPolicy organizationPolicy = new OnlineAuthenticationPolicy(orgUrl + FlatWSDLSuffix);
WsdlTokenManager orgTokenManager = new WsdlTokenManager();
// Authenticate the user using the organization authentication policy.
SecurityData securityData = orgTokenManager.authenticate(orgUrl, username, password, organizationPolicy.getAppliesTo(), organizationPolicy.getPolicy(), organizationPolicy.getIssuerUri());
// Retrieve organization stub using organization URL with the security data.
serviceStub = createOrganizationServiceStub(orgUrl, securityData);
Options options = serviceStub._getServiceClient().getOptions();
if (reuseHttpClient != null) {
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.REUSE_HTTP_CLIENT, reuseHttpClient);
}
if (timeout != null) {
options.setTimeOutInMilliSeconds(Long.valueOf(timeout));
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.SO_TIMEOUT, timeout);
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.CONNECTION_TIMEOUT, timeout);
}
} catch (IDiscoveryService_Execute_DiscoveryServiceFaultFault_FaultMessage e) {
throw new Exception(e.getFaultMessage().getDiscoveryServiceFault().getMessage());
}
return serviceStub;
}
Aggregations