You need to sign in to do that
Don't have an account?
Fluffy
Cant execute queries with axis 2
Hello, I am using axis 2 and having a problem executing queries from my Java code. I have generated the SforceServiceStub.java from the wsdl file, and I am able to connect to the salesforce service successfully (i.e. I can get the server URL, and a session ID). Moreover, the describeGlobal()
function runs great, and returns all the object types. However, when trying to execute a basic
query, I'm getting this error:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
java.lang.RuntimeException: Unsupported type urn:sobject.enterprise.soap.sforce.com Contact
at com.sforce.soap.enterprise.SforceServiceStub$ExtensionMapper.getTypeObject(SforceServiceStub.java:25165)
at com.sforce.soap.enterprise.SforceServiceStub$SObject$Factory.parse(SforceServiceStub.java:16678)
at com.sforce.soap.enterprise.SforceServiceStub$QueryResult$Factory.parse(SforceServiceStub.java:21263) at com.sforce.soap.enterprise.SforceServiceStub$QueryResponse$Factory.parse(SforceServiceStub.java:40935)
at com.sforce.soap.enterprise.SforceServiceStub.fromOM(SforceServiceStub.java:25016)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
my code is as follows:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public class SampleLogin {
public static void main(String args[]) {
SforceServiceStub stub = new SforceServiceStub();
Options options = stub._getServiceClient().getOptions();
options.setProperty(HTTPConstants.MC_ACCEPT_GZIP, Boolean.TRUE);
options.setProperty(HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE);
Login lg = new Login();
lg.setPassword("********");
lg.setUsername("*******");
LoginScopeHeader lsh = null;
LoginResponse response = stub.login(lg, lsh);
LoginResult lr = response.getResult();
SessionHeader sh = new SessionHeader();
sh.setSessionId(lr.getSessionId());
stub = new SforceServiceStub(lr.getServerUrl());
options = stub._getServiceClient().getOptions();
options.setProperty(HTTPConstants.MC_ACCEPT_GZIP, Boolean.TRUE);
options.setProperty(HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE);
QueryOptions qOptions = new QueryOptions();
qOptions.setBatchSize(200);
Query q = new Query();
q.setQueryString("select AccountId from Contact");
QueryResponse qResponse = stub.query(q, sh, qOptions, null);
QueryResult qr = qResponse.getResult();
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Can anyone please suggest what I may be doing wrong, and point in the right direction ?
Thanks a bunch ahead,
:0)
--Fluffy
function runs great, and returns all the object types. However, when trying to execute a basic
query, I'm getting this error:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
java.lang.RuntimeException: Unsupported type urn:sobject.enterprise.soap.sforce.com Contact
at com.sforce.soap.enterprise.SforceServiceStub$ExtensionMapper.getTypeObject(SforceServiceStub.java:25165)
at com.sforce.soap.enterprise.SforceServiceStub$SObject$Factory.parse(SforceServiceStub.java:16678)
at com.sforce.soap.enterprise.SforceServiceStub$QueryResult$Factory.parse(SforceServiceStub.java:21263) at com.sforce.soap.enterprise.SforceServiceStub$QueryResponse$Factory.parse(SforceServiceStub.java:40935)
at com.sforce.soap.enterprise.SforceServiceStub.fromOM(SforceServiceStub.java:25016)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
my code is as follows:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public class SampleLogin {
public static void main(String args[]) {
SforceServiceStub stub = new SforceServiceStub();
Options options = stub._getServiceClient().getOptions();
options.setProperty(HTTPConstants.MC_ACCEPT_GZIP, Boolean.TRUE);
options.setProperty(HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE);
Login lg = new Login();
lg.setPassword("********");
lg.setUsername("*******");
LoginScopeHeader lsh = null;
LoginResponse response = stub.login(lg, lsh);
LoginResult lr = response.getResult();
SessionHeader sh = new SessionHeader();
sh.setSessionId(lr.getSessionId());
stub = new SforceServiceStub(lr.getServerUrl());
options = stub._getServiceClient().getOptions();
options.setProperty(HTTPConstants.MC_ACCEPT_GZIP, Boolean.TRUE);
options.setProperty(HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE);
QueryOptions qOptions = new QueryOptions();
qOptions.setBatchSize(200);
Query q = new Query();
q.setQueryString("select AccountId from Contact");
QueryResponse qResponse = stub.query(q, sh, qOptions, null);
QueryResult qr = qResponse.getResult();
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Can anyone please suggest what I may be doing wrong, and point in the right direction ?
Thanks a bunch ahead,
:0)
--Fluffy
Hi Simon,
thanks alot for your reply.
I saw your code snippet, but it is impossible for me to simply re-use it, because for
some reason the classes which got generated from my wsdl are somewhat different.
For example, there is no such thing as
QueryDocument in my class space.
Am I SUPPOSED to have a QueryDocument ?
Moreover, as you can see in my code, I DO create a new session
header before I call the query, and the query function DOES get
the new copy of the session header. The only difference is that
I don't have any QueryDocument, but - obviously I can't have it
because it doesn't exist amongst the classes generated by the wsdl.
So can you please be more specific regarding what I may be doing wrong
here ? Do you think that I SHOULD have had a QueryDocument class , so
does that mean that my wsdl wasn't generated correctly or something ?
(Although I'm pretty sure that wsdl generated everything correctly because
otherwise I probably wouldn't be able to login).
?? (??????? ???? ?????? ?)
Thanks alot for any clarifications,
regards,
fluffy
"the default ADB databinding will not work with the sforce enterprise WSDL, because it can't handle complex types extensions, unfortunately it won't tell you this at WSDL2Java time, you get a rather more cryptic error at runtime, use the XMLBeans option instead (this is unfortunate because the xmlbeans model is even more verbose to use than ADB)"
I used the xmlbeans option, like you suggested and it worked this time. Thanks so much for your help !
regards,
--Fluffy
did someone succeed in generating and using the partner wsdl with axis2?
I have some code which uses the get_any method and this seems not to be supported by xmlbeans options.
Regards
Massi
I use Axis2 to integrate with Salesforce web-service API and run queries.
see http://rabout.com/?q=salesforce_api_axis2
I hope you'll find it useful,
Alon