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
Ramandeep_SinghRamandeep_Singh 

Problem in setting mock responses for web services

hi guys,

i am having problem while setting mock responses for my web service.....here is the code....please provide with some solution
 
******************************************code for the web service************************************************************
public String synchronizeAX(String sdfcObjectId,String sfdcObjectName,String companyName,String operationtype,ID stagingStatusId) {
            string xml;
            OAC_AXIntegrate.synchronizeAX_element request_x = new OAC_AXIntegrate.synchronizeAX_element();
            OAC_AXIntegrate.synchronizeAXResponse_element response_x;
            request_x.sdfcObjectId = sdfcObjectId;
            request_x.sfdcObjectName = sfdcObjectName;
            request_x.companyName = companyName;
            request_x.operationtype = operationtype;
            request_x.domain = domain_x;
            request_x.username = username_x;
            request_x.password = password_x;
            Map<String, OAC_AXIntegrate.synchronizeAXResponse_element> response_map_x = new Map<String, OAC_AXIntegrate.synchronizeAXResponse_element>();
            response_map_x.put('response_x', response_x);
            //stagingStatusId = OAC_AXSynchronize.createStagingData(sdfcObjectId,sfdcObjectName,companyName,operationtype); 
                        WebServiceCallout.invoke(
                this,
                request_x,
                response_map_x,
                new String[]{endpoint_x,
                'http://tempuri.org/IAXSdfcService/synchronizeAX',
                'http://tempuri.org/',
                'synchronizeAX',
                'http://tempuri.org/',
                'synchronizeAXResponse',
                'OAC_AXIntegrate.synchronizeAXResponse_element'}
            );
            
            response_x = response_map_x.get('response_x');
                 system.debug('---message----'+response_x);
            
          
           xml = this.getXml(sdfcObjectId,sfdcObjectName,companyName);
           OAC_AXSynchronize.updateStagingData(sdfcObjectId,companyName,sfdcObjectName,stagingStatusId,response_x.synchronizeAXResult,xml);
         return response_x.synchronizeAXResult;
            
            
        }



*********************************​code for the  mock response for web service************************************************
@isTest
global class  mocksyncax implements WebServiceMock {
   global void doInvoke(
           Object stub,
           Object request,
           Map<String, Object> response,
           String endpoint,
           String soapAction,
           String requestName,
           String responseNS,
           String responseName,
           string responseType) {

// Create response element from the autogenerated class.
        OAC_AXIntegrate.synchronizeAXResponse_element reselement   = new  OAC_AXIntegrate.synchronizeAXResponse_element();
//Here createRecordResponse_element is an inner class in generated service class for preparing response
// Populate response element.
       reselement.synchronizeAXResult='welcome';
// Add response element to the response parameter, as follows:
        response.put('response_x', reselement);
   }
      
}


**********************************this is my test class***********************************

@isTest
private class CalloutClassTest {

  
    
     @isTest static void testEchoString() {   
         
         
        
       

      // Test.setMock(WebServiceMock.class, new mocksyncax());
        
        // Call the method that invokes a callout
        
      // string ressyncax = axservice.synchronizeAX('0011700000Po7oaAAB','Account','OA','Insert','a0117000004ynJuAAI');
          
         
        
         

    }
    }
i am getting the following error:
FATAL_ERROR System.TypeException: Collection store exception putting OAC_AXIntegrate.getXMLResponse_element into Map<String,OAC_AXIntegrate.synchronizeAXResponse_element>

please provide with some solution.............



 
subramanyam subbu 7subramanyam subbu 7
Did u got answer ? i was facing the same error