+ Start a Discussion
soasoa 

Unable to invoke the methods of the apex class

Hi,
 
I have generated the folllowing class:
 
public class wwwWebservicexNet {
    public class ConvertTemperatureSoap {
        public String endpoint_x = 'http://www.webservicex.net/ConvertTemperature.asmx';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        private String[] ns_map_type_info = new String[]{'http://www.webserviceX.NET/', 'wwwWebservicexNet'};
        public Double ConvertTemp(Double Temperature,String FromUnit,String ToUnit) {
            wwwWebservicexNet.ConvertTemp_element request_x = new wwwWebservicexNet.ConvertTemp_element();
            wwwWebservicexNet.ConvertTempResponse_element response_x;
            request_x.Temperature = Temperature;
            request_x.FromUnit = FromUnit;
            request_x.ToUnit = ToUnit;
            Map<String, wwwWebservicexNet.ConvertTempResponse_element> response_map_x = new Map<String, wwwWebservicexNet.ConvertTempResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://www.webserviceX.NET/ConvertTemp',
              'http://www.webserviceX.NET/',
              'ConvertTemp',
              'http://www.webserviceX.NET/',
              'ConvertTempResponse',
              'wwwWebservicexNet.ConvertTempResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.ConvertTempResult;
        }
    }
    public class ConvertTempResponse_element {
        public Double ConvertTempResult;
        private String[] ConvertTempResult_type_info = new String[]{'ConvertTempResult','http://www.w3.org/2001/XMLSchema','double','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.webserviceX.NET/','true'};
        private String[] field_order_type_info = new String[]{'ConvertTempResult'};
    }
    public class ConvertTemp_element {
        public Double Temperature;
        public String FromUnit;
        public String ToUnit;
        private String[] Temperature_type_info = new String[]{'Temperature','http://www.w3.org/2001/XMLSchema','double','1','1','false'};
        private String[] FromUnit_type_info = new String[]{'FromUnit','http://www.webserviceX.NET/','TemperatureUnit','1','1','false'};
        private String[] ToUnit_type_info = new String[]{'ToUnit','http://www.webserviceX.NET/','TemperatureUnit','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.webserviceX.NET/','true'};
        private String[] field_order_type_info = new String[]{'Temperature','FromUnit','ToUnit'};
    }
}
 
I tried to invoke the methods of the code (as given on page 141 of salesforce_platform_cookbook.pdf) The code is :

global class MassNoteInsert{

WebService static Integer insertNotes(String iTitle,

String iBody,

Id[] iParentIds) {

Note[] notes = new Note[0];

for (Id iParentId : iParentIds) {

notes.add(new Note(parentId = iParentId,

title = iTitle, body = iBody));

}

insert notes; //Bulk Insert

return notes.size();

}

}

But for the previous code I am getting an error as I prees the button on the Accounts page. The error is:
 
" A problem with OnClick Javascript for this button or link was encountered:
{faultcode:'soapenv:Client', faultString:'No service available for class"www.webServicexNet.ConvertTemperatureSoap",}"
 
 
Please help me out for the same.
 
Regards,
 
Diti


Message Edited by soa on 08-19-2008 02:09 AM
SuperfellSuperfell
I don't see how the massNoteInsert has anything to do with the apex callout. but based on the error, your javascript is trying to call www.webServicexNet.ConvertTemperatureSoap, but your class is actually wwwWebservicexNet. ConvertTemperatureSoap
soasoa

Hi

We need to invoke an external Web Service from a standard form (e.g. Account).

For that we had done the following steps :

1. Generated a Apex Class from the WSDL of the Web Service.
(Ref : Chapter 8 of salesforce_apex_language_reference.pdf)

Code:
//Generated by wsdl2apex

public class wwwWebservicexNet {
    public class ConvertTemperatureSoap {
        public String endpoint_x = 'http://www.webservicex.net/ConvertTemperature.asmx';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        private String[] ns_map_type_info = new String[]{'http://www.webserviceX.NET/', 'wwwWebservicexNet'};
      public Double ConvertTemp(Double Temperature,String FromUnit,String ToUnit) {
            wwwWebservicexNet.ConvertTemp_element request_x = new wwwWebservicexNet.ConvertTemp_element();
            wwwWebservicexNet.ConvertTempResponse_element response_x;
            request_x.Temperature = Temperature;
            request_x.FromUnit = FromUnit;
            request_x.ToUnit = ToUnit;
            Map<String, wwwWebservicexNet.ConvertTempResponse_element> response_map_x = new Map<String, wwwWebservicexNet.ConvertTempResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://www.webserviceX.NET/ConvertTemp',
              'http://www.webserviceX.NET/',
              'ConvertTemp',
              'http://www.webserviceX.NET/',
              'ConvertTempResponse',
              'wwwWebservicexNet.ConvertTempResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.ConvertTempResult;
        }
    }
    public class ConvertTempResponse_element {
        public Double ConvertTempResult;
        private String[] ConvertTempResult_type_info = new String[]{'ConvertTempResult','http://www.w3.org/2001/XMLSchema','double','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.webserviceX.NET/','true'};
        private String[] field_order_type_info = new String[]{'ConvertTempResult'};
    }
    public class ConvertTemp_element {
        public Double Temperature;
        public String FromUnit;
        public String ToUnit;
        private String[] Temperature_type_info = new String[]{'Temperature','http://www.w3.org/2001/XMLSchema','double','1','1','false'};
        private String[] FromUnit_type_info = new String[]{'FromUnit','http://www.webserviceX.NET/','TemperatureUnit','1','1','false'};
        private String[] ToUnit_type_info = new String[]{'ToUnit','http://www.webserviceX.NET/','TemperatureUnit','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.webserviceX.NET/','true'};
        private String[] field_order_type_info = new String[]{'Temperature','FromUnit','ToUnit'};
    }
}

2. We then created a button which would invoke the method of the Apex Class
generated from the WSDL.
(Ref : Chapter 7 of Salesforce_platform_cookbook.pdf)
On-Click Java Script :

Code:
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")} 

var fromUnit = prompt("Please enter the unit from which to convert"); 
var toUnit = prompt("Please enter the unit to which to be converted"); 
var temp= prompt("Please enter the temperature"); 

// alert (''Before calling "); 

// Now make a synchronous call to the Apex Web service 
// method 
var result = sforce.apex.execute( 
"wwwWebservicexNet. ConvertTemperatureSoap", // class 
"ConvertTemp", // method 
{iFrom : fromUnit, // method arguments 
iTo: toUnit, 
iTemp:temp});


 3. Add the button to the Account List view Layout

On Click of the button the input prompt are appearing to accept the input value
However finally it is showing the following errors:

fault code : 'Soapenv.client',
Faultstring : 'No Service available for the class wwwWebServiceNet.ConvertTemperatureSOAP'

Am I Missing Some thing?
 
Regards
Sanghamitra Mitra