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
Sylvain@RibbonFishSylvain@RibbonFish 

Access Apex object from c# using SOAP web service

Hi,

See the following example:

global class TestController {

	global cAccountCollection cAccountColl {get; set;}
	
	public BulkSampleController(){
		cAccountColl = new cAccountCollection('Account');
		
	}
	
	
	global PageReference ccSearch()
	{
	        cAccountColl.cSearch('Select Type, Name From Account');
		return null;
		
	}

	global PageReference WebSearch(String query)
		{
			
			
			cAccountColl.cSearch(query);
			
			return null;
			
		}

	
	 webService static cAccountCollection webSccSearch(String query)
	 {
	 	
	 	BulkSampleController test2 = new BulkSampleController();
	 	test2.WebSearch(query);
	 	
	 	
	 	return test2.cAccountColl;
	 }
	
	
	webService static BaseModelCollection webSccSearch2(String query)
	 {
	 	
	 	BulkSampleController test2 = new BulkSampleController();
	 	test2.WebSearch(query);
	 	
	 	return test2.cAccountColl;
	 }
	
	
}

 I access this by using a web reference in c# (visual studio).

When I receive the object by using the web service, visual studio recognize the object type as cAccountCollection but I can't access property of this object.

Someone know why this happen?

Thanks

Sylvain

Best Answer chosen by Admin (Salesforce Developers) 
Sylvain@RibbonFishSylvain@RibbonFish
Someone know how to solve this situation?
Thanks

All Answers

_Prasu__Prasu_
What type of class cAccountCollection is? 
Sylvain@RibbonFishSylvain@RibbonFish

cAccountCollection is a class with:

List<cAccount> 

other properties

 

cAccount: Boolean isSelected

                   Account acct

                   other properties

 

I need this hierarchy in the system but I don't undertand how to expose cAccountCollection and cAccount to access them from the webservice call by c#.

because I return a list of cAccountCollection I just want to access the list then all the cAccount inside.

Thanks

_Prasu__Prasu_

Have you made tthat collectionclass global with each parameter you need to access as global/public?

Sylvain@RibbonFishSylvain@RibbonFish

Yes I put everything as global, no difference visual studio see the object cAccountCollection but don't see any property.

 

Sylvain@RibbonFishSylvain@RibbonFish
Someone know how to solve this situation?
Thanks
This was selected as the best answer
JWykelJWykel
I believe any property you want to be visible needs to be marked as WebService.

For example, you should have:
global class cAccountCollection{
WebService List<cAccount> Accounts;
WebService String otherProperties;
}
global class cAccount{
WebService Boolean IsSelected;
WebService Account Account;
WebService String otherProperties;
}

Also, I am unsure if you will be able to use 'Account' like this. I have never tried using standard objects as a property of a custom webservice class, so if you are successful, please report back!