Search in sources :

Example 1 with Options

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);
}
Also used : Options(org.apache.axis2.client.Options)

Example 2 with Options

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);
}
Also used : Options(org.apache.axis2.client.Options)

Example 3 with Options

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);
}
Also used : Options(org.apache.axis2.client.Options) ProxyProperties(org.apache.axis2.transport.http.HttpTransportProperties.ProxyProperties)

Example 4 with Options

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;
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) Options(org.apache.axis2.client.Options) HttpTransportProperties(org.apache.axis2.transport.http.HttpTransportProperties) ProxyProperties(org.apache.axis2.transport.http.HttpTransportProperties.ProxyProperties) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 5 with Options

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;
}
Also used : DiscoveryServiceStub(com.microsoft.schemas.xrm._2011.contracts.DiscoveryServiceStub) Options(org.apache.axis2.client.Options) OnlineAuthenticationPolicy(org.talend.ms.crm.sdk.OnlineAuthenticationPolicy) SecurityData(org.talend.ms.crm.sdk.SecurityData) IDiscoveryService_Execute_DiscoveryServiceFaultFault_FaultMessage(com.microsoft.schemas.xrm._2011.contracts.IDiscoveryService_Execute_DiscoveryServiceFaultFault_FaultMessage) WsdlTokenManager(org.talend.ms.crm.sdk.WsdlTokenManager) XMLStreamException(javax.xml.stream.XMLStreamException) RemoteException(java.rmi.RemoteException)

Aggregations

Options (org.apache.axis2.client.Options)5 ProxyProperties (org.apache.axis2.transport.http.HttpTransportProperties.ProxyProperties)2 DiscoveryServiceStub (com.microsoft.schemas.xrm._2011.contracts.DiscoveryServiceStub)1 IDiscoveryService_Execute_DiscoveryServiceFaultFault_FaultMessage (com.microsoft.schemas.xrm._2011.contracts.IDiscoveryService_Execute_DiscoveryServiceFaultFault_FaultMessage)1 RemoteException (java.rmi.RemoteException)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 AxisFault (org.apache.axis2.AxisFault)1 EndpointReference (org.apache.axis2.addressing.EndpointReference)1 HttpTransportProperties (org.apache.axis2.transport.http.HttpTransportProperties)1 OnlineAuthenticationPolicy (org.talend.ms.crm.sdk.OnlineAuthenticationPolicy)1 SecurityData (org.talend.ms.crm.sdk.SecurityData)1 WsdlTokenManager (org.talend.ms.crm.sdk.WsdlTokenManager)1