I've written the following Apex class as a part of a suite of custom webservices. All have the same problem but this one is the easiest example; if I can solve it for this, I can solve it for the other webservices.
global class WebServiceA4S {
global class returngetEnquiries {
public String status {get;set;}
public String error {get;set;}
public List<Enquiry__c> results {get;set;}
}
Webservice static returngetEnquiries getEnquiries() {
returngetEnquiries rtnError = new returngetEnquiries();
rtnError.status='success';
rtnError.error = '';
rtnError.results = new List<Enquiry__c>();
// id en name
try {
list<Enquiry__c> tmp = [Select id,name From Enquiry__c];
rtnError.results = tmp;
}
catch(Exception e) {
rtnError.status='error';
rtnError.error = String.valueof(e);
}
return rtnError;
}
}
Now if I debug the rtnError returned, just before the 'return rtnError', it does show a list of Enquiries so the code works. The problem is that if I call the Webservice (via PHP or SOAPUI) the result is empty. I use the wsdl from the class, created by salesforce of course.
I also looked at the wsdl and it looks like this:
...
<xsd:complexType name="returngetEnquiries">
<xsd:sequence/>
</xsd:complexType>
<xsd:element name="getEnquiries">
<xsd:complexType>
<xsd:sequence/>
</xsd:complexType>
</xsd:element>
<xsd:element name="getEnquiriesResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="result" type="tns:returngetEnquiries" nillable="true"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
...
It looks like the returngetEnquiries is not defined. I tried to edit it and add the fields as defined in the class, but that doesn't help.