You need to sign in to do that
Don't have an account?

Not able to query custom objects - Invalid element in com.sforce.soap.enterprise.sobject.SObject
Hi there,
I am not able to query custom objects like 'Quote' through java.
a) I am able to get the metadata for the 'SFDC_520_Quote__c' object, but am not able to retreive any fields other than id.
b) I get results in the SForce explorer SOQL window for the query 'select Id, opportunity__c from SFDC_520_Quote__c'.
c) I get the the exception for the following line:
qr = binding.query("select Id, opportunity__c from SFDC_520_Quote__c");
Sep 18, 2006 5:30:22 PM org.apache.axis.client.Call invoke
SEVERE: Exception:
org.xml.sax.SAXException: Invalid element in com.sforce.soap.enterprise.sobject.SObject - Opportunity__c
at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:258)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
d)
i done what you said.
1. i have the right to modify this object
2. the select stetment is running in sforce explorer...
My error: org.xml.sax.SAXException: Invalid element in com.sforce.soap.enterprise.sobject.SObject - First_Name__c
On this code:
binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
loginResult = binding.login(User, Password);
binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, loginResult
.getServerUrl());
SessionHeader sh = new SessionHeader();
sh.setSessionId(loginResult.getSessionId());
String sforceURI = new SforceServiceLocator().getServiceName()
.getNamespaceURI();
binding.setHeader(sforceURI, "SessionHeader", sh);
QueryResult qr = binding.query("Select c.First_Name__c from Candidate__c c");
in Candidate__c.static i have:
typeDesc.addFieldDesc(elemField);
elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("First_Name__c");
elemField.setXmlName(new javax.xml.namespace.QName("urn:sobject.enterprise.soap.sforce.com", "First_Name__c"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setMinOccurs(0);
elemField.setNillable(true);
in WSDL i have:
<complexType name="Candidate__c">
<complexContent>
<extension base="ens:sObject">
<sequence>
...
<element name="Email__c" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="Events" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="First_Name__c" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="Histories" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="IsDeleted" nillable="true" minOccurs="0" type="xsd:boolean"/>
...
<element name="Last_Name__c" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="Name" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="Notes" nillable="true" minOccurs="0" type="tns:QueryResult"/>
...
</sequence>
</extension>
</complexContent>
</complexType>
And i have
Your logged in server id is: https://na5-api.salesforce.com/services/Soap/c/8.0/460200D700000009vf9
Your logged in URI id is: urn:enterprise.soap.sforce.com
in my wsdl i change Soap/c/11.1 in Soap/u/11.1 but the serverUrl stay the same
<!-- Soap Service Endpoint -->
<service name="SforceService">
<documentation>Sforce SOAP API</documentation>
<port binding="tns:SoapBinding" name="Soap">
<soap:address location="https://www.salesforce.com/services/Soap/c/11.1"/>
</port>
</service>
On other question is: How can i regenerate my stub?
And the second one: How can i genetrated new stubs using WSDL ?
Do you have another Idea?
thx
Magda
Message Edited by magda on 12-12-2007 04:31 AM
Message Edited by magda on 12-12-2007 04:32 AM
Message Edited by magda on 12-12-2007 04:37 AM
Message Edited by magda on 12-12-2007 07:33 AM
Make sure that you aren't referencing some other jar file in your path that might have and old version of the generated file. I've seen people take the generated classes from the quickStart for example and try to use those on there own orgs.
hi,
thank you for your answer. But I don't know how i can generate the stub.
I do what you said, with the quickstar and modify this one. Could you please explain me what i have to do to generate a stub?
Today morning i try to create a new Projekt, with Sopa
https://www.salesforce.com/services/Soap/u/11.1
without namespaceprefix.
And I'm becoming an exception during the project creation
ConnectionException: Unexpected element. Parser was expecting element 'urn:partner.soap.sforce.com:organizationId' but found 'urn:partner.soap.sforce.com:orgDefaultCurrencyIsoCode'
Message Edited by magda on 12-12-2007 11:30 PM
Login to your developer edition and download the wsdl that you want to use (Enterprise or Partner). Save that wsdl and use the available java tools to create the stub.
There are many different methods for creating the stub depending on your java development environment. I recommend using Apache Axis 1.2. There are easy instructions on the apache axis site that describe how to generate the code using a command line.
What I done (if other peolpe have the same problem)
1 install Tomcat
2 download axis
3 in tomcate/weapps copie webapps/axis
4 install xml parser xerces J bin
5 add xml-aps.jar and ercesImpl.jar in AXISCLASSPATH
6 add tomcat in Eclipse (properties/server)
7 download WSDL from salesforce
8 on WSDL generate Client / Deploy Client
I think there are other possibilities. But I'm very happy because it is now running without Exception.
I can now begin to build my Application ;)
To resolve - 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:
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