function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

delegated authentication for between two salesforce orgs

We have two orgs , one org has enabled DA(delegated authentication). followed below steps to connect from one org to another org
1. Enabled DA
2. Downloaded DA wsdl 
3. enabled single sign on permission to one of the user 
4. added default gateway URL 
5. WSDL parsed into other salesforce org
//Generated by wsdl2apex

public class authenticationSoapSforceCom {
    public class AuthenticateResult {
        public Boolean Authenticated;
        private String[] Authenticated_type_info = new String[]{'Authenticated','',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'','true','false'};
        private String[] field_order_type_info = new String[]{'Authenticated'};
    public class Authenticate {
        public String username;
        public String password;
        public String sourceIp;
        private String[] username_type_info = new String[]{'username','',null,'1','1','false'};
        private String[] password_type_info = new String[]{'password','',null,'1','1','false'};
        private String[] sourceIp_type_info = new String[]{'sourceIp','',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'','true','false'};
        private String[] field_order_type_info = new String[]{'username','password','sourceIp'};
    public class AuthenticationService {
        public String endpoint_x = '';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'', 'authenticationSoapSforceCom'};
        public Boolean Authenticate(String username,String password,String sourceIp) {
            authenticationSoapSforceCom.Authenticate request_x = new authenticationSoapSforceCom.Authenticate();
            request_x.username = username;
            request_x.password = password;
            request_x.sourceIp = sourceIp;
            authenticationSoapSforceCom.AuthenticateResult response_x;
            Map<String, authenticationSoapSforceCom.AuthenticateResult> response_map_x = new Map<String, authenticationSoapSforceCom.AuthenticateResult>();
            response_map_x.put('response_x', response_x);
              new String[]{endpoint_x,
            response_x = response_map_x.get('response_x');
            return response_x.Authenticated;

testing with developer console

authenticationSoapSforceCom.AuthenticationService   Stub = new authenticationSoapSforceCom.AuthenticationService ();


Getting below error:
System.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element '' but found ''

Please help to resolve this issue

ShashankShashank (Salesforce Developers) 
It could most probably be a firewall/whitelisting issue. If you are still facing this issue, please ensure you whitelist all salesforce IPs as per this article: