You need to sign in to do that
Don't have an account?

Can a custom Salesforce webservice return sObjects via SOAP?
Hi all,
I'm trying to create a custom SF webservice and the call it from my .NET app.
So I'm adding my service's WSDL in VS 2012. It does work for a tiny test webservice that returns a string but it doesn't work when I want to return an opportunity.
Can I return sObjects at all?
In case I can, then here are some details:
By not working I mean that I can't reference my web reference in code and when I try to update web reference I'm getting the following error:
Is there a workaround for this?
My tiny test service code is the following (it does work when called from Apex):
global class OpportunitySearch { webService static Opportunity[] getOpportunities() { Opportunity[] searchResults = Database.query('SELECT Name, Id FROM Opportunity LIMIT 10'); return searchResults; } }
It behaves the same way when I'm trying to return a single Opportunity or an Account.
Thanks in advance
However, have you considered using the Partner (or Enterprise) wsdl instead?
If those don't work, then you could always create a global wrapper class to return the Id and other fields of the Opportunity your .NET webservice needs.
Hi James,
Thanks for your reply.
Yep, I'm used to Enterprise and Partner wsdl and I'm fond of them, but I think that a custom webservice could be a bit faster (in case you need to do something complex and need to make several calls for it) so I'm trying to explore this option at the moment.
The same webservice wsdl does work fine when I change the return type like this:
Or, you could also serialize the Opportunity list to JSON as well, if it's small enough, and then deserialize it in your .NET application.
Hope it helps 2 years later.