1
  1. I have downloaded the WSDL file from this link: download.
  2. This WSDL contains 2 bindings, 2 ports so to generate apex class in Salesforce, I have removed the additional binding & port then I'm able to successfully generate apex class in Salesforce.
  3. After parsing, it generated 2 classes, I changed the names
    a. Authentications
    b. Authentication
  4. Apex Generated classes I have uploaded in GIthub https://github.com/ManjunadhManubolu/DevFiles/blob/master/ApexClass_1.txt https://github.com/ManjunadhManubolu/DevFiles/blob/master/ApexClass_2.txt

  5. In ApexClass_1.txt file, I manually added below code in "TokenResponse" inner class to avoid the error "Unable to find field status"

    public String Status;        
    public String TrxResult;
    public String TokenId;
    public Integer UserId;  
    private String[] Status_type_info = new String[]{'Status','http://www.campusmgmt.com/Soa/Foundation/MessageDefinition.xsd',null,'1','1','false'};
    private String[] TrxResult_type_info = new String[]{'TrxResult','http://www.campusmgmt.com/Soa/Foundation/MessageDefinition.xsd',null,'0','1','false'};
    private String[] TokenId_type_info = new String[]{'TokenId','http://www.campusmgmt.com/Soa/Foundation/MessageDefinition.xsd',null,'0','1','false'};
    private String[] UserId_type_info = new String[]{'UserId','http://www.campusmgmt.com/Soa/Foundation/MessageDefinition.xsd',null,'0','1','false'};
    
    1. Below error captured from Debug logs

      ErrorSecurity GeTrxResultBusinessLogicFailedMessage~One or more messages failed execution. Please check each message TrxResult value for more details.

    2. Below is my callout logic : GITBUBLINK

.

    Public class AuthUserNamePassword
    {
        public static String getSessionid()
        {
           String Access_Token;

           Authentication.TokenRequest reqParms = new Authentication.TokenRequest();
           reqParms.UserName = 'usernamehere';
           reqParms.Password = 'passwordhere';
           reqParms.StaffId=36205;


           Authentications.AuthenticationSoap req = new Authentications.AuthenticationSoap();
           Access_Token =''+ req.GetAuthorizationToken(reqParms);
           Account acc = new Account(Id='0017F000020VNEc',Description =Access_Token);
           Update acc;

           return Access_Token;
        }
    }
  1. Kindly suggest me what I'm missing here.

  2. I tested this service using SOAP UI, the response is generated without any issues (In the above point 5, I added additional fields because, in SOAP UI tool, the response contains additional fields but after generating apex class those fields are not there in TokenResponse class so I added there.)

1

If you run the code in a dev org and then capture the debug log you can see the full callout request and response in the corresponding CALLOUT_REQUEST and CALLOUT_RESPONSE log entries.

Request

<?xml version="1.0" encoding="utf-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <env:Header />
  <env:Body>
    <GetAuthorizationToken xmlns="http://www.campusmgmt.com/Soa/Foundation/">
      <TokenRequest>
        <UserName xmlns="http://www.campusmgmt.com/Soa/Foundation/MessageDefinition.xsd">usernamehere</UserName>
        <Password xmlns="http://www.campusmgmt.com/Soa/Foundation/MessageDefinition.xsd">passwordhere</Password>
        <StaffId xmlns="http://www.campusmgmt.com/Soa/Foundation/MessageDefinition.xsd">36205</StaffId>
      </TokenRequest>
    </GetAuthorizationToken>
  </env:Body>
</env:Envelope>

Response

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <ResponseHeader xmlns="http://www.campusmgmt.com/Soa/Foundation/">
      <Headers></Headers>
    </ResponseHeader>
  </soap:Header>
  <soap:Body>
    <GetAuthorizationTokenResponse xmlns="http://www.campusmgmt.com/Soa/Foundation/">
      <TokenResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.campusmgmt.com/Soa/Foundation/MessageDefinition.xsd">
        <Status>ErrorSecurity</Status>
        <TrxResult>GeTrxResultBusinessLogicFailedMessage~One or more messages failed execution. Please check each message TrxResult value for more details.</TrxResult>
        <TokenId />
      </TokenResponse>
    </GetAuthorizationTokenResponse>
  </soap:Body>
</soap:Envelope>

Salesforce is then throwing the exception:

System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element TrxResult.

Based on your Authentication.TokenResponse class that makes sense, as TrxResult is currently commented out. Try updating it as follows:

public class TokenResponse {
        public String Status;        
        public String TrxResult;
        public String TokenId;
        public Integer UserId;

        public String SecurityTransactionStatus;
        private String[] Status_type_info = new String[]{'Status','http://www.campusmgmt.com/Soa/Foundation/MessageDefinition.xsd',null,'1','1','false'};
        private String[] TrxResult_type_info = new String[]{'TrxResult','http://www.campusmgmt.com/Soa/Foundation/MessageDefinition.xsd',null,'0','1','false'};
        private String[] TokenId_type_info = new String[]{'TokenId','http://www.campusmgmt.com/Soa/Foundation/MessageDefinition.xsd',null,'0','1','false'};
        private String[] UserId_type_info = new String[]{'UserId','http://www.campusmgmt.com/Soa/Foundation/MessageDefinition.xsd',null,'0','1','false'};


        public String[] SecurityTransactionStatus_type_info = new String[]{'SecurityTransactionStatus','http://www.campusmgmt.com/Soa/Foundation/MessageDefinition.xsd',null,'0','1','false'};
        public String[] apex_schema_type_info = new String[]{'http://www.campusmgmt.com/Soa/Foundation/MessageDefinition.xsd','true','false'};
        public String[] field_order_type_info = new String[]{'Status','TrxResult','TokenId','UserId','SecurityTransactionStatus'};
    }

That will, at a minimum, allow you to read the response.

Authentication.TokenRequest reqParms = new Authentication.TokenRequest();
reqParms.UserName = 'usernamehere';
reqParms.Password = 'passwordhere';
reqParms.StaffId=36205;

Authentications.AuthenticationSoap req = new Authentications.AuthenticationSoap();
Authentication.TokenResponse response = req.GetAuthorizationToken(reqParms);
System.debug(response);

If you are still having issues, try adding the equavalient SOAP request for SOAP UI to the question. Obviously, change and real passwords or usernames before doing so. You could also include the expected response format.

  • Hi @Daniel, Thanks for your response. 1. I have removed the comments in the "Authentication" class. 2. Also added the fileds in "field_order_type_info" in the same class as per the response generated in SOAP UI tool. 3. Debug log request & Response, SOAP UI request & response I have added in the GIT HUB link: github.com/ManjunadhManubolu/SOAP_Implementation_Issue 4. The whole idea of this class is to get Sessionid from an external app and initiate the next calls. Kindly help me what else I'm missing. – Manjunadh Manubolu Sep 25 at 7:48

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.