+ Start a Discussion
Pascal tagPascal tag 

Data Integration Specialist - Step 7 - The SOAP call to the BillingService did not return the correct response. Please check your configurations and code

Hi,
In Step 7 of Data Integration Specialist, even though code is working as expected ( project status changing from Billable to Bill), I keep on getting the following error :
The SOAP call to the BillingService did not return the correct response. Please check your configurations and code

I know that a similar discussion has been opened but as there's a best answer related to this and that it was initially about the Web Service being down, I want this trail to be dedicated to this issue only. Trying several ways to complete the challenge didn't give any result.

Please don't answer if you only want to say you face the same issue (click on like). Just reply if you resolved the issue or opened a case and mention it. Maybe if a lot of people open a case, Salesforce will fix the issue or be more specific on the issue.

Has someone passed step 7 of Superbadge "Data Integration Specialist" since 20 august 2018 ?
For information, I opened a case 00010194 but still no answer.
Pascal tagPascal tag
Finally, thanks to Andrea (& Hugo), the WSDL is not accurate.
projectid and projectRef must BOTH be provided !!!

For details, read :
https://developer.salesforce.com/forums/?id=9060G000000BeecQAC
 
Christopher Thaxter 4Christopher Thaxter 4

Thanks for the direction. To summarize and clarify for others, here are the steps to resolve:

The BillingServiceProxy class that was generated from the WSDL has a "project" subclass with the following public variables:
 

public String username;
public String password;
public String projectid;
public Double billAmount;


. . . as well as six private variables. Per the suggestion in the other thread linked in Pascal's comment of 8/24/2018, I added a fifth public variable:
 

public String projectRef;


Then, I went to my main handler class (BillingCalloutService) and assigned the new variable to exactly the same value as projectid. In other words, both projectid and projectRef take the external project ID. The Salesforce record ID is not used by the external system.

Once I did the above, I reran my tests and rechecked the challenge in Trailhead, and it worked like a charm!

Because this is clearly an error on Salesforce's part within the challenge checker and/or within the Heroku app, they will probably fix it at some point, and this solution may become obsolete. Hopefully that means people won't be searching for this issue online. If the above solution doesn't work in the future, but the issue is still coming up, my best suggestion would be to play with those two variables until something works (with one, with the other, etc.).

Happy Trails!

hpmohanhpmohan
Sombody give this man a cofee.. Your fix worked..  I have been scraching my head to find a solution for this. Thank you @Christopher Thaxter 4.
Eric HartyeEric Hartye
Thank you so much for posting your resolution to this issue!
jegadeesh G Rjegadeesh G R
@Christopher...Since 2 weeks I am trying to complete this challenge. Finally It worked. I could not even think about changing the auto-generated wsdl class. Thanks man. (Y)
sridhar -sridhar -
I tried adding
 
public String projectRef;

to the generated apex and set the corresponding field from my code. It's showing a new error 'Something went wrong. Please try again'.

Anybody facing a similar problem?

@jegadeesh G R. When did you complete the challenge?
Alex2lAlex2l
Thanks @Christopher. Your fix worked.
Roland Pennig 1Roland Pennig 1
Thank you very much, Christopher! Your fix worked perfekt! Finally I solved Step 7!
Chris Henson 15Chris Henson 15
Thank you all. I was really banging my head on this one till I found this thread.  Thanks again!
Sunnel MishraSunnel Mishra
@Christopher Thaxter 4 thanks !! correct solution
Alok DoraAlok Dora
@Christopher - I did it. But still I am getting the error. 
1. Added the Projectref in both the classes(BillingServiceProxy and BillingCalloutService).
Abhishek patil 26Abhishek patil 26
//Generated by wsdl2apex

public class BillingServiceProxy {
    public class billProjectRequest_element {
        public BillingServiceProxy.project project;
        private String[] project_type_info = new String[]{'project','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://salesforce.com/th/invoice-web-service','true','false'};
        private String[] field_order_type_info = new String[]{'project'};
    }
    public class project {
        public String username;
        public String password;
        public String projectid;
// add this line //
        public String projectRef;
//---------------//
        public Double billAmount;
        private String[] username_type_info = new String[]{'username','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
        private String[] password_type_info = new String[]{'password','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
        private String[] projectid_type_info = new String[]{'projectid','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
// add this one  /////
        private String[] projectRef_type_info = new String[]{'projectRef','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
//-----------------////
        private String[] billAmount_type_info = new String[]{'billAmount','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://salesforce.com/th/invoice-web-service','true','false'};
// add this one //
        private String[] field_order_type_info = new String[]{'username','password','projectid','projectRef','billAmount'};
//-------------------//

    }
    public class billProjectResponse_element {
        public String status;
        private String[] status_type_info = new String[]{'status','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://salesforce.com/th/invoice-web-service','true','false'};
        private String[] field_order_type_info = new String[]{'status'};
    }
    public class InvoicesPortSoap11 {
        public String endpoint_x = 'http://sb-integration-bs.herokuapp.com:80/ws';
        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[]{'http://salesforce.com/th/invoice-web-service', 'BillingServiceProxy'};
        public String billProject(BillingServiceProxy.project project) {
            BillingServiceProxy.billProjectRequest_element request_x = new BillingServiceProxy.billProjectRequest_element();
            request_x.project = project;
            BillingServiceProxy.billProjectResponse_element response_x;
            Map<String, BillingServiceProxy.billProjectResponse_element> response_map_x = new Map<String, BillingServiceProxy.billProjectResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://salesforce.com/th/invoice-web-service',
              'billProjectRequest',
              'http://salesforce.com/th/invoice-web-service',
              'billProjectResponse',
              'BillingServiceProxy.billProjectResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.status;
        }
    }
}

In above apex class " ProjectRef" variable is not there. this is salesforce issue i guess. so please add above three commented  lines to complete this challenge.
Anil Upreti 38Anil Upreti 38
@Christopher Thaxter 4,  Thanks a lot. Even I got struck in same issue. After your direction it got resolved.
Rahul Mukherji 26Rahul Mukherji 26
===================Updated WSDL Class================

//Generated by wsdl2apex

public class BillingServiceProxy {
    public class billProjectRequest_element {
        public BillingServiceProxy.project project;
        private String[] project_type_info = new String[]{'project','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://salesforce.com/th/invoice-web-service','true','false'};
        private String[] field_order_type_info = new String[]{'project'};
    }
    public class project {
        public String username;
        public String password;
        public String projectid;
        public String projectRef;
        public Double billAmount;
        
        private String[] username_type_info = new String[]{'username','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
        private String[] password_type_info = new String[]{'password','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
        private String[] projectid_type_info = new String[]{'projectid','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
        private String[] projectRef_type_info = new String[]{'projectRef','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
        private String[] billAmount_type_info = new String[]{'billAmount','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://salesforce.com/th/invoice-web-service','true','false'};
        private String[] field_order_type_info = new String[]{'username','password','projectid','projectRef','billAmount'};
    }
    public class billProjectResponse_element {
        public String status;
        private String[] status_type_info = new String[]{'status','http://salesforce.com/th/invoice-web-service',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://salesforce.com/th/invoice-web-service','true','false'};
        private String[] field_order_type_info = new String[]{'status'};
    }
    public class InvoicesPortSoap11 {
        public String endpoint_x = 'http://sb-integration-bs.herokuapp.com:80/ws';
        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[]{'http://salesforce.com/th/invoice-web-service', 'BillingServiceProxy'};
        public String billProject(BillingServiceProxy.project project) {
            BillingServiceProxy.billProjectRequest_element request_x = new BillingServiceProxy.billProjectRequest_element();
            request_x.project = project;
            BillingServiceProxy.billProjectResponse_element response_x;
            Map<String, BillingServiceProxy.billProjectResponse_element> response_map_x = new Map<String, BillingServiceProxy.billProjectResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://salesforce.com/th/invoice-web-service',
              'billProjectRequest',
              'http://salesforce.com/th/invoice-web-service',
              'billProjectResponse',
              'BillingServiceProxy.billProjectResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.status;
        }
    }
}
Rahul Mukherji 26Rahul Mukherji 26
================Updated Apex Trgger Handler Class for the trigger==============
public class BillingCalloutService {
    //Implement business and callout logic methods here
    //
    public static void callBillingService(List<Project__c> projectList){
        List<String> projectId = new List<String>();
        List<String> projectRef = new List<String>();
        List<Double> billedAmount = new List<Double>();
        String userName;
        String password;
        ServiceCredentials__c custSet = ServiceCredentials__c.getValues('BillingServiceCredential');
        userName = custSet.Username__c;
        password =custSet.Password__c;
        for(Project__c project : projectList){
            if(project.Status__c =='Billable'){
                projectId.add(project.Id);
                projectRef.add(project.ProjectRef__c);
                billedAmount.add(project.Billable_Amount__c);
                
            }
        }
        if(projectRef.size()>0 && billedAmount.size()>0){
            BillingCalloutService.callExtSys(username,password,projectId[0],projectRef[0],billedAmount[0]);
        }
    }
    
    @future(callout=true)
    public static void callExtSys(String userName,String password,String projectId,String projectRef,Double billedAmount){
        BillingServiceProxy.project proj = new BillingServiceProxy.project();
        proj.username =userName;
        proj.password =password;
        proj.projectid =projectId;
        proj.projectRef =projectRef;
        proj.billAmount =billedAmount;
        
        BillingServiceProxy.InvoicesPortSoap11 invoiceCallout = new BillingServiceProxy.InvoicesPortSoap11();
        try{
             String calloutResponse = invoiceCallout.billProject(proj);
            System.debug('calloutResponse:: '+calloutResponse);
            if(!String.isBlank(calloutResponse) && calloutResponse.equalsIgnoreCase('OK')){
                Project__c project =[SELECT Id,ProjectRef__c,Status__c,Billable_Amount__c FROM Project__c WHERE ProjectRef__c=:projectRef LIMIT 1];
                if(project !=NULL){
                    System.debug('project to update::'+project);
                    project.Status__c='Billed';
                    Database.update(project,false);
                }
            }
            if(test.isRunningTest()){
                CalloutException ex = new CalloutException();
                ex.setMessage('Test Message!');
                throw ex;
            }
        }
        catch(Exception e){
            System.debug('error at line:: '+e.getLineNumber());
            System.debug('error message:: '+e.getMessage());
        }
       
        
    }
}