0

I am using salesforce SOAP API version 8. This is Login code which i am using for login for Salesforce Soap API.

public String login(String userid, String passwd) {
    SoapBindingStub binding;
    un = userid;
    if (un.trim().length() == 0) {
        return null;
    }
    pw = passwd;
    if (pw.trim().length() == 0) {
        return null;
    }

    // Provide feed back while we create the web service binding
    //System.out.println(new Date()+" Creating the binding to the web service...");

    try {
        binding = (SoapBindingStub)new SforceServiceLocator().getSoap();

        binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, "https://login.salesforce.com/services/Soap/u/8.0");

    } catch (ServiceException ex) {
        System.out.println(new Date()+" ERROR: creating binding to soap service, error was: "+ ex.getMessage());
        WebServerLogger.getLogger().log(new LogEntry("SFClient","login",
                "Could not connect to SalesForce, some configuration problem! \n Exception Text ::" + ex.getMessage()));
        return null;
    }

    // set the session header for subsequent call authentication
    binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, binding._getProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY));

    //For login of Professional account holders
    String clientID = "ABC/ABC/";
    CallOptions co = new CallOptions();
    co.setClient(clientID);

    // bind it to the current soap session
    binding.setHeader("SforceService", "CallOptions", co);

    // Time out after 2 minute
    binding.setTimeout(120000);
    //Saving current session time
    sessionTime =  System.currentTimeMillis();

    // Attempt the login giving the user feedback
    System.out.println(new Date()+"GOING TO LOGIN AT SALESFORCE .... SFUserId :: "+userid);
    try {
        loginResult = binding.login(un, pw);
    } catch (LoginFault lf) {
        System.out.println(lf.getExceptionMessage());
        WebServerLogger.getLogger().log(new LogEntry("SFClient", "sfLogin",
                "Could not login to SalesForce ["+userid+"] \nLoginFault:: "+lf));
        return null;
    } catch (UnexpectedErrorFault uef) {
        System.out.println(uef.getExceptionMessage());
        uef.printStackTrace();
        WebServerLogger.getLogger().log(new LogEntry("SFClient", "sfLogin",
                "Unexpected error while logging in to salesforce ["+userid+"] \n Unexcepted Fault:: " + uef));
        this.setSynchError(uef.getFaultString());
        return null;
    } catch (RemoteException re) {
        System.out.println(re.getMessage());
        re.printStackTrace();
        WebServerLogger.getLogger().log(new LogEntry("SFClient","sfLogin",
                "Remote exception while logging in to salesforce ["+userid+"] \n Remote Exception::" + re));
        this.setSynchError(re.getMessage());
        return null;
    }

    //System.out.println(new Date()+" The session id is: " + loginResult.getSessionId());

    // set the session header for subsequent call authentication
    binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY,loginResult.getServerUrl());


    // Create a new session header object and set the session id to that
    // returned by the login
    SessionHeader sh = new SessionHeader();
    sh.setSessionId(loginResult.getSessionId());
    binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(), "SessionHeader", sh);

    loggedIn = true;

    sessions.put(un, loginResult.getSessionId());

    return loginResult.getSessionId();

}

loginResult = binding.login(un, pw); At this line i am getting this exception. But when i restart Tomcat its start working fine. I am Using tomcat 6.

; nested exception is:
Dec 17 02:26:22 localhost catalina.sh[9228]: org.xml.sax.SAXException: Invalid element in com.sforce.soap.partner.fault.UnexpectedErrorFault - upgradeURL
Dec 17 02:26:22 localhost catalina.sh[9228]: AxisFault
Dec 17 02:26:22 localhost catalina.sh[9228]: faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
Dec 17 02:26:22 localhost catalina.sh[9228]: faultSubcode:
Dec 17 02:26:22 localhost catalina.sh[9228]: faultString: org.xml.sax.SAXException: Invalid element in com.sforce.soap.partner.fault.UnexpectedErrorFault - upgradeURL
Dec 17 02:26:22 localhost catalina.sh[9228]: faultActor:
Dec 17 02:26:22 localhost catalina.sh[9228]: faultNode:
Dec 17 02:26:22 localhost catalina.sh[9228]: faultDetail:
Dec 17 02:26:22 localhost catalina.sh[9228]: {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: Invalid element in com.sforce.soap.partner.fault.UnexpectedErrorFault - upgradeURL
  • If it is working fine, what is the issue? – Saroj Bera Dec 19 '16 at 14:53
  • Its keep on producing like if i restart the tomcat its gone but after a few while like 20 or 30 min its start coming again. – Fazeen Ahmad Dec 19 '16 at 15:50
1

I faced the exact same error.

Problem: i was using Java 1.6 which does not have TLS 1.1 or higher support by default.

Now, there are two options to correct the situation:

  1. Use JVM parameter of -Dhttps.protocols=TLSv1.1,TLSv1.2

  2. Upgrade your java to 1.8 which uses TLS 1.2 (i used this one.)

Salesforce has discontinued the support TLS 1.0 from July, here is the reference: https://help.salesforce.com/articleView?id=000221207&type=1

  • I am using java 1.7 and due to some factor i cannot upgrade it to 1.8 is there any solution of this problem using java 1.7 and i tried the JVM parameter too but still the same problem. – Fazeen Ahmad Mar 29 '17 at 9:04
  • Did you verify that parameters passing is higher than TLSv1.0 in java 1.7 ? – Deepish Mar 30 '17 at 17:36
  • Yes I was passing TLSv1.1,TLSv1.2 and also tried them separately. – Fazeen Ahmad Apr 4 '17 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.