• Varun Sinha 17
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 8
    Replies
I am writing a test class and I am getting this error: System.TypeException: Methods defined as TestMethod do not support Web service callouts
Here is my Test class
@isTest
public class Test_CSS_SOAPEDS {
 
 @isTest static void testEchoString() {              
        // This causes a fake response to be generated
       
        String title = 'Customer Name:CSS EDS WS Test ';
        String workorder = 'workorder1';
        String model = 'null'; //"ISC CM2150"; //"ISB CM850";
        String serialNumber = '46826048';
        String locale = 'en';
        string userGroup=System.Label.UserGroup;
        string userName=System.Label.UserName;
        string encryptedKey = CSS_SOAPEDS.getgenerateToken(userName,userGroup);
        string systemDate;
        string token=userName+';'+userGroup+';datetime-'+systemDate;
        System.debug('The encryptedKey '+encryptedKey);
        System.debug('The title id '+title);
        string session = CSS_SOAPEDS.login(encryptedKey,locale);
        // Call the method that invokes a callout
         Test.setMock(WebServiceMock.class, new EDSwebcalloutMockImpl());
        String output = CSS_SOAPEDS.createDS(session,title,serialNumber,model,workorder);
        System.debug('The output '+output);
        // Verify that a fake result is returned
        System.assertEquals('DSBDT3829', output);
    }
}

Below is my web service mock class

@isTest
global class EDSwebcalloutMockImpl 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) {
            wwwKaidaraCom.createDiagnosticSessionResponse response_elem = new  wwwKaidaraCom.createDiagnosticSessionResponse();
            wwwKaidaraComKaidaraservice.resultDiagnosticSession dsID = new wwwKaidaraComKaidaraservice.resultDiagnosticSession();
            dsID.ID='DSBDT3829';
            system.debug('DSBDT3829<><>' + dsID.ID);
            response_elem.return_x = dsID;
            response.put('response_x', response_elem);

        }
}

Can anyone help me with this?
Thank You
Varun Sinha
I am getting some response back from the web service in a url i.e
https://cummins--cssdev.cs50.my.salesforce.com/a093B0000006oTdQAI?DSStatus=OPEN&DSID=DSBDT3497

Now from this url I need to save DSSTATUS and DSID in a custom object.
Can anyone help me with this.
Thank You in advance.
I was able to make a connection with the endpoint url.But now when I am trying to call method to create diagnostic key I am getting this error :

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

Can anyone help me with this?
Thanx
I have a visual force page that is calling an external web service and whenever I invoke the method on the web service I get this error.

System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: Fail creating session for token 'oEP0N1VHM4yLFOytdDwSSRpuXsW+s4LMnypVDYU8/X8afi3kUJxen26ZStVyyy5s'. faultcode=soap:Server faultactor=

Any help would be greatly appreciated. 
I am trying to share the job record with the perent account contact records.I am getting the owner of the record and then user and then contact and then parent account and from there contacts of the parent but while inserting I am getting this error.Can anyone help me?Below is my code
trigger CSS_Service_Order_SharingRule on CSS_Job_Order__c (after insert) {
    List<ID> userList = new List<ID>();
    List<ID> conListId = new List<ID>();
    List<ID> conList = new List<ID>();
    List<contact> coList = new List<contact>();
    List<user>usList = new List<user>();
    List<CSS_Job_Order__share> jobOrderList = new List<CSS_Job_Order__share>();
    List<Contact> contList = new List<Contact>();
    List<Account> accListID = new List<Account>();
    Map<Id,Id> uList = new Map<Id,Id>();
    for(CSS_Job_Order__c jobOrder : trigger.new) {
        userList.add(jobOrder.ownerID);
        System.debug('The owner id is'+userList);
    }
    for(User u:[Select id,contactID from user where id=:userList ]){
        conListId.add(u.ContactId);
         System.debug('The contact owner id is'+conListId);
    }
    for(Contact c:[Select accountID from contact where id=:conListId]){
        conList.add(c.accountID);
         System.debug('The ACCOUNT owner id is'+conList);
    }
    for(Account a:[Select parentid from account where id=:conList]){
        accListID.add(a);
         System.debug('The parent id is'+accListID);
    }
    if(accListID.size()>0){
        for(Contact c:[Select id,name,ownerid from contact where accountid=:accListID]){
            contList.add(c);       
        }
        for(CSS_Job_Order__c c : trigger.new) {
            for(Integer i = 0; i < contList.size();i++) {
                
                if(!contlist[i].ownerid.equals(c.ownerid)) {
                    coList.add(contList[i]);
                }
            }
            
        }
        if(coList.size()>0){
            
            for(User u : [SELECT id, contactid from User WHERE contactid = :coList]) {
                uList.put(u.contactid,u.id);
                
            }
            
            
            for(CSS_Job_Order__c jobOrd : trigger.new) {
                
                for(Integer i =0; i < coList.size(); i++) {
                    if(uList.containsKey(coList[i].Id)){
                        CSS_Job_Order__share cjo = new CSS_Job_Order__share(); 
                        cjo.AccessLevel='Read';
                        cjo.ParentId = jobOrd.id;
                        cjo.UserOrGroupId = uList.get(contList[i].Id);
                        jobOrderList.add(cjo);
                    }
                }
            }
            if (trigger.isInsert && !jobOrderList.isEmpty())
                insert jobOrderList;
        }
    }
}
I created a custom visualforce page. I want to add this component to the Salesforce Object page and hide from the home page. Is there a way to do this? Thanks!
I need to show all the contact id related to a particular account and total number of contact related to account  so that whenever i click on a particular contact id it should redirect me to that contact page.
Can anyone help me on this.
Thanx
I need to show all the contact id related to a particular account and total number of contact related to account  so that whenever i click on a particular contact id it should redirect me to that contact page.
Can anyone help me on this.
Thanx
I am getting some response back from the web service in a url i.e
https://cummins--cssdev.cs50.my.salesforce.com/a093B0000006oTdQAI?DSStatus=OPEN&DSID=DSBDT3497

Now from this url I need to save DSSTATUS and DSID in a custom object.
Can anyone help me with this.
Thank You in advance.
I was able to make a connection with the endpoint url.But now when I am trying to call method to create diagnostic key I am getting this error :

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

Can anyone help me with this?
Thanx
I have a visual force page that is calling an external web service and whenever I invoke the method on the web service I get this error.

System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: Fail creating session for token 'oEP0N1VHM4yLFOytdDwSSRpuXsW+s4LMnypVDYU8/X8afi3kUJxen26ZStVyyy5s'. faultcode=soap:Server faultactor=

Any help would be greatly appreciated.