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
VPVP 

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(BeanDeserializer.java:258)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)

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

What is the ServerURL of the enterprise WSDL?

loginResult.serverUrl= "https://eu0-api.salesforce.com/services/Soap/c/7.0" ?

Thanks, Andi

SuperfellSuperfell
it depends, you should be starting with www.salesforce.com/services/Soap/c/7.0 (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("urn:sobject.enterprise.soap.sforce.com", "My_New_Object__c");
cachedSerQNames.add(qName);
cls = com.sforce.soap.enterprise.sobject.My_New_Object__c.class;
cachedSerClasses.add(cls);
cachedSerFactories.add(beansf);
cachedDeserFactories.add(beandf);

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