ConcourseSuite Support

Support
Corporate
PUBLIC PROFILE

Back to topics

Discuss Development

How are XML-API requests processed?

You need to be logged in to post messages

How are XML-API requests processed?

1/21/2008 2:29 PM EST

Hello,

I'm currently trying to debug code I've written for the HTTP XML-API. (Specifically, I can't seem to get a contact's "primaryEmail" field to be set to "TRUE"... no matter what I send, the database displays it as "FALSE".)

So I'm wondering if someone could walk me through how the code receives an HTTP XML-ALI request. Where does the XML get processed?

Thanks for your help!

Tom Hallman

1. 1/21/2008 11:33 PM EST

Hi Tom,

If you set the name and value to "primaryEmail" you will get true stored in the database. Here's a sample using the DataRecord class from the tools.jar:
dataRecord.setName("contactEmailAddress");
dataRecord.setAction(org.aspcfs.apps.transfer.DataRecord.INSERT);
dataRecord.addField("contactId", 1);
dataRecord.addField("type", 2);
dataRecord.addField("email", "test@example.com");
dataRecord.addField("enteredBy", 1);
dataRecord.addField("modifiedBy",1);
dataRecord.addField("primaryEmail","primaryEmail");
connection.save(dataRecord);

As you thought, this is because of the way the XML HTTP API works. Incoming requests to the ProcessPacket class are read and the elements are mapped to their base class, in this case, ContactEmailAddress. Each child element is then populated in the object through the setter methods. The unexpected behavior is caused from an overloaded setPrimaryEmail method that accepts a String. This method breaks convention and sets the field to true only if the String is "primaryEmail."

- Lorraine

2. 1/22/2008 9:04 AM EST

Thank you very much, Lorraine! This was very helpful information. I'm certain I wouldn't have figured that one out on my own =)

Along the same lines, are there other areas where there are other potentially confusing XML API strings like that one? For example, it seems that the contactAddress class might have the same issue...?

Thanks again!

3. 1/22/2008 9:19 AM EST

Oh... nevermind. The contactAddress class works just fine with "true" and "false"! But are there other places you know of?

4. 1/22/2008 1:29 PM EST
Default user photo

By Matt Rajkowski

Concursive Corporation
Product Design

airplane-icon-100x100.png

In this case, we'll update the class to allow the more conventional "true" by changing the setter:

public void setPrimaryEmail(String tmp)
this.primaryEmail = ("primaryEmail".equals(tmp) || DatabaseUtils.parseBoolean(tmp));
}

We'll maintain backwards compatibility with the word "primaryEmail." Address and phone only accept true/false.

4 results found