1

Hi this my generated apex code can any help me on writing apex controller i am tring controller class like this but getting error:

public class tempuriOrg {
    public class SubtractResponse_element {
        public Integer SubtractResult;
        private String[] SubtractResult_type_info = new String[]{'SubtractResult','http://tempuri.org/',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true','false'};
        private String[] field_order_type_info = new String[]{'SubtractResult'};
    }
    public class Divide_element {
        public Integer intA;
        public Integer intB;
        private String[] intA_type_info = new String[]{'intA','http://tempuri.org/',null,'1','1','false'};
        private String[] intB_type_info = new String[]{'intB','http://tempuri.org/',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true','false'};
        private String[] field_order_type_info = new String[]{'intA','intB'};
    }
    public class Multiply_element {
        public Integer intA;
        public Integer intB;
        private String[] intA_type_info = new String[]{'intA','http://tempuri.org/',null,'1','1','false'};
        private String[] intB_type_info = new String[]{'intB','http://tempuri.org/',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true','false'};
        private String[] field_order_type_info = new String[]{'intA','intB'};
    }
    public class Subtract_element {
        public Integer intA;
        public Integer intB;
        private String[] intA_type_info = new String[]{'intA','http://tempuri.org/',null,'1','1','false'};
        private String[] intB_type_info = new String[]{'intB','http://tempuri.org/',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true','false'};
        private String[] field_order_type_info = new String[]{'intA','intB'};
    }
    public class AddResponse_element {
        public Integer AddResult;
        private String[] AddResult_type_info = new String[]{'AddResult','http://tempuri.org/',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true','false'};
        private String[] field_order_type_info = new String[]{'AddResult'};
    }
    public class Add_element {
        public Integer intA;
        public Integer intB;
        private String[] intA_type_info = new String[]{'intA','http://tempuri.org/',null,'1','1','false'};
        private String[] intB_type_info = new String[]{'intB','http://tempuri.org/',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true','false'};
        private String[] field_order_type_info = new String[]{'intA','intB'};
    }
    public class DivideResponse_element {
        public Integer DivideResult;
        private String[] DivideResult_type_info = new String[]{'DivideResult','http://tempuri.org/',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true','false'};
        private String[] field_order_type_info = new String[]{'DivideResult'};
    }
    public class MultiplyResponse_element {
        public Integer MultiplyResult;
        private String[] MultiplyResult_type_info = new String[]{'MultiplyResult','http://tempuri.org/',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://tempuri.org/','true','false'};
        private String[] field_order_type_info = new String[]{'MultiplyResult'};
    }
    public class CalculatorSoap {
        public String endpoint_x = 'http://www.dneonline.com/calculator.asmx';
        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://tempuri.org/', 'tempuriOrg'};
        public Integer Multiply(Integer intA,Integer intB) {
            tempuriOrg.Multiply_element request_x = new tempuriOrg.Multiply_element();
            request_x.intA = intA;
            request_x.intB = intB;
            tempuriOrg.MultiplyResponse_element response_x;
            Map<String, tempuriOrg.MultiplyResponse_element> response_map_x = new Map<String, tempuriOrg.MultiplyResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://tempuri.org/Multiply',
              'http://tempuri.org/',
              'Multiply',
              'http://tempuri.org/',
              'MultiplyResponse',
              'tempuriOrg.MultiplyResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.MultiplyResult;
        }
        public Integer Divide(Integer intA,Integer intB) {
            tempuriOrg.Divide_element request_x = new tempuriOrg.Divide_element();
            request_x.intA = intA;
            request_x.intB = intB;
            tempuriOrg.DivideResponse_element response_x;
            Map<String, tempuriOrg.DivideResponse_element> response_map_x = new Map<String, tempuriOrg.DivideResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://tempuri.org/Divide',
              'http://tempuri.org/',
              'Divide',
              'http://tempuri.org/',
              'DivideResponse',
              'tempuriOrg.DivideResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.DivideResult;
        }
        public Integer Subtract(Integer intA,Integer intB) {
            tempuriOrg.Subtract_element request_x = new tempuriOrg.Subtract_element();
            request_x.intA = intA;
            request_x.intB = intB;
            tempuriOrg.SubtractResponse_element response_x;
            Map<String, tempuriOrg.SubtractResponse_element> response_map_x = new Map<String, tempuriOrg.SubtractResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://tempuri.org/Subtract',
              'http://tempuri.org/',
              'Subtract',
              'http://tempuri.org/',
              'SubtractResponse',
              'tempuriOrg.SubtractResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.SubtractResult;
        }
        public Integer Add(Integer intA,Integer intB) {
            tempuriOrg.Add_element request_x = new tempuriOrg.Add_element();
            request_x.intA = intA;
            request_x.intB = intB;
            tempuriOrg.AddResponse_element response_x;
            Map<String, tempuriOrg.AddResponse_element> response_map_x = new Map<String, tempuriOrg.AddResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://tempuri.org/Add',
              'http://tempuri.org/',
              'Add',
              'http://tempuri.org/',
              'AddResponse',
              'tempuriOrg.AddResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.AddResult;
        }
    }
}

this is my controller class

public class bodmas{
public integer intA{get;set;}
public integer intB{get;set;}
public integer result{get;set;}

public integer additoin(){
result = tempuriOrg.Add(intA,intB);
} 
public integer Subtraction(){
result = tempuriOrg.Subtract(intA,intB);
} 
public integer division(){
result = tempuriOrg.Divide(intA,intB);
} 
}

my error:

Error: Compile Error: Method does not exist or incorrect signature: tempuriOrg.Add(Integer, Integer) at line 7 column 10

Visulaforce code:

<apex:page controller="bodmas">
<apex:form >
INTEGERA:<apex:inputtext value="{!inta}"/><br/>
INTEGERB:<apex:inputtext value="{!intb}"/><br/>
addition:<apex:commandbutton value="addition" action="{!additoin}"/><br/>
sutraction:<apex:commandbutton value="sutraction" action="{!Subtraction}"/><br/>
division:<apex:commandbutton value="division" action="{!division}"/><br/>
result:<apex:outputtext value="{!result}"/><br/>
</apex:form>
</apex:page>
1

Taking addition as an example, it looks like the method you want to call is this:

public Integer Add(Integer intA,Integer intB) 

which is a method of the CalculatorSoap inner class. What I believe you would want to do is create an instance of that class, and then call that method:

public class bodmas{
    public integer intA{get;set;}
    public integer intB{get;set;}
    public integer result{get;set;}

    public PageReference additoin(){
        tempuriOrg.CalculatorSoap calculator = new tempuriOrg.CalculatorSoap();
        result = calculator.Add(intA,intB);
        return NULL;
    } 
                    ⋮
}
  • Thank you @martin your code working fine but while running in visualforce showing error: "Return type of an Apex action method must be a PageReference. Found: java.lang.Integer " – user321 Feb 19 '16 at 10:26
  • Updated My visualforce page above please check once why error came – user321 Feb 19 '16 at 10:30
  • When you call an action from a commandButton, the return type of the method in the controller has to be PageReference. If you return NULL, the visualforce page should refresh with the new value of result. – martin Feb 19 '16 at 10:34
  • excellent. I'm glad I could help. – martin Feb 19 '16 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.