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

Constructor not defined: [myservice.listValues].<Constructor>(String, String)




   I am  need  use webservice to get some values. I  generated apex class from wsdl , in that class i am getting 

public class myService{

public myService.userInfo[] listValues(Long userId,String userName) {





I need to pass parameters and need to get some values

so i write  like this 

 myservice.listValues myObj = new  myservice.listValues('456','myName');


I got error like 


Constructor not defined: [myservice.listValues].<Constructor>(String, String)




Hi karthik,


You have to use
myservice.listValues myObj = new  myservice.listValues(456,'myName');


instead of

myservice.listValues myObj = new  myservice.listValues('456','myName');


because first parameter of listValues is Long not a string.


Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator
My Blog:-

Thanks for your reply
I tried all the ways like

myservice.listValues myObj = new myservice.listValues(456,myName);

myservice.listValues myObj = new myservice.listValues(456,'myName');

myservice.listValues myObj = new myservice.listValues('456','myName');

The real problem is not the way we pass the parameter


public class myService{

public void myMethod(long x ,string s){


myservice.mymethod(x,'y') - it will be correct because it does not have anything like
before method name . for this we need to create constructor

For example look at this url

I am unable to get like this

@ekarthik - The way you are accessing the methid is wrong. What you need is to instantiate an object of MyService and call the instance method listValues. The return type of the method is an array of MyService.UserInfo. So you need to try this:

myService.UserInfo[] uiList = new myService().listValues(456,myName);

 In case you do not need to create an object to call the function, you can define the method as static and use the notation

myService.UserInfo[] uiList = myService.listValues(456,myName);

You need to understand that the constructor cannot return any value. It can be parameterized and has to have the class name.