I know it is old bug 744 and has been fixed, but I doubt it has been fixed
completely.
On old jaxb-api 2.1 it happened to me for every field.
After I have read this topic and updated to jaxb-api 2.2.8 and jaxb-impl
2.2.5, the problem still occurs, but only for the first element affected.
Input XML:
<upsert xmlns="urn:enterprise.soap.sforce.com"
xmlns:ns2="urn:sobject.enterprise.soap.sforce.com">
<externalIDFieldName>dummyExternalIdName</externalIDFieldName>
<sObjects xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:type="ns2:Account_Contact_Role__c">
<ns2:Id xsi:nil="true"/>
<ns2:Account_Name__r>
<ns2:Id>ABCDEFGHIJ12345678</ns2:Id>
</ns2:Account_Name__r>
<ns2:CreatedBy>
<ns2:Id xsi:nil="true"/>
<ns2:Legacy_User_Id__c>dummyLegacyUserIdC</ns2:Legacy_User_Id__c>
</ns2:CreatedBy>
<ns2:LastModifiedBy>
<ns2:Id xsi:nil="true"/>
<ns2:Legacy_User_Id__c>dummyLegacyUserIdC</ns2:Legacy_User_Id__c>
</ns2:LastModifiedBy>
</sObjects>
</upsert>
After unmarshalling and marshallilng again:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<upsert xmlns="urn:enterprise.soap.sforce.com"
xmlns:ns2="urn:sobject.enterprise.soap.sforce.com">
<externalIDFieldName>dummyExternalIdName</externalIDFieldName>
<sObjects xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:type="ns2:Account_Contact_Role__c">
<ns2:Id xsi:nil="true"/>
<ns2:Account_Name__r xsi:nil="true">
<ns2:Id>ABCDEFGHIJ12345678</ns2:Id>
</ns2:Account_Name__r>
<ns2:CreatedBy>
<ns2:Id xsi:nil="true"/>
<ns2:Legacy_User_Id__c>dummyLegacyUserIdC</ns2:Legacy_User_Id__c>
</ns2:CreatedBy>
<ns2:LastModifiedBy>
<ns2:Id xsi:nil="true"/>
<ns2:Legacy_User_Id__c>dummyLegacyUserIdC</ns2:Legacy_User_Id__c>
</ns2:LastModifiedBy>
</sObjects>
</upsert>
If I remove element "Account_Name__r", unwanted "nil" appears for
"CreatedBy".
Input XML v2:
<upsert xmlns="urn:enterprise.soap.sforce.com"
xmlns:ns2="urn:sobject.enterprise.soap.sforce.com">
<externalIDFieldName>OADM_AccountContactLink_ID__c</externalIDFieldName>
<sObjects xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:type="ns2:Account_Contact_Role__c">
<ns2:Id xsi:nil="true"/>
<ns2:CreatedBy>
<ns2:Id xsi:nil="true"/>
<ns2:Legacy_User_Id__c>dummyLegacyUserIdC</ns2:Legacy_User_Id__c>
</ns2:CreatedBy>
<ns2:LastModifiedBy>
<ns2:Id xsi:nil="true"/>
<ns2:Legacy_User_Id__c>dummyLegacyUserIdC</ns2:Legacy_User_Id__c>
</ns2:LastModifiedBy>
</sObjects>
</upsert>
After unmarshalling and marshalling again:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<upsert xmlns="urn:enterprise.soap.sforce.com"
xmlns:ns2="urn:sobject.enterprise.soap.sforce.com">
<externalIDFieldName>OADM_AccountContactLink_ID__c</externalIDFieldName>
<sObjects xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:type="ns2:Account_Contact_Role__c">
<ns2:Id xsi:nil="true"/>
<ns2:CreatedBy xsi:nil="true">
<ns2:Id xsi:nil="true"/>
<ns2:Legacy_User_Id__c>dummyLegacyUserIdC</ns2:Legacy_User_Id__c>
</ns2:CreatedBy>
<ns2:LastModifiedBy>
<ns2:Id xsi:nil="true"/>
<ns2:Legacy_User_Id__c>dummyLegacyUserIdC</ns2:Legacy_User_Id__c>
</ns2:LastModifiedBy>
</sObjects>
</upsert>
Problem is as usual in Unmarshaller rather than in Marshaller, because
"isNil()" function returns "true" for the field on unmarshalled object.
--
View this message in context: http://old.nabble.com/xsi%3Anil-problem-on-repeated-marshalling-unmarshalling-operations-tp27928223p33682509.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.