You need to sign in to do that
Don't have an account?
imhere
Class Cast Exception Custom object
i created a Custom Object : Area
using partner API .. create and describle call works fine.
But when i Query this object and cast it back in Area it gives Class Cast Exception
Folloing is the code:
queryResult = binding.query("select Name, City__c from Area__c");
while (queryResult.getRecords() != null)
{
for (int i = 0; i < queryResult.getRecords().length; i++)
{
LINE NO 425 Area con = (Area) queryResult.getRecords(i); // EXCEPTION ARISES HERE
String firstName = con.getName ();
String lastName = con.getCity__c();
System.out.println("Contact " + (i + 1) + ": " + firstName + " "
+ lastName);
}
queryResult = binding.queryMore(queryResult.getQueryLocator());
}
EXCEPTION IS :
java.lang.ClassCastException: com.sforce.soap.partner.sobject.SObject
at com.smartmicros.sforce.test.SamplesPartner.querySample(SamplesPartner.java:425)
at com.smartmicros.sforce.test.SamplesPartner.run(SamplesPartner.java:537)
at com.smartmicros.sforce.test.SamplesPartner.main(SamplesPartner.java:65)
I extended Area Object from SObject of parnters API.
wt i think is : SObject's instance is created and as the Instance is of base class it can not be Cast Down in Derived class's instance
would any one please guide me ?? The same Call for Account works fine using Enterprice API.
using partner API .. create and describle call works fine.
But when i Query this object and cast it back in Area it gives Class Cast Exception
Folloing is the code:
queryResult = binding.query("select Name, City__c from Area__c");
while (queryResult.getRecords() != null)
{
for (int i = 0; i < queryResult.getRecords().length; i++)
{
LINE NO 425 Area con = (Area) queryResult.getRecords(i); // EXCEPTION ARISES HERE
String firstName = con.getName ();
String lastName = con.getCity__c();
System.out.println("Contact " + (i + 1) + ": " + firstName + " "
+ lastName);
}
queryResult = binding.queryMore(queryResult.getQueryLocator());
}
EXCEPTION IS :
java.lang.ClassCastException: com.sforce.soap.partner.sobject.SObject
at com.smartmicros.sforce.test.SamplesPartner.querySample(SamplesPartner.java:425)
at com.smartmicros.sforce.test.SamplesPartner.run(SamplesPartner.java:537)
at com.smartmicros.sforce.test.SamplesPartner.main(SamplesPartner.java:65)
I extended Area Object from SObject of parnters API.
wt i think is : SObject's instance is created and as the Instance is of base class it can not be Cast Down in Derived class's instance
would any one please guide me ?? The same Call for Account works fine using Enterprice API.
is there any way ???
i am trying to write my Own Ser and DeSer and registering my classes to the Bindings
as it is done in SoupBindingStub class of enterprise and partner API.
would it work ??
No, you can't register custom serializers/deserializers and have it work because at the XML level there is only the sObject type, no others, so you can't have the deserializer fire for MyCustomObject__c but not for Account. (for the parnter API).
for the enterprise API, re-download the WSDL after the custom object was created, then it'll be in the WSDL and WSDL2Java will create all the relevant classes needed.
i downloaded the enterprose WSDL. it worked fine.
If i include This code in Prtner's WSDL and run WSDL2Java on it.... would it work ??
.....
......
If doing wt described above is Useless ...
would u plz tell me wts the difference between Partner and Enterprise any LINK or Document wil be helpFull.
when i started using i thgt Custom Objects will be dealt Via Partner's API.
SOAP Request Envelop is same... SOAP response Envelop is same . I could not get where it differes?