• Raghu Pedabba
  • NEWBIE
  • 30 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 9
    Replies
Hi All,

I am trying to create a test class for my Web Service and I am getting the following Error

FATAL_ERROR System.TypeException:Collection store exception putting
 pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results into Map<String,pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element>


Please Help. ...

Class Generated From WSDL
//Generated by wsdl2apex


public class pca_Email_validation {
    public class EmailValidation_Batch_Validate_v1_20_Results {
        public String Status;
        public String EmailAddress;
        public String Account;
        public String Domain;
        public Boolean IsDisposible;
        public Boolean IsSystemMailbox;
        private String[] Status_type_info = new String[]{'Status','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] EmailAddress_type_info = new String[]{'EmailAddress','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] Account_type_info = new String[]{'Account','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] Domain_type_info = new String[]{'Domain','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] IsDisposible_type_info = new String[]{'IsDisposible','http://services.postcodeanywhere.co.uk/',null,'1','1','false'};
        private String[] IsSystemMailbox_type_info = new String[]{'IsSystemMailbox','http://services.postcodeanywhere.co.uk/',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'Status','EmailAddress','Account','Domain','IsDisposible','IsSystemMailbox'};
    }
    public class EmailValidation_Batch_Validate_v1_20_element {
        public String Key;
        public String Emails;
        private String[] Key_type_info = new String[]{'Key','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] Emails_type_info = new String[]{'Emails','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'Key','Emails'};
    }
    public class EmailValidation_Batch_Validate_v1_20_Response_element {
        public pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults EmailValidation_Batch_Validate_v1_20_Result;
        private String[] EmailValidation_Batch_Validate_v1_20_Result_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Result','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Result'};
    }
    public class EmailValidation_Batch_Validate_v1_20_ArrayOfResults {
        public pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results[] EmailValidation_Batch_Validate_v1_20_Results;
        private String[] EmailValidation_Batch_Validate_v1_20_Results_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Results','http://services.postcodeanywhere.co.uk/',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Results'};
    }
    public class PostcodeAnywhere_Soap {
        public String endpoint_x = 'https://services.postcodeanywhere.co.uk/EmailValidation/Batch/Validate/v1.20/soapnew.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://services.postcodeanywhere.co.uk/', 'pca_Email_validation'};
        public pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults EmailValidation_Batch_Validate_v1_20(String Key,String Emails) {
            pca_Email_validation.EmailValidation_Batch_Validate_v1_20_element request_x = new pca_Email_validation.EmailValidation_Batch_Validate_v1_20_element();
            request_x.Key = Key;
            request_x.Emails = Emails;
            pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element response_x;
            Map<String, pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element> response_map_x = new Map<String, pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://services.postcodeanywhere.co.uk/EmailValidation_Batch_Validate_v1_20',
              'http://services.postcodeanywhere.co.uk/',
              'EmailValidation_Batch_Validate_v1_20',
              'http://services.postcodeanywhere.co.uk/',
              'EmailValidation_Batch_Validate_v1_20_Response',
              'pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.EmailValidation_Batch_Validate_v1_20_Result;
        }
    }
}
web Service Mock Impl Class

@isTest
global class WebServiceMockImpl 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){
             
        pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results   respElement = new pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results();
        respElement.Status = 'Invalid';
        response.put('response_x', respElement);
       }
}

@isTest
public class DispatcherLeadNewTest {
 static testMethod void pcavalidation(){

        Test.setMock(WebServiceMock.class, new WebServiceMockImpl());
        Test.startTest();
        String Key = 'XXXX-XXXX-XXXX-XXXX';
        String Mail = 'test@test.com';
        pca_Email_validation.PostcodeAnywhere_Soap stub = new  pca_Email_validation.PostcodeAnywhere_Soap();
        pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results stub2 = new           pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results();
        pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults stub1 = new               pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults();
           
            stub1 = stub.EmailValidation_Batch_Validate_v1_20(Key,mail);
            String valid = stub1.EmailValidation_Batch_Validate_v1_20_Results[0].status;
            
            system.assertEquals('Invalid',valid);
           Test.stopTest();
       
    }
Hi Gurus,

I have created a Web Service for Email Validation , its work fine. But not sure how to write  a test class for this.

//Generated by wsdl2apex

public class pca_Email_validation {
    public class EmailValidation_Batch_Validate_v1_20_Results {
        public String Status;
        public String EmailAddress;
        public String Account;
        public String Domain;
        public Boolean IsDisposible;
        public Boolean IsSystemMailbox;
        private String[] Status_type_info = new String[]{'Status','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] EmailAddress_type_info = new String[]{'EmailAddress','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] Account_type_info = new String[]{'Account','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] Domain_type_info = new String[]{'Domain','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] IsDisposible_type_info = new String[]{'IsDisposible','http://services.postcodeanywhere.co.uk/',null,'1','1','false'};
        private String[] IsSystemMailbox_type_info = new String[]{'IsSystemMailbox','http://services.postcodeanywhere.co.uk/',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'Status','EmailAddress','Account','Domain','IsDisposible','IsSystemMailbox'};
    }
    public class EmailValidation_Batch_Validate_v1_20_element {
        public String Key;
        public String Emails;
        private String[] Key_type_info = new String[]{'Key','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] Emails_type_info = new String[]{'Emails','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'Key','Emails'};
    }
    public class EmailValidation_Batch_Validate_v1_20_Response_element {
        public pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults EmailValidation_Batch_Validate_v1_20_Result;
        private String[] EmailValidation_Batch_Validate_v1_20_Result_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Result','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Result'};
    }
    public class EmailValidation_Batch_Validate_v1_20_ArrayOfResults {
        public pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results[] EmailValidation_Batch_Validate_v1_20_Results;
        private String[] EmailValidation_Batch_Validate_v1_20_Results_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Results','http://services.postcodeanywhere.co.uk/',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Results'};
    }
    public class PostcodeAnywhere_Soap {
        public String endpoint_x = 'https://services.postcodeanywhere.co.uk/EmailValidation/Batch/Validate/v1.20/soapnew.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://services.postcodeanywhere.co.uk/', 'pca_Email_validation'};
        public pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults EmailValidation_Batch_Validate_v1_20(String Key,String Emails) {
            pca_Email_validation.EmailValidation_Batch_Validate_v1_20_element request_x = new pca_Email_validation.EmailValidation_Batch_Validate_v1_20_element();
            request_x.Key = Key;
            request_x.Emails = Emails;
            pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element response_x;
            Map<String, pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element> response_map_x = new Map<String, pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://services.postcodeanywhere.co.uk/EmailValidation_Batch_Validate_v1_20',
              'http://services.postcodeanywhere.co.uk/',
              'EmailValidation_Batch_Validate_v1_20',
              'http://services.postcodeanywhere.co.uk/',
              'EmailValidation_Batch_Validate_v1_20_Response',
              'pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.EmailValidation_Batch_Validate_v1_20_Result;
        }
    }
}

Calling this From my Custom Controller

public class DispatcherLeadNew{
    
    public DispatcherLeadNew(ApexPages.StandardController controller) {
        this.controller = controller;
    }
       public PageReference Save_Validate(){
        
       newLead = (Lead) controller.getRecord();     
        
       String Email = newLead.Email;
       String MPhone = newLead.MobilePhone;
       Boolean Va    = newLead.Validate__c;
       System.debug('Value of Boolean ' + Va);
       
           if(Va){
               Email_validation(Email);
            Phone_validation(Mphone);
           }    
         public void Email_Validation(String mail){

        
        
        //pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results wa;
        String Key = 'XXXX-XXXX-XXXX-XXXX';
        //String Email = newLead.Email;

          if(String.isNotBlank(mail)){  
            pca_Email_validation.PostcodeAnywhere_Soap stub = new  pca_Email_validation.PostcodeAnywhere_Soap();
            pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results stub2 = new pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results();
            pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults stub1 = new pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults();

                stub1 = stub.EmailValidation_Batch_Validate_v1_20(Key,mail);
                system.debug(stub1.EmailValidation_Batch_Validate_v1_20_Results[0].status);
                String valid = stub1.EmailValidation_Batch_Validate_v1_20_Results[0].status;        
                newLead.valid_email__c = valid;
         }   
       private final ApexPages.StandardController controller;
    }

Please can someone guide me to write a test class for this ?

Thanks,
Raghu Ram





 
Hi All,

I wanted to display seperate Visualforce page for a particular record type.
Did that by following this link http://blog.jeffdouglas.com/2008/11/14/redirecting-users-to-different-visualforce-pages/
 But, when I select any other record type the Record Selection Page is displayed twice ?

Apex:
public class DispatcherLeadNew{          public DispatcherLeadNew(ApexPages.StandardController controller) {         this.controller = controller;     }     public PageReference getRedir() {         PageReference newPage;         if (ApexPages.currentPage().getParameters().get('RecordType') == 'xxxxxxxxxxxxxxxxx') {             newPage = Page.LeadAddressLookup;             return newPage.setRedirect(true);         } else {             return null;                      }     }     private final ApexPages.StandardController controller;      }

VF Page:
<apex:page standardController="Lead" showHeader="true" sidebar="true" tabStyle="Lead" extensions="DispatcherLeadNew" action="{!nullValue(redir.url, urlFor($Action.Lead.New, null, null, true))}"> </apex:page>


What is wrong ?

Thanks,
Raghu

 
Dear Gurus,

I need to make POST request.

This is the JSON format for POST

{"products":[{"id":1,"quantity":1}],"desc":"infomation"}

*
Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);

Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('http://*******:*****/prod/');
request.setMethod('POST');
request.setHeader('Authorization', authorizationHeader);
request.setHeader('Content-Type', 'application/json;charset=UTF-8');
request.setBody('{"products":[{"id":1,"quantity":1}],"user_id":"user11"}');
HttpResponse response = http.send(request);
//if (response.getStatusCode() != 201) {
//    System.debug('The status code returned was not expected: ' +
//        response.getStatusCode() + ' ' + response.getStatus());
//} else {
    System.debug(response.getBody());

This works well.But I want to replace id and quantity with Integar variable.

Please guide me.

Thanks,
Raghu
 

Hi,

I have created a Visualforce Page with multiple page blocks with page block table.

First Page Block Table his filled from productde and I want the second page block table to display with value from Prodcat(but its blank)

Please find my code below.

<apex:page controller="My_Controller_Class" action="{!getProd}" >
    
    <apex:form >
       <apex:pageBlock title="Product Details">
           <apex:pageBlockButtons >
              <apex:commandButton action="{!displaySelectedProd}" value="showSelected Product" 
                   rerender="Available" status="status"/>
          </apex:pageBlockButtons>
           <apex:pageBlockSection id="invoiceblock" columns="5">
            <apex:pageBlockTable value="{!productde}" var="PD">
                <apex:column >
                    <apex:inputCheckbox value="{!PD.isSelected}"/>
                    
                </apex:column>   
                <apex:column headerValue="Product Id" value="{!PD.id}"/>
                <apex:column headerValue="Product Name" value="{!PD.name}"/>
                <apex:column headerValue="Qty">
                    <apex:inputText value="{!PD.qty}" maxlength="3" size="1"/>  
                                     
                </apex:column>    
            </apex:pageBlockTable>
           </apex:pageBlockSection>
           </apex:pageBlock>
           <apex:pageBlock title="Product Availabity">
           <apex:pageblockSection id="Available" Columns="5">
               <apex:pageBlockTable value="{!prodcat}" var="PA">
                <apex:column headerValue="Product Id" value="{!PA.id}"/>
                <apex:column headerValue="Product Name" value="{!PA.name}"/>
                <apex:column headerValue="Available Qty" value="{!PA.quantity_available}"/>
            </apex:pageBlockTable>
           </apex:pageblockSection> 
       </apex:pageBlock>
    </apex:form>
</apex:page>

My Controller Class:

global class My_Controller_Class {
    
    public List<ProductDetails> ProductDe{get;set;}
    public Set<String> SelProdNames{get;set;}
    public set<integer> qty{get;set;}
    public Boolean hasSelProd{get;set;}
    public List<JSON2Apex>ProdCat{get;set;}
    
    
    public PageReference Submit(){
        return null;
    }
    
    public void getProd(){
    
       String Username =  '****';
       String password = '*****';
       String endpoint = 'http://*****/product/'; 
       String httpMethod = 'GET';
 
       Blob headerValue = Blob.valueOf(username + ':' + password);
       String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
        
        
        HttpRequest req = new HttpRequest();
        Http http = new Http();
        req.setMethod('GET');
        req.setEndpoint(endpoint);  
        req.setHeader('Authorization', authorizationHeader); 
        req.setHeader('Content-type', 'application/json');
        HTTPResponse res = http.send(req);
        System.debug(res.getBody());
        System.debug(res.toString());
        String responseStrng = res.getBody();
        
        ProductDe = (List<ProductDetails>) System.JSON.deserialize(responseStrng, List<ProductDetails>.class);
        system.debug('Product' + productde);
        ProductDe.sort();
        }

//
    public PageReference displaySelectedProd(){
        //selProdNames.clear();
        selProdNames = new Set<String>(); 
        hasSelProd = false;
       for(ProductDetails prod : ProductDe){
            if(prod.isSelected){
                hasSelProd = true;
                selProdNames.add(prod.name);
           }
        }
//
       String Username =  '*****';
       String password = '*****';
       String endpoint = 'http://**********/produc/'; 
       String httpMethod = 'GET';
 
       Blob headerValue = Blob.valueOf(username + ':' + password);
       String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
              
        HttpRequest req = new HttpRequest();
        Http http = new Http();
        req.setMethod('GET');
        req.setEndpoint(endpoint);  
        req.setHeader('Authorization', authorizationHeader); 
        req.setHeader('Content-type', 'application/json');
        HTTPResponse res = http.send(req);
        System.debug(res.getBody());
        System.debug(res.toString());
        String responseStrng = res.getBody();
        
        JSON2Apex Prodcat = JSON2Apex.parse(responseStrng);
        //ProdCat = (List<JSON2Apex>) System.JSON.deserialize(responseStrng, List<JSON2Apex>.class);
        //Prodcat = (List<JSON2Apex>) JSON.deserialize(responseStrng, List<JSON2Apex>.class);
        system.debug('ProductCat' + ProdCat);        
        
        return null;
    }
//
//      
        }



Thanks,

Raghu

Hi Gurus,

I am trying to do a Call Out using REST.

My JSON
[{"eid":4,"name":"Mark"},{"eid":3,"name":"Steve"},{"eid":1,"name":"Peter"},{"eid":7,"name":"Matt"},{"eid":6,"name":"Barrow"},{"eid":5,"name":"Sugar"},{"eid":2,"name":"Thomas"}]

//
// Generated by JSON2Apex http://json2apex.herokuapp.com/
//
     public class JSON2Apex {
 
             public Integer id;
             public String name;
               public static JSON2Apex parse(String json) {
                   return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class);
            }
}

In execute anoymous window, I am trying the below code
HttpRequest req = new HttpRequest();
req.setEndpoint('http://********/emp/');
req.setMethod('GET');

String Username =  '*****';
String password = '*******';
 
Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'Basic ' +
EncodingUtil.base64Encode(headerValue);
req.setHeader('Authorization', authorizationHeader);
   
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());
 String responseStrng = res.getBody();
List<JSON2Apex> Emp = (List<JSON2Apex>)JSON.deserialize(responseStrng, List<JSON2Apex>.class);
system.debug(emp);

But, I am not getting any value in list emp ??

Not sure where I am going wrong. Please help.


 
Hi Expert,

I need to create a report showing Employee Starters based on Start Date and Employee Leavers based on Exit Date in same chart grouped by Date and country ?

Any suggestions ?

Regards,
Raghu

 

Hi Experts,

I am getting this error (Your login attempt using single sign-on with an identity provider certificate has failed. Please contact your salesforce.com administrator for more information.) when I try to login using https://abc.my.salesforce.com , but it works fine when I login thro' test.salesforce.com.

Any pointers on, how to resolve this ?

Regards,
Raghu

Hi All,

I want to give a user access to export data weekly.

Can see that option in profile, but do not want to enable that in profile since its used by many.

Can I enable it thro' permission sets ?
Hi All,

Two users have same profile and role.But one user is not able to see records seen by other user. They both have same permission sets.

Hi All,

I am creating Report on Contacts with Job Applications.

If the a particular person have applied for multiple Job, I want only record of that contact.

Currently, i get four records for that contact,since he applied for 4 Jobs. But I need only one record for that person. 

How can I do this ??

Regards,

Raghu

Hi All,

I am trying to create a test class for my Web Service and I am getting the following Error

FATAL_ERROR System.TypeException:Collection store exception putting
 pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results into Map<String,pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element>


Please Help. ...

Class Generated From WSDL
//Generated by wsdl2apex


public class pca_Email_validation {
    public class EmailValidation_Batch_Validate_v1_20_Results {
        public String Status;
        public String EmailAddress;
        public String Account;
        public String Domain;
        public Boolean IsDisposible;
        public Boolean IsSystemMailbox;
        private String[] Status_type_info = new String[]{'Status','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] EmailAddress_type_info = new String[]{'EmailAddress','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] Account_type_info = new String[]{'Account','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] Domain_type_info = new String[]{'Domain','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] IsDisposible_type_info = new String[]{'IsDisposible','http://services.postcodeanywhere.co.uk/',null,'1','1','false'};
        private String[] IsSystemMailbox_type_info = new String[]{'IsSystemMailbox','http://services.postcodeanywhere.co.uk/',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'Status','EmailAddress','Account','Domain','IsDisposible','IsSystemMailbox'};
    }
    public class EmailValidation_Batch_Validate_v1_20_element {
        public String Key;
        public String Emails;
        private String[] Key_type_info = new String[]{'Key','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] Emails_type_info = new String[]{'Emails','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'Key','Emails'};
    }
    public class EmailValidation_Batch_Validate_v1_20_Response_element {
        public pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults EmailValidation_Batch_Validate_v1_20_Result;
        private String[] EmailValidation_Batch_Validate_v1_20_Result_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Result','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Result'};
    }
    public class EmailValidation_Batch_Validate_v1_20_ArrayOfResults {
        public pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results[] EmailValidation_Batch_Validate_v1_20_Results;
        private String[] EmailValidation_Batch_Validate_v1_20_Results_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Results','http://services.postcodeanywhere.co.uk/',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Results'};
    }
    public class PostcodeAnywhere_Soap {
        public String endpoint_x = 'https://services.postcodeanywhere.co.uk/EmailValidation/Batch/Validate/v1.20/soapnew.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://services.postcodeanywhere.co.uk/', 'pca_Email_validation'};
        public pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults EmailValidation_Batch_Validate_v1_20(String Key,String Emails) {
            pca_Email_validation.EmailValidation_Batch_Validate_v1_20_element request_x = new pca_Email_validation.EmailValidation_Batch_Validate_v1_20_element();
            request_x.Key = Key;
            request_x.Emails = Emails;
            pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element response_x;
            Map<String, pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element> response_map_x = new Map<String, pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://services.postcodeanywhere.co.uk/EmailValidation_Batch_Validate_v1_20',
              'http://services.postcodeanywhere.co.uk/',
              'EmailValidation_Batch_Validate_v1_20',
              'http://services.postcodeanywhere.co.uk/',
              'EmailValidation_Batch_Validate_v1_20_Response',
              'pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.EmailValidation_Batch_Validate_v1_20_Result;
        }
    }
}
web Service Mock Impl Class

@isTest
global class WebServiceMockImpl 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){
             
        pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results   respElement = new pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results();
        respElement.Status = 'Invalid';
        response.put('response_x', respElement);
       }
}

@isTest
public class DispatcherLeadNewTest {
 static testMethod void pcavalidation(){

        Test.setMock(WebServiceMock.class, new WebServiceMockImpl());
        Test.startTest();
        String Key = 'XXXX-XXXX-XXXX-XXXX';
        String Mail = 'test@test.com';
        pca_Email_validation.PostcodeAnywhere_Soap stub = new  pca_Email_validation.PostcodeAnywhere_Soap();
        pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results stub2 = new           pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results();
        pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults stub1 = new               pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults();
           
            stub1 = stub.EmailValidation_Batch_Validate_v1_20(Key,mail);
            String valid = stub1.EmailValidation_Batch_Validate_v1_20_Results[0].status;
            
            system.assertEquals('Invalid',valid);
           Test.stopTest();
       
    }
Hi Gurus,

I have created a Web Service for Email Validation , its work fine. But not sure how to write  a test class for this.

//Generated by wsdl2apex

public class pca_Email_validation {
    public class EmailValidation_Batch_Validate_v1_20_Results {
        public String Status;
        public String EmailAddress;
        public String Account;
        public String Domain;
        public Boolean IsDisposible;
        public Boolean IsSystemMailbox;
        private String[] Status_type_info = new String[]{'Status','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] EmailAddress_type_info = new String[]{'EmailAddress','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] Account_type_info = new String[]{'Account','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] Domain_type_info = new String[]{'Domain','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] IsDisposible_type_info = new String[]{'IsDisposible','http://services.postcodeanywhere.co.uk/',null,'1','1','false'};
        private String[] IsSystemMailbox_type_info = new String[]{'IsSystemMailbox','http://services.postcodeanywhere.co.uk/',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'Status','EmailAddress','Account','Domain','IsDisposible','IsSystemMailbox'};
    }
    public class EmailValidation_Batch_Validate_v1_20_element {
        public String Key;
        public String Emails;
        private String[] Key_type_info = new String[]{'Key','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] Emails_type_info = new String[]{'Emails','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'Key','Emails'};
    }
    public class EmailValidation_Batch_Validate_v1_20_Response_element {
        public pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults EmailValidation_Batch_Validate_v1_20_Result;
        private String[] EmailValidation_Batch_Validate_v1_20_Result_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Result','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Result'};
    }
    public class EmailValidation_Batch_Validate_v1_20_ArrayOfResults {
        public pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results[] EmailValidation_Batch_Validate_v1_20_Results;
        private String[] EmailValidation_Batch_Validate_v1_20_Results_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Results','http://services.postcodeanywhere.co.uk/',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Results'};
    }
    public class PostcodeAnywhere_Soap {
        public String endpoint_x = 'https://services.postcodeanywhere.co.uk/EmailValidation/Batch/Validate/v1.20/soapnew.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://services.postcodeanywhere.co.uk/', 'pca_Email_validation'};
        public pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults EmailValidation_Batch_Validate_v1_20(String Key,String Emails) {
            pca_Email_validation.EmailValidation_Batch_Validate_v1_20_element request_x = new pca_Email_validation.EmailValidation_Batch_Validate_v1_20_element();
            request_x.Key = Key;
            request_x.Emails = Emails;
            pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element response_x;
            Map<String, pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element> response_map_x = new Map<String, pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://services.postcodeanywhere.co.uk/EmailValidation_Batch_Validate_v1_20',
              'http://services.postcodeanywhere.co.uk/',
              'EmailValidation_Batch_Validate_v1_20',
              'http://services.postcodeanywhere.co.uk/',
              'EmailValidation_Batch_Validate_v1_20_Response',
              'pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.EmailValidation_Batch_Validate_v1_20_Result;
        }
    }
}

Calling this From my Custom Controller

public class DispatcherLeadNew{
    
    public DispatcherLeadNew(ApexPages.StandardController controller) {
        this.controller = controller;
    }
       public PageReference Save_Validate(){
        
       newLead = (Lead) controller.getRecord();     
        
       String Email = newLead.Email;
       String MPhone = newLead.MobilePhone;
       Boolean Va    = newLead.Validate__c;
       System.debug('Value of Boolean ' + Va);
       
           if(Va){
               Email_validation(Email);
            Phone_validation(Mphone);
           }    
         public void Email_Validation(String mail){

        
        
        //pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results wa;
        String Key = 'XXXX-XXXX-XXXX-XXXX';
        //String Email = newLead.Email;

          if(String.isNotBlank(mail)){  
            pca_Email_validation.PostcodeAnywhere_Soap stub = new  pca_Email_validation.PostcodeAnywhere_Soap();
            pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results stub2 = new pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results();
            pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults stub1 = new pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults();

                stub1 = stub.EmailValidation_Batch_Validate_v1_20(Key,mail);
                system.debug(stub1.EmailValidation_Batch_Validate_v1_20_Results[0].status);
                String valid = stub1.EmailValidation_Batch_Validate_v1_20_Results[0].status;        
                newLead.valid_email__c = valid;
         }   
       private final ApexPages.StandardController controller;
    }

Please can someone guide me to write a test class for this ?

Thanks,
Raghu Ram





 
Dear Gurus,

I need to make POST request.

This is the JSON format for POST

{"products":[{"id":1,"quantity":1}],"desc":"infomation"}

*
Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);

Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('http://*******:*****/prod/');
request.setMethod('POST');
request.setHeader('Authorization', authorizationHeader);
request.setHeader('Content-Type', 'application/json;charset=UTF-8');
request.setBody('{"products":[{"id":1,"quantity":1}],"user_id":"user11"}');
HttpResponse response = http.send(request);
//if (response.getStatusCode() != 201) {
//    System.debug('The status code returned was not expected: ' +
//        response.getStatusCode() + ' ' + response.getStatus());
//} else {
    System.debug(response.getBody());

This works well.But I want to replace id and quantity with Integar variable.

Please guide me.

Thanks,
Raghu
 

Hi,

I have created a Visualforce Page with multiple page blocks with page block table.

First Page Block Table his filled from productde and I want the second page block table to display with value from Prodcat(but its blank)

Please find my code below.

<apex:page controller="My_Controller_Class" action="{!getProd}" >
    
    <apex:form >
       <apex:pageBlock title="Product Details">
           <apex:pageBlockButtons >
              <apex:commandButton action="{!displaySelectedProd}" value="showSelected Product" 
                   rerender="Available" status="status"/>
          </apex:pageBlockButtons>
           <apex:pageBlockSection id="invoiceblock" columns="5">
            <apex:pageBlockTable value="{!productde}" var="PD">
                <apex:column >
                    <apex:inputCheckbox value="{!PD.isSelected}"/>
                    
                </apex:column>   
                <apex:column headerValue="Product Id" value="{!PD.id}"/>
                <apex:column headerValue="Product Name" value="{!PD.name}"/>
                <apex:column headerValue="Qty">
                    <apex:inputText value="{!PD.qty}" maxlength="3" size="1"/>  
                                     
                </apex:column>    
            </apex:pageBlockTable>
           </apex:pageBlockSection>
           </apex:pageBlock>
           <apex:pageBlock title="Product Availabity">
           <apex:pageblockSection id="Available" Columns="5">
               <apex:pageBlockTable value="{!prodcat}" var="PA">
                <apex:column headerValue="Product Id" value="{!PA.id}"/>
                <apex:column headerValue="Product Name" value="{!PA.name}"/>
                <apex:column headerValue="Available Qty" value="{!PA.quantity_available}"/>
            </apex:pageBlockTable>
           </apex:pageblockSection> 
       </apex:pageBlock>
    </apex:form>
</apex:page>

My Controller Class:

global class My_Controller_Class {
    
    public List<ProductDetails> ProductDe{get;set;}
    public Set<String> SelProdNames{get;set;}
    public set<integer> qty{get;set;}
    public Boolean hasSelProd{get;set;}
    public List<JSON2Apex>ProdCat{get;set;}
    
    
    public PageReference Submit(){
        return null;
    }
    
    public void getProd(){
    
       String Username =  '****';
       String password = '*****';
       String endpoint = 'http://*****/product/'; 
       String httpMethod = 'GET';
 
       Blob headerValue = Blob.valueOf(username + ':' + password);
       String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
        
        
        HttpRequest req = new HttpRequest();
        Http http = new Http();
        req.setMethod('GET');
        req.setEndpoint(endpoint);  
        req.setHeader('Authorization', authorizationHeader); 
        req.setHeader('Content-type', 'application/json');
        HTTPResponse res = http.send(req);
        System.debug(res.getBody());
        System.debug(res.toString());
        String responseStrng = res.getBody();
        
        ProductDe = (List<ProductDetails>) System.JSON.deserialize(responseStrng, List<ProductDetails>.class);
        system.debug('Product' + productde);
        ProductDe.sort();
        }

//
    public PageReference displaySelectedProd(){
        //selProdNames.clear();
        selProdNames = new Set<String>(); 
        hasSelProd = false;
       for(ProductDetails prod : ProductDe){
            if(prod.isSelected){
                hasSelProd = true;
                selProdNames.add(prod.name);
           }
        }
//
       String Username =  '*****';
       String password = '*****';
       String endpoint = 'http://**********/produc/'; 
       String httpMethod = 'GET';
 
       Blob headerValue = Blob.valueOf(username + ':' + password);
       String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
              
        HttpRequest req = new HttpRequest();
        Http http = new Http();
        req.setMethod('GET');
        req.setEndpoint(endpoint);  
        req.setHeader('Authorization', authorizationHeader); 
        req.setHeader('Content-type', 'application/json');
        HTTPResponse res = http.send(req);
        System.debug(res.getBody());
        System.debug(res.toString());
        String responseStrng = res.getBody();
        
        JSON2Apex Prodcat = JSON2Apex.parse(responseStrng);
        //ProdCat = (List<JSON2Apex>) System.JSON.deserialize(responseStrng, List<JSON2Apex>.class);
        //Prodcat = (List<JSON2Apex>) JSON.deserialize(responseStrng, List<JSON2Apex>.class);
        system.debug('ProductCat' + ProdCat);        
        
        return null;
    }
//
//      
        }



Thanks,

Raghu

Hi Gurus,

I am trying to do a Call Out using REST.

My JSON
[{"eid":4,"name":"Mark"},{"eid":3,"name":"Steve"},{"eid":1,"name":"Peter"},{"eid":7,"name":"Matt"},{"eid":6,"name":"Barrow"},{"eid":5,"name":"Sugar"},{"eid":2,"name":"Thomas"}]

//
// Generated by JSON2Apex http://json2apex.herokuapp.com/
//
     public class JSON2Apex {
 
             public Integer id;
             public String name;
               public static JSON2Apex parse(String json) {
                   return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class);
            }
}

In execute anoymous window, I am trying the below code
HttpRequest req = new HttpRequest();
req.setEndpoint('http://********/emp/');
req.setMethod('GET');

String Username =  '*****';
String password = '*******';
 
Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'Basic ' +
EncodingUtil.base64Encode(headerValue);
req.setHeader('Authorization', authorizationHeader);
   
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());
 String responseStrng = res.getBody();
List<JSON2Apex> Emp = (List<JSON2Apex>)JSON.deserialize(responseStrng, List<JSON2Apex>.class);
system.debug(emp);

But, I am not getting any value in list emp ??

Not sure where I am going wrong. Please help.


 
Hi, 

I am trying to override the New button on Opportunity with the following Visualforce Page: 

<apex:page standardController="Opportunity">
<script>
window.top.location.replace("{!URLFOR($Action.Opportunity.New, null, [saveURL='/apex/RedirectToCompetitorAgreement',nooverride=1,save=1], true)}");
</script>
</apex:page>

When the user has entered the opportunity information and presses save he is redirected to the VF page "RedirectToCompetitorAgreement". Everything works as expected except that the record type selection page is shown two times. Any ideas on how I can fix this issue? 
Hi All,

Two users have same profile and role.But one user is not able to see records seen by other user. They both have same permission sets.
hi i want to integrate sap with salesforce please tell me in detail because iam a fresher .if there any document please post

Hi All,

I am creating Report on Contacts with Job Applications.

If the a particular person have applied for multiple Job, I want only record of that contact.

Currently, i get four records for that contact,since he applied for 4 Jobs. But I need only one record for that person. 

How can I do this ??

Regards,

Raghu