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
MattReynoldsMattReynolds 

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.
SuperfellSuperfell
You typically get this by sending a partner API request to the enterprise API endpoint.
MattReynoldsMattReynolds
Agreed, and I've checked the URL (It's using /c/6.0 not u, right?) and I've generated the code from the WSDL I downloaded from my account.

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

MattReynoldsMattReynolds
BTW, I didn't see in the docs where these URLs are documented. Can you point me at them?
SuperfellSuperfell
The URLs come from the WSDLs.
MattReynoldsMattReynolds
So am I supposed to be using "C" or "U"? In my XML that I posted, I'm using C, which is returned from the login server. My WSDL as well has "C" in the URL. Am I missing something? It seems like I'm using the right URLs. The code also has "C" in the URL Locator.
SuperfellSuperfell
c is used for the enterprise API. u for the Partner API.

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.
MattReynoldsMattReynolds
Currently I'm just using the standard Samples.java, with a slight modification to force it to create a new lead (And I replaced the logging). Here it is.

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.
MattReynoldsMattReynolds
Also, creating other objects (Account, etc) is causing the same problem. I can package up the generated code, WSDL, and sample code if that will help. I'm not sure what check you guys to do match the object type (Package? WSDL name space?), but if you could tell me I can start trying to track this down on my end from a code gen standpoint.
MattReynoldsMattReynolds
I've identified the problem. By creating a new project and just using your axis and saaj jars, it works.

Is there a known issue with using the Axis 1.3 jars?
SuperfellSuperfell
try using Axis 1.2.1 instead of 1.3, it might be a 1.3 bug.
MattReynoldsMattReynolds
It is :) What versions are you guys using? I'll end up having to use a custom classloader to use your stuff since we're using 1.3 elsewhere. Do you have a plan to upgrade to 1.3 or support it any time in the future?
adalessandroadalessandro
Matt,
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
adalessandroadalessandro
Matt/Simon,
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"
amoahamoah
"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...");
        }
    }




SuperfellSuperfell
Start by using a known version of Axis, like 1.1 or 1.2.1, newer is not always better, particular where axis is concerned.
pathworkspathworks
 
Is this still a known issue?  I'm using Axis 1.3 and cannot update a Lead using the Partner API.  My code is pretty simple:
 
                 MessageElement [] updateFields = new MessageElement[1];
                 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});
But I get the error "must send a concrete entity type".  Any help would be appreciated - I'd prefer not to have to put in a custom classloader for Axis 1.2 at this point...
 
 
SuperfellSuperfell
Sounds like you're sending the request to the enterprise endpoint, not the partner endpoint.
pathworkspathworks

 

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

pathworkspathworks
 
Hmm , you may be right actually.  I'm using the partner classes but a URL passed from a HYPERLINK() function that was probably the enterprise end point.  Interesting, it worked fine for the query and get_any() methods.
 
Dan
 
pathworkspathworks
 
Ok, I was using this:
 
 
 
I suppose that's the enterprise end point...the reason I was using that is that I can't pass the API Server URL from a HYPERLINK function - it's unavailable.  My code falls back on the hard-coded URL above.
 
I'll look up the correct Partner endpoint and see if that makes a difference.  It would be nice to be able to pass it from the HYPERLINK function.
 
Dan