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
KaityKaity 

WSDL2APEX run from developer console

Hi,
I have  query here:
I consumed the WSDL provided by the 3rd party. Now, I want to ren the WSDL2APEX through anonymous block. I am finding hard to write the anonymous block from developer console because there are many classess/ subclassess ate there. 
Can you please give an example here? Many Thanks...

-Kaity
olsenolsen
Hi Kaity,
Here are some sample code for a simple web service I use.
Based on the following class:
public class noBrregSaksysGrunndataWs {
    
    public class ErFrSoapPort {
// Parameters for the callout
        public String endpoint_x = 'https://ws.brreg.no/grunndata/ErFr'; 
        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://no/brreg/saksys/grunndata/ws','noBrregSaksysGrunndataWs'};

        public String getdata(String userid,String password,String orgnr) {
            noBrregSaksysGrunndataWs.getdata_element request_x = new noBrregSaksysGrunndataWs.getdata_element();
            noBrregSaksysGrunndataWs.getdataResponse_element response_x;
            request_x.userid = userid;
            request_x.password = password;
            request_x.orgnr = orgnr;
            Map<String, noBrregSaksysGrunndataWs.getdataResponse_element> response_map_x = new Map<String, noBrregSaksysGrunndataWs.getdataResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
                this,
                request_x,
                response_map_x,
                new String[]{endpoint_x,
                '',
                'http://no/brreg/saksys/grunndata/ws',
                'getdata',
                'http://no/brreg/saksys/grunndata/ws',
                'getdataResponse',
                'noBrregSaksysGrunndataWs.getdataResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.return_x;
        }
You can run this in the developer console to perform the callout:
// Create an instance of the webservice class
noBrregSaksysGrunndataWs.ErFrSoapPort brreg = new noBrregSaksysGrunndataWs.ErFrSoapPort(); 
 // call the method getdata() with parameters 
String reply=brreg.getData('myuserid', 'mypassword', 'orgnr');
system.debug(reply);