You need to sign in to do that
Don't have an account?
Sylvain@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
Thanks
All Answers
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
Have you made tthat collectionclass global with each parameter you need to access as global/public?
Yes I put everything as global, no difference visual studio see the object cAccountCollection but don't see any property.
Thanks
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!