Caling up the service, form the Client

Topics: General Discussion Forum, July and December Releases Forum
Apr 9, 2008 at 10:07 AM
Hi,
well i am facing an issue with the calling up of an operation in the Client side.
My operation is all about retreving all the Users that are in the DB. i am using List<> to get all the User's.

I have created a Response message contract in which there are two fileds, One is of UserDc and another one is of StstusType DC.
here comes the difficult task in which i am facing...

i dont have anything in my resuest MC, but after creating the Proxy class, and i compiled, i am getting an error. like....
Error 192 No overload for method 'GetAllUsers' takes '0' arguments

While i am keepign mouse ove the method in the Client side i am able to see one message like,
userDC[] UserClient.GetAllUsers(out StatusType Status),
but my method is nothing but... userDC[] dc=UserClient.GetAllUsers(),

please help me with.............
Hopefully,
Nimi
Apr 9, 2008 at 4:08 PM
You should use that call,

userDC[] UserClient.GetAllUsers(out StatusType Status)
That's the one you should use. Notice that is also returning the StatusType along with the userDC array.
Apr 9, 2008 at 4:58 PM
But in this case whoat should i give as the input,
what could be the parameter...
i wanna take all the users,
i havnt come accross this type situation.
userDC[] udc= UserClient.GetAllUsers(out StatusType Status)---------------> what should be the parameter...

i am really stuck up with this...
please help me,
Apr 10, 2008 at 11:19 PM
in this case you will end up with two outputs, userDC[] and Status, so your code will look like this:

StatusType theStatus;
userDC[] udc= UserClient.GetAllUsers(out theStatus)---------------> 
So after the service call, the variable 'theStatus' will contain the passed data.
Apr 11, 2008 at 2:13 PM
in the server side, i am not giving anything in the Request, , my request is empty. To get all users in the Db, i dont have to give anything in the request. i am not passing any parameter.

here comes the problem, in the above reply
_______________________________________________________________________________________________________________
userDC[] udc= UserClient.GetAllUsers(out theStatus)
---------------------------------------------------------------------------------------------------------------
my doubts are :
1) i am getting like this, but why it is coming like this ?
2) i am using List<userDC> as the Response of the service method. bu tin the client side when i am takign all the values, i am able to take values as userDC[] udc. Why is it so ? Cant i use List<userDC> istead of userdc[].

---------------------------------------------------------------------------------------------------------------------------------------------------
This is a part of code fro mmy proxy class :

System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)
GetAllUserResponse IUser.GetAllUser(GetAllUserRequest request)
{
return base.Channel.GetAllUser(request);
}

public employee.datacontracts.2008.02.UserDC[] GetAllUser(out employee.datacontracts.2008.02.StatusType Status)
{
GetAllUserRequest inValue = new GetAllUserRequest();
GetAllUserResponse retVal = ((IUser)(this)).GetAllUser(inValue);
Status = retVal.Status;
return retVal.UserList;
}
---------------------------------------------------------------------------------------------------------------------------------------------------


Well, initailly i had something like request, GetUserRequest. But no wi dont have this in my Service Method, but the Proxy class which i have generated shows that still it has that. Moreover

public employee.datacontracts.2008.02.UserDC[] GetAllUser(out employee.datacontracts.2008.02.StatusType Status)

the above piece of code indicates something in the request....


Can you please help me up to avoid the confusions.....

nimi
Apr 11, 2008 at 10:22 PM
In this case, using the 'GetAllUser(out StatusType Status)' method you are actually not passing a request and just getting two parameters back as response, that are Status and the UserDC array. Notice that the parameter of 'GetAllUser is marked as 'out' so that will only return values and won't accept any input value. This is part of standard C# parameters definitions.
'
Apr 12, 2008 at 6:55 AM

System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)
GetAllUserResponse IUser.GetAllUser(GetAllUserRequest request)
{
return base.Channel.GetAllUser(request);
}

public employee.datacontracts.2008.02.UserDC[] GetAllUser(out employee.datacontracts.2008.02.StatusType Status)
{
GetAllUserRequest inValue = new GetAllUserRequest();
GetAllUserResponse retVal = ((IUser)(this)).GetAllUser(inValue);
Status = retVal.Status;
return retVal.UserList;
}

in this, i can find <<<<<<<<public employee.datacontracts.2008.02.UserDC[]>>>> what is this ?
actually i am not defining the an array of DataContracts anywhere but what is this ? How it came here....

my resposne is List<UserDC>, instead of that userDC[] is comming.......

Apr 14, 2008 at 5:31 PM
That's the "tramslation" that the automatic code gen did when the proxy was created (same as svcutil.exe does.)
However, nothing stops you from using your expectd method signature like:

GetAllUserResponse IUser.GetAllUser(GetAllUserRequest request)
{
return base.Channel.GetAllUser(request);
}

And call it from there. In order to do that, you may cast your client to "IUser" and access that method like above.
Apr 15, 2008 at 11:18 AM
Charly,
i am also using svcutil to generate proxy class..
here is my question.
below provided is a part form my IUser

OperationContract(IsTerminating = false, IsInitiating = true, IsOneWay = false, AsyncPattern = false, Action = "GetAllFromUserGroups")
GetAllUserGroupsResponse GetAllFromUserGroups();

here GetAllUserGroupsResponse is the response..
class definition is provided below :

MessageContract
public class GetAllUserGroupsResponse
{
private List<UserGroupDC> UserGroupResponseField;

MessageBodyMember(Order = 0)
public List<UserGroupDC> UserGroupResponse
{
get { return UserGroupResponseField; }
set { UserGroupResponseField = value; }
}


}

after creating the proxy class, when i am trying to access it form the User, i am getting an array of DC as the response...

but here the response is class, then y i am getting it as the DC[]...

please dont mind, if this is a blunder question....
Apr 15, 2008 at 6:16 PM
Try something like the following:

IUser proxy = new MyClientProxy() as IUser;
//set the request
// call your operation
GetAllUserResponse response = GetAllUser(request);

Apr 16, 2008 at 11:12 PM
To avoid having an out parameter in the client proxy, set the isWrapped property to true for the response message contract in the service contract design.




Nimi wrote:
Hi,
well i am facing an issue with the calling up of an operation in the Client side.
My operation is all about retreving all the Users that are in the DB. i am using List<> to get all the User's.

I have created a Response message contract in which there are two fileds, One is of UserDc and another one is of StstusType DC.
here comes the difficult task in which i am facing...

i dont have anything in my resuest MC, but after creating the Proxy class, and i compiled, i am getting an error. like....
Error 192 No overload for method 'GetAllUsers' takes '0' arguments

While i am keepign mouse ove the method in the Client side i am able to see one message like,
userDC[] UserClient.GetAllUsers(out StatusType Status),
but my method is nothing but... userDC[] dc=UserClient.GetAllUsers(),

please help me with.............
Hopefully,
Nimi