• MaxSilveraN
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hello, 
I use APEX to call a SOAP Service that has been working fine in Salesforce, recently the service provider change his End Point (EP) from 190.XX.XX.XX/EP1 to 190.XX.XX.XX/EP2 but when I try to invoke the service from any of those EPs i get an html as a response, in addition when the service is called from the SOAP UI it works fine.

This is the body of the html response:

The following error was encountered while trying to retrieve the URL: http://190.XXX.XX.X/EP/index.php
Connection to 190.XXX.XX.X failed.
The system returned: (110) Connection timed out
The remote host or network may be down. Please try the request again.
Your cache administrator is support@salesforce.com.

Remote site setting are enabled and the soap action has been updated to the new EP
Has anybody been pass though this issue?
Hello Everyone,

I've been trying to do a test Method for a callOut class that invokes a Callout in a future Method, but this is returning System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out only in the test Execution, When running in the normal flow, it responses with no problem.

I've understood that this error is produced when doing a DML statement before a CallOut. However there's no operation besides the createData in the TestSetUp.

I've read some posts and the most likely was this one:  https://developer.salesforce.com/forums?id=906F0000000927CIAQ  .But the proposed solution of Test.StartTest();  Test.SetMock(); ... Test.EndTest()  is already developed.

This is the code returning the error
@isTest
global class RPP_SyncOportunidad_ws_tst {
    
    @testSetup
    static void createData()
    {
        Account acc = new Account();
        acc = new Account();
 		acc.Name='AVX_cuentaPrueba ';
        acc.RPP_NombreComercial__c='NombreComercial '; 
        insert acc;
        
        Contract contrato =  RPP_DataGenerator_cls.crearContrato(true, acc.Id);
        Opportunity objOpp = RPP_DataGenerator_cls.crearOpportunity(false,acc.Id);
        objOpp.RPP_Acuerdo__c= contrato.Id;

        insert objOpp;
    }
    
    public static testMethod void successTest()
    {
        List<Opportunity> lstOpps = [SELECT Id FROM Opportunity];
        Test.startTest();
        Test.setMock(HttpCalloutMock.class, new MockSuccessResponse());
        RPP_SyncOportunidad_ws mci = new RPP_SyncOportunidad_ws(lstOpps);
        Id jobId = System.enqueueJob(mci);
        Test.stopTest();
        
        System.assertNotEquals(mci, null, 'Test error: Cannot create invocacion ws');
    }
    
    global class MockSuccessResponse implements HttpCalloutMock
    {
        global HTTPResponse respond(HTTPRequest req)
        {
            HttpResponse res = new HttpResponse();
            res.setHeader('Content-Type', 'application/json');
            String strJSON ='[\n' +
                '{\n' +
                ' "CodigoError": null, \n' +
                ' "EntidadComercialId": "32201", \n' +
                ' "Estado": "S", \n' +
                ' "Mensaje": "Cliente registrado con éxito", \n' +
                ' "SalesForceGuid": "D58B1521-BAC2-4279" \n' +
                '}\n' +
                ']';                          
            res.setBody(strJSON);
            res.setStatus('OK');
            res.setStatusCode(200);
            return res;
        }
    }
}
It also happens that I have developed other CallOut classes with their own TestClasses and they work just fine.

Has anyone being in this issue?
Hello Everyone,

I've been trying to do a test Method for a callOut class that invokes a Callout in a future Method, but this is returning System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out only in the test Execution, When running in the normal flow, it responses with no problem.

I've understood that this error is produced when doing a DML statement before a CallOut. However there's no operation besides the createData in the TestSetUp.

I've read some posts and the most likely was this one:  https://developer.salesforce.com/forums?id=906F0000000927CIAQ  .But the proposed solution of Test.StartTest();  Test.SetMock(); ... Test.EndTest()  is already developed.

This is the code returning the error
@isTest
global class RPP_SyncOportunidad_ws_tst {
    
    @testSetup
    static void createData()
    {
        Account acc = new Account();
        acc = new Account();
 		acc.Name='AVX_cuentaPrueba ';
        acc.RPP_NombreComercial__c='NombreComercial '; 
        insert acc;
        
        Contract contrato =  RPP_DataGenerator_cls.crearContrato(true, acc.Id);
        Opportunity objOpp = RPP_DataGenerator_cls.crearOpportunity(false,acc.Id);
        objOpp.RPP_Acuerdo__c= contrato.Id;

        insert objOpp;
    }
    
    public static testMethod void successTest()
    {
        List<Opportunity> lstOpps = [SELECT Id FROM Opportunity];
        Test.startTest();
        Test.setMock(HttpCalloutMock.class, new MockSuccessResponse());
        RPP_SyncOportunidad_ws mci = new RPP_SyncOportunidad_ws(lstOpps);
        Id jobId = System.enqueueJob(mci);
        Test.stopTest();
        
        System.assertNotEquals(mci, null, 'Test error: Cannot create invocacion ws');
    }
    
    global class MockSuccessResponse implements HttpCalloutMock
    {
        global HTTPResponse respond(HTTPRequest req)
        {
            HttpResponse res = new HttpResponse();
            res.setHeader('Content-Type', 'application/json');
            String strJSON ='[\n' +
                '{\n' +
                ' "CodigoError": null, \n' +
                ' "EntidadComercialId": "32201", \n' +
                ' "Estado": "S", \n' +
                ' "Mensaje": "Cliente registrado con éxito", \n' +
                ' "SalesForceGuid": "D58B1521-BAC2-4279" \n' +
                '}\n' +
                ']';                          
            res.setBody(strJSON);
            res.setStatus('OK');
            res.setStatusCode(200);
            return res;
        }
    }
}
It also happens that I have developed other CallOut classes with their own TestClasses and they work just fine.

Has anyone being in this issue?