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

SAXException: Invalid element in com.sforce.soap.enterprise.sobject.SObject - type

I am running a query with enterprise api as follows:
qr = binding.query("select id from "+objName+ " where Name = '"+objInstanceNameValue+"'");
objName=Account and objInstanceNameValue has an account value.

I am getting the error:

18312 [main] ERROR org.apache.axis.client.Call - Exception:
org.xml.sax.SAXException: Invalid element in com.sforce.soap.enterprise.sobject.SObject - type
at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(
at org.apache.axis.encoding.DeserializationContext.startElement(

What could be the problem?
You're using the enterprise WSDL, but running against the parner WSDL endpoint.
Thanks a lot. I got totally misled bcoz the debug msgs were showing '' and I kept on believing that the endpoint was correct.

What is the ServerURL of the enterprise WSDL?

loginResult.serverUrl= "" ?

Thanks, Andi

it depends, you should be starting with (as per the enterprise WSDL). What gets returned by login will depend on your account.
Mr. Kirill YunussovMr. Kirill Yunussov
This error indicates that your Salesforce client cannot recognize the SObject type, so it's not able to interpret any of that SObject's fields other than ID. 

To resolve (if you are using enterprise WSDL/endpoint) - not only do you need to import the new object's definition into your WSDL, you also need to update the qName section of your com.sforce.soap.enterprise.SoapBindingStub class to reference this new SObject type.  Looks something like this:
qName = new javax.xml.namespace.QName("", "My_New_Object__c");
cls = com.sforce.soap.enterprise.sobject.My_New_Object__c.class;

If you don't update SoapBindingStub class - you will still be able to query the new SObject, but no fields except the ID field.  For any other fields, you will get the following error:

org.xml.sax.SAXException: Invalid element in com.sforce.soap.enterprise.sobject.SObject - Custom_Field__c