You need to sign in to do that
Don't have an account?
MattReynolds
Java, sample code / INVALID_TYPE: Must send concrete entity type
***** I'm not sure how to adjust the formatting so this post isn't garbled, please comment with help? *****
I've been trying to create a lead, and figured starting with the sample code was a good idea. As such, I copied the lead creation and login code from the Samples object and strung them together. When I got the above error, I figured I was doing something wrong, so I modified the samples slightly to force creation of a sample user to be used when converting a lead. Here's the code.
Samples::getUnconvertedLead:
QueryResult qr = null;
//if ( qr.getSize() == 0 ) { // No leads where found that have not been
// converted, so....
// we will create a lead and then run the query again
System.out.println( "No unconverted leads found, will create one for you..." );
createLeadSample();
qr = binding.query( "Select Id, FirstName, LastName from Lead where ConvertedDate = Null" );
// }
I then use the samples, entry 19 (convert lead), and I get the following error :
6315 [main] DEBUG org.apache.axis.transport.http.HTTPSender - Enter: HTTPSender::invoke
6388 [main] DEBUG org.apache.axis.transport.http.HTTPSender - XML sent:
6388 [main] DEBUG org.apache.axis.transport.http.HTTPSender - ---------------------------------------------------
6392 [main] DEBUG org.apache.axis.transport.http.HTTPSender - POST /services/Soap/c/6.0 HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.3
Host: na1-api.salesforce.com
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Content-Length: 668
9TmIvTqotGCN_c.GekBT1DE0RYoHessVxfIQUK.vzwUz2lK0tHP_nOJgFrqHAnK.l2E6Thcgy0imJXvtVPjFMhhD2wYHcrlK4SNdGN37zi4=
6446 [main] DEBUG org.apache.axis.transport.http.HTTPSender - HTTP/1.0 500 Internal Server Error
6449 [main] DEBUG org.apache.axis.transport.http.HTTPSender - Server sfdc
6450 [main] DEBUG org.apache.axis.transport.http.HTTPSender - Cache-Control private
6451 [main] DEBUG org.apache.axis.transport.http.HTTPSender - Content-Type text/xml; charset=utf-8
6452 [main] DEBUG org.apache.axis.transport.http.HTTPSender - Date Fri, 28 Oct 2005 01:57:06 GMT
6454 [main] DEBUG org.apache.axis.transport.http.HTTPSender -
no Content-Length
6455 [main] DEBUG org.apache.axis.transport.http.HTTPSender -
XML received:
6455 [main] DEBUG org.apache.axis.transport.http.HTTPSender - -----------------------------------------------
6657 [main] DEBUG org.apache.axis.transport.http.HTTPSender -
soapenv:Server
common.exception.ApiException: Must send a concrete entity type.
INVALID_TYPE
Must send a concrete entity type.
-1
-1
6658 [main] DEBUG org.apache.axis.transport.http.HTTPSender - Exit: HTTPDispatchHandler::invoke
Failed to create lead succesfully, error message was:
null
***
This doesn't seem to be the desired behavior, so I figured I'd ask what's wrong with the samples that's causing this.
I've been trying to create a lead, and figured starting with the sample code was a good idea. As such, I copied the lead creation and login code from the Samples object and strung them together. When I got the above error, I figured I was doing something wrong, so I modified the samples slightly to force creation of a sample user to be used when converting a lead. Here's the code.
Samples::getUnconvertedLead:
QueryResult qr = null;
//if ( qr.getSize() == 0 ) { // No leads where found that have not been
// converted, so....
// we will create a lead and then run the query again
System.out.println( "No unconverted leads found, will create one for you..." );
createLeadSample();
qr = binding.query( "Select Id, FirstName, LastName from Lead where ConvertedDate = Null" );
// }
I then use the samples, entry 19 (convert lead), and I get the following error :
6315 [main] DEBUG org.apache.axis.transport.http.HTTPSender - Enter: HTTPSender::invoke
6388 [main] DEBUG org.apache.axis.transport.http.HTTPSender - XML sent:
6388 [main] DEBUG org.apache.axis.transport.http.HTTPSender - ---------------------------------------------------
6392 [main] DEBUG org.apache.axis.transport.http.HTTPSender - POST /services/Soap/c/6.0 HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.3
Host: na1-api.salesforce.com
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Content-Length: 668
9TmIvTqotGCN_c.GekBT1DE0RYoHessVxfIQUK.vzwUz2lK0tHP_nOJgFrqHAnK.l2E6Thcgy0imJXvtVPjFMhhD2wYHcrlK4SNdGN37zi4=
6446 [main] DEBUG org.apache.axis.transport.http.HTTPSender - HTTP/1.0 500 Internal Server Error
6449 [main] DEBUG org.apache.axis.transport.http.HTTPSender - Server sfdc
6450 [main] DEBUG org.apache.axis.transport.http.HTTPSender - Cache-Control private
6451 [main] DEBUG org.apache.axis.transport.http.HTTPSender - Content-Type text/xml; charset=utf-8
6452 [main] DEBUG org.apache.axis.transport.http.HTTPSender - Date Fri, 28 Oct 2005 01:57:06 GMT
6454 [main] DEBUG org.apache.axis.transport.http.HTTPSender -
no Content-Length
6455 [main] DEBUG org.apache.axis.transport.http.HTTPSender -
XML received:
6455 [main] DEBUG org.apache.axis.transport.http.HTTPSender - -----------------------------------------------
6657 [main] DEBUG org.apache.axis.transport.http.HTTPSender -
soapenv:Server
common.exception.ApiException: Must send a concrete entity type.
INVALID_TYPE
Must send a concrete entity type.
-1
-1
6658 [main] DEBUG org.apache.axis.transport.http.HTTPSender - Exit: HTTPDispatchHandler::invoke
Failed to create lead succesfully, error message was:
null
***
This doesn't seem to be the desired behavior, so I figured I'd ask what's wrong with the samples that's causing this.
See, all the OTHER pieces work find. Retrieving objects, converting leads, etc. But creating objects from scratch is the only piece that doesn't seem to work.
I can package up all my stuff into a jar and put it somewhere if that'll help.
I guess I was figuring that the sample code should work regardless of the other issues. Also, the error messages being returned (since they have a default cause) should be more descriptive if possible.
Message Edited by MattReynolds on 10-27-2005 09:17 PM
other than the default URL in the generated code for your stub, you shouldn't need to know about this in your code.
If you're still having problems, please post your code.
Apparently, the code is too long to post. Please try this URL. http://pastebin.com/409138
Checkout line 1830. That's the code I modified.
Is there a known issue with using the Axis 1.3 jars?
Were you able to get Axis 1.3 to work with sforce 6.0? If so, could you repost the code, or provide another mechanism. We'd like to take advantage of the compression available in 1.3, and have reworked all of our surrounding code against the 1.3 implementation. We are unable to edit or create new objects however with axis 1.3.
Thanks,
-Art
This message was posted to blog.sforce.com in response to a similar question with Axis 1.3 and the sforce API:
"The Axis 1.3 library is compatible with the SForce API v6 but the way to you call the API is a bit different. In order to resolve your particular problem performing Update and Create, you can do the following:
// Instead of using the base class array (won't work)
SObject[] upserts = new SObject[2];
// Use an array of specific objects
SObject[] upserts = new Account[2];
Posted by: Alex Warshavsky | Nov 18, 2005 3:20:03 PM"
But this solution only applies to Enterprise API. Is there any other solution to this problem? I read through the whole thread but didn't quite get what exactly was the solution for people using Partner API.
Right now I am getting the same error message as included the initial post of this thread. My endpoint URL is https://na1-api.salesforce.com/services/Soap/u/7.0. I am using Partner WSDL and PartnerSample.Java included in Partner Sample toolkit. The method createLeadSample() from PartnerSample.java is giving me the error message. Nothing was modified to that sample code except to not take the user input for email address. I don't see any reason why the PartnerSample code shouldn't work as it is.
If there's something really obvious I am missing, I apologize. I am quite new to webservice APIs in general. Any help will be appreciated. I am really stuck and running out of time.
Thanks in advance!
Following is the code from PartnerSample.java
private void createLeadSample() {
// Verify that we are already authenticated, if not
// call the login function to do so
if (!loggedIn) {
if (!login())
return;
}
try {
SObject[] leads = new SObject[1];
MessageElement[] lead = new MessageElement[23];
lead[0] = newMessageElement("AnnualRevenue", "1000000.0");
lead[1] = newMessageElement("City", "San Francisco");
lead[2] = newMessageElement("Company", "Acme Anvils");
....
lead[20] = newMessageElement("Street", "10 Downing Street");
lead[21] = newMessageElement("Title", "Director of Directors");
lead[22] = newMessageElement("Website", "www.acmeanvils.com");
leads[0].setType("Lead");
leads[0].set_any(lead);
SaveResult[] sr = binding.create(leads);
for (int j = 0; j < sr.length; j++) {
if (sr[j].isSuccess()) {
System.out.println("A lead was created with an id of: "
+ sr[j].getId());
} else {
// there were errors during the create call, go through the
// errors
// array and write them to the screen
for (int i = 0; i < sr[j].getErrors().length; i++) {
// get the next error
com.sforce.soap.partner.Error err = sr[j].getErrors()[i];
System.out.println("Errors were found on item "
+ new Integer(j).toString());
System.out.println("Error code is: "
+ err.getStatusCode().toString());
System.out
.println("Error message: " + err.getMessage());
}
}
getUserInput("\nHit return to continue...");
}
} catch (ApiFault af) {
System.out
.println("\nFailed to create lead succesfully, error message was: \n"
+ af.getExceptionMessage());
getUserInput("\nHit return to continue...");
} catch (Exception ex) {
System.out
.println("\nFailed to create lead succesfully, error message was: \n"
+ ex.getMessage());
getUserInput("\nHit return to continue...");
}
}
updateFields[0] = new MessageElement(new QName("AMBI_Pathworks_ID"), newTask.getId());
SObject leadUpdate = new SObject(type, new String [] {}, id, updateFields);
binding.update(new SObject [] {leadUpdate});
I'm 99.9% certain it's the Partner endpoint(<--- of course I was wrong! see later).I just double checked the code and it's all com.sforce.soap.partner.* classes. (And it's the same stuff I use a few lines of code earlier to do a query on an arbitrary type so I can call get_any() successfully).Dan
Message Edited by pathworks on 08-04-2006 04:21 PM