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
lakshman.mattilakshman.matti 

Test class for Webservice callouts(SOAP)

Hi Everyone,

I want to write to test class for webservice callouts.below is the WSDL2Apex class.
how to generate mock response for this.
public class GsdTrunkpartorderCreateResponse {
    public class CreateTrunkPartOrderEndpoint3 {
        public String endpoint_x = 'https://localhost:4437/CreateTrunkPartOrder';
        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://www.hp.com/GSD/SFDC/Outbound/WES_Cloud/CreateTrunkPartOrder/Artifacts/Schema/CreateTrunkPartOrder.xsd', 'GsdTrunkpartorderCreateRequest', 'http://www.hp.com/GSD/SFDC/Outbound/WES_Cloud/CreateTrunkPartOrder/Services/CreateTrunkPartOrder-service.serviceagent', 'GsdTrunkpartorderCreateResponse'};
        public GsdTrunkpartorderCreateRequest.CreateTrunkPartOrderResponse_element CreateTrunkPartOrder(GsdTrunkpartorderCreateRequest.YORDER_CREATE_IMP1 ORDER_CREATE_IMP,GsdTrunkpartorderCreateRequest.Monitoring_element Monitoring,String Region) {
            GsdTrunkpartorderCreateRequest.CreateTrunkPartOrder_element request_x = new GsdTrunkpartorderCreateRequest.CreateTrunkPartOrder_element();
            request_x.ORDER_CREATE_IMP = ORDER_CREATE_IMP;
            request_x.Monitoring = Monitoring;
            request_x.Region = Region;
            GsdTrunkpartorderCreateRequest.CreateTrunkPartOrderResponse_element response_x;
            Map<String, GsdTrunkpartorderCreateRequest.CreateTrunkPartOrderResponse_element> response_map_x = new Map<String, GsdTrunkpartorderCreateRequest.CreateTrunkPartOrderResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '/SFDC/Outbound/WES_Cloud/CreateTrunkPartOrder/Artifacts/WSDL/CreateTrunkPartOrder_Abstract-service3.serviceagent/CreateTrunkPartOrderEndpoint3/CreateTrunkPartOrder',
              'http://www.hp.com/GSD/SFDC/Outbound/WES_Cloud/CreateTrunkPartOrder/Artifacts/Schema/CreateTrunkPartOrder.xsd',
              'CreateTrunkPartOrder',
              'http://www.hp.com/GSD/SFDC/Outbound/WES_Cloud/CreateTrunkPartOrder/Artifacts/Schema/CreateTrunkPartOrder.xsd',
              'CreateTrunkPartOrderResponse',
              'GsdTrunkpartorderCreateRequest.CreateTrunkPartOrderResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x;
        }
    }
}.
-----------------------
public class GsdTrunkpartorderCreateRequest {
public class CreateTrunkPartOrderResponse_element {
        public String StatusCode;
        public String StatusMsg;
        private String[] StatusCode_type_info = new String[]{'StatusCode','http://www.hp.com/GSD/SFDC/Outbound/WES_Cloud/CreateTrunkPartOrder/Artifacts/Schema/CreateTrunkPartOrder.xsd',null,'0','1','false'};
        private String[] StatusMsg_type_info = new String[]{'StatusMsg','http://www.hp.com/GSD/SFDC/Outbound/WES_Cloud/CreateTrunkPartOrder/Artifacts/Schema/CreateTrunkPartOrder.xsd',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.hp.com/GSD/SFDC/Outbound/WES_Cloud/CreateTrunkPartOrder/Artifacts/Schema/CreateTrunkPartOrder.xsd','true','false'};
        private String[] field_order_type_info = new String[]{'StatusCode','StatusMsg'};
    }
}
PratikPratik (Salesforce Developers) 
Hi Lakshman,

Please refer below links for sample test class for SOAP callouts:

https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_wsdl2apex_testing.htm

http://sfdc.arrowpointe.com/2009/05/01/testing-http-callouts/

Thanks,
Pratik
lakshman.mattilakshman.matti
Hi Pratik,

i'm refered all the salesforce documetations. i followed them and im not getting fake response.
and importantly this is not for http callouts , this is soap based callouts.
 i have provided my test class and the class name.please suggest me to how to get fake response when implementing webservicemock interface.

Regards
Lakshman
Lokeswara ReddyLokeswara Reddy
Hi Lakshman,

Did you find the way to complete the test class for webservice call out? if so please update the steps.

Regards
Lokesh