There is often confusion in webservices with regards to the long id values that are passed in and returned. These are not the same thing as the content id, and what you get returned can often be a large negative number. In fact these ids are an internal representation of the PSGuid object in the system that is not itself exposed through WebServices.
Often when creating an item you can just pass back the id you got from the system for changes. Problems occur when the item is in a quick edit or other post publish state. The long id value contains information on both the content id and revision id. If an operation like save increases the revision of the item, an ContractViolation error will be thrown if you send back the old id, with the old non editable revision.
If a Guid has a revision id of -1, it is thought of as revisionless and WebServices will always handle the request with the current or edit revision of the item which is often what is required rather than separately trying to request this.
The long value is basically has three parts, type, id and revision stored in a long with a bitmask. I have an example class that can be used to convert a long returned from web services so the values can be manipulated. Using this you can log the proper content id and revision returned by WebServices and also reset the revision id to -1 if you want to modify the current revision of the item.
public class Guid
{
private long guid;
public Guid()
{
}
public Guid(int id)
{
setId(id);
setRevision(-1);
setType(101);
}
public Guid(long guid)
{
this.guid = guid.longValue();
}
public long getGuid()
{
return guid;
}
public void setGuid(long guid)
{
this.guid = guid;
}
public int getId()
{
return Guid.getId(guid);
}
public void setId(int id)
{
long mask = 0xffffffff00000000L;
guid = mask & guid | java.lang.Long.valueOf(id).longValue();
}
public int getRevision()
{
return getRevision(guid);
}
public void setRevision(int revision)
{
long mask = 0xffffffffffL;
guid = mask & guid | java.lang.Long.valueOf(revision).longValue() << 40;
}
public int getType()
{
return Guid.getType(guid);
}
public void setType(int type)
{
long mask = 0xffffff00ffffffffL;
guid = mask & guid | java.lang.Long.valueOf(type).longValue() << 32;
}
public String toString()
{
return getType()+"-"+getId()+"-"+getRevision();
}
public static int getId(long id)
{
return (int)(id & 0xffffffffL);
}
public static int getRevision(long id)
{
return (int)(id >> 40);
}
public static int getType(long id)
{
return (int)(id >> 32) & 0xff;
}
}