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
shiva pendemshiva pendem 

How to Return a Record using SOAP ?

Hi Everyone this is my code for returning a account record but its not parsing while Generating from WSDL from other ORG .Can anyone Pplease give me the the solution how to fetch the record .

global class TestSoapWeb
{      webService static Account RecordFetch(id aid) {        
      Account Ac = [select name, id, phone, Industry, Fax, Type from account where id=:aid];         
        return Ac;    
 }
}
After writing this Generated WSDL'S Enterprise and Custom .then I am Calling this WSDL from other ORG by Clicking "Generate From WSDL"
At that time .Getting error LIke  :
  " Error  Apex Generation Failed    :Unable to find complexType for {http://soap.sforce.com/schemas/class/TestSoapWeb}address"              
.Even though tried in .Net But same problem getting ..Please give me the solution .
 
Sumitkumar_ShingaviSumitkumar_Shingavi
You are trying to do something weird! Partner & Enterprise WSDL are for external communication and you should not use then inside Salesforce only through "Generate Apex from WSDL" [that button Apex Classes list view button]. These WSDLs normaill used in .Net and Java app integrations and you can use tool like WSDLToJava or same kind of tool for .Net.
shiva pendemshiva pendem
Hi Sumitkumar
I have tried to access this generated WSDL in DotNet also Its not working there.but when we return Single field ( return ac.name )its working properly. But in my senario I want return complete record with all the fields which we have query At that we are getting problem can u please give me some advise to me for this issue .
Sumitkumar_ShingaviSumitkumar_Shingavi
Check this : http://www.salesforce.com/developer/docs/api/Content/sforce_api_calls_query.htm
Also for getting all fields in SOQL query string, you need to use
DescribeSObjectResult res = binding.describeSObject("Account");
Field[] fields = res.getFields();String expr = "";
for(int i=0; i < fields.length-1; i++) {
	expr += fields[i].getName() + ", ";
}
expr += fields[ fields.length - 1 ].getName();
String qry = "Select " + expr + " from Account";
QueryResult res = binding.query( qry );
Hope this helps!