Lawrence,
 
Thanks for the quick reply.
 
You should see getters/setters for those instead of for ContactPersonType
 
I am indeed seeing getters and setters.  As evidence I included below my authored code (vs. generated code) that compiles and executes.
 
I have been digging around and I believe the problem lies in the generated code.  My current suspicions center on the generated class, PersonAffiliationInfoImp, immediately below:  Look for the initialization of NAME$0 in red.  Note that the 1st parameter to QName is the empty string.  Looking at the other values initialized here, I don't think the empty string is correct.  I think it should be the path to the schema for Name,  http://era.nih.gov/Projectmgmt/SBIR/dev/rarschema.xsd.  What do you think?  This is similiar to a problem I was having trying to automatically build a serializer/deserializer using JAXB.  I guess this must be extra tricky XML or something.
 
    public static class PersonAffiliationInfoImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements gov.nih.era.projectmgmt.sbir.cgap.personinforesponseNamespace.PersonAffiliationInfoDocument.PersonAffiliationInfo
    {        
        public PersonAffiliationInfoImpl(org.apache.xmlbeans.SchemaType sType)
        {
            super(sType);
        }
       
        private static final javax.xml.namespace.QName NAME$0 =
            new javax.xml.namespace.QName("", "Name");
        private static final javax.xml.namespace.QName CONTACTINFORMATION$2 =
            new javax.xml.namespace.QName("", "ContactInformation");
        private static final javax.xml.namespace.QName PREFERREDADDRESSCODE$4 =
            new javax.xml.namespace.QName("http://era.nih.gov/Projectmgmt/SBIR/CGAP/personinforesponse.namespace", "PreferredAddressCode");
        private static final javax.xml.namespace.QName DEGREE$6 =
            new javax.xml.namespace.QName("http://era.nih.gov/Projectmgmt/SBIR/CGAP/personinforesponse.namespace", "Degree");
        private static final javax.xml.namespace.QName POSITIONTITLE$8 =
            new javax.xml.namespace.QName("http://era.nih.gov/Projectmgmt/SBIR/CGAP/personinforesponse.namespace", "PositionTitle");
        private static final javax.xml.namespace.QName PRIORGRANT$10 =
            new javax.xml.namespace.QName("http://era.nih.gov/Projectmgmt/SBIR/CGAP/personinforesponse.namespace", "PriorGrant");
I believe the above generated code should reflect these XML snippets:
 

<xs:element name="PersonAffiliationInfo">
    <xs:complexType>
        <xs:sequence>
            <xs:group ref="rar:ContactPersonType" />
            <xs:element name="PreferredAddressCode" type="pireq:YesNoIndicator" />
            <xs:element name="Degree" type="xs:token" maxOccurs="unbounded" />
            <xs:element name="PositionTitle" type="xs:token" />
            <xs:element name="PriorGrant" type="nih:GrantNumberType" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>
</xs:element>

 

<xs:group name="ContactPersonType">
    <xs:sequence>
        <xs:element name="Name" type="rar:PersonFullNameType" />
        <xs:element name="ContactInformation" type="common:ContactInfoType" />
    </xs:sequence>
</xs:group>
 
rar:PersonFullNameType:
<xs:complexType name="PersonFullNameType">
    <xs:sequence>
        <xs:element name="NamePrefix" type="xs:string" minOccurs="0" />
        <xs:group ref="common:PersonFullNameType" />
        <xs:element name="NameSuffix" type="xs:string" minOccurs="0" />
    </xs:sequence>
</xs:complexType>
 
<xs:group name="PersonFullNameType">
    <xs:sequence>
        <xs:sequence>
            <xs:element name="FirstName" type="common:FirstNameType" />
            <xs:element name="MiddleName" type="common:MiddleNameType" minOccurs="0" />
            <xs:element name="LastName" type="common:LastNameType" />
        </xs:sequence>
    </xs:sequence>
</xs:group>

 
 
Authored code that compiles and executes(with exception-handling details removed):
 
  PersonInfoResponseDocument piresDoc;
  piresDoc = PersonInfoResponseDocument.Factory.parse(cgapElement);
  
  PersonInfoResponseDocument.PersonInfoResponse pires = piresDoc.getPersonInfoResponse();
  PersonAffiliationInfoDocument.PersonAffiliationInfo personInfo = pires.getPersonAffiliationInfo();
  String title = personInfo.getPositionTitle();
  System.out.println("title: " + title);
  PersonFullNameType fullName = personInfo.getName();
  System.out.println("First Name: " + fullName.getFirstName());
  System.out.println("Middle Name: " + fullName.getMiddleName());
  System.out.println("Last Name: " + fullName.getLastName());
The title prints out the correct value.  The problem is that personInfo.getName() returns null.  At the end of this email I have reproduced an excerpt of the SOAP file I'm reading so you can see there is data there.
 
Exerpt from actual data being parsed. 
Here is part of the SOAP file I'm reading in and parsing.  Note that the position title is being found, so in general the parsing is working pretty well:
 
                <pires:PersonInfoResponse xmlns:common="http://era.nih.gov/Projectmgmt/SBIR/CGAP/common.namespace"
                                  xmlns:nih="http://era.nih.gov/Projectmgmt/SBIR/CGAP/nihspecific.namespace"
                                  xmlns:pires="http://era.nih.gov/Projectmgmt/SBIR/CGAP/personinforesponse.namespace"
                                  xmlns:rar="http://era.nih.gov/Projectmgmt/SBIR/CGAP/researchandrelated.namespace">
                    <pires:RequestID>95E1F13F54252CF806C71F2C26E2D120</pires:RequestID>
                    <pires:InstitutionID>098330171</pires:InstitutionID>
                    <pires:CommonsUserID>JUNGEL</pires:CommonsUserID><pires:DUNS>BOGUSDUNS</pires:DUNS>
                    <pires:AffiliationType>PI</pires:AffiliationType>
                    <pires:PersonAffiliationInfo>
                        <rar:Name>
                            <rar:NamePrefix/>
                            <common:FirstName>James</common:FirstName>
                            <common:MiddleName>Undau</common:MiddleName>
                            <common:LastName>Gellat</common:LastName>
                            <rar:NameSuffix/>
                        </rar:Name>
                        <rar:ContactInformation>
                            <common:PostalAddress>
                            <common:Street>DEPT. OF CELL &amp; DEVELOPMENTAL BIOLOGY</common:Street>
                            <common:Street>UNIVERSITY OF MISSISSIPPI MEDICAL SCHOOL</common:Street>
                            <common:Street>4643 MED SCI II</common:Street>
                            <common:Street>1335 CATHERINE STREET</common:Street>
                            <common:City>Oxford</common:City>
                            <common:State>MS</common:State>
                            <common:PostalCode>38677</common:PostalCode>
                            <common:Country/>
                            </common:PostalAddress>
                            <common:PhoneNumber>(692) 615-7509</common:PhoneNumber>
                            <common:FaxNumber>6927631166</common:FaxNumber>
                            <common:Email>[EMAIL PROTECTED]</common:Email>
                        </rar:ContactInformation>
                        <pires:PreferredAddressCode>true</pires:PreferredAddressCode>
                        <pires:Degree>PHD</pires:Degree>
                        <pires:PositionTitle>Professor and Chair</pires:PositionTitle>
 
 
 
----- Original Message -----
Sent: Tuesday, July 19, 2005 10:51 AM
Subject: RE: How do I debug?

Hi Samuel

 

The line you’ve highlighted is just a reference to a model group. Model groups are treated as if the reference to the model group were resolved in place and the names of the elements etc. which the model group defines inserted in place. >From your http://era.nih.gov/Projectmgmt/SBIR/dev/rarschema.xsd  schema it looks as though the model group ContactPersonType resolves to 2 elements: Name and ContactInformation. You should see getters/setters for those instead of for ContactPersonType.

 

Cheers,

 

Lawrence

 


From: Samuel B. Quiring [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 19, 2005 10:18 AM
To: [email protected]
Subject: How do I debug?

 

Greetings,

 

I have successfully compiled a schema.  I have an Eclipse project/program that is utilizing the generated classes.  The program reads in a SOAP file, breaks it apart, hands a SOAPElement to the parse() member, which returns a Document.  The code retrieves a simple value and prints it.  The value is correct!

 

However, the next value it retrieves is not so simple.  And that does not work, I get a null pointer exception.  How do I debug this?

 

The schema in question is http://era.nih.gov/Projectmgmt/SBIR/dev/personinforesponse.xsd.  Here's the excerpt that includes what's working and what's not:

 

<xs:element name="PersonAffiliationInfo">
    <xs:complexType>
        <xs:sequence>
            <xs:group ref="rar:ContactPersonType" />
            <xs:element name="PreferredAddressCode" type="pireq:YesNoIndicator" />
            <xs:element name="Degree" type="xs:token" maxOccurs="unbounded" />
            <xs:element name="PositionTitle" type="xs:token" />
            <xs:element name="PriorGrant" type="nih:GrantNumberType" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>
</xs:element>

 

I am able to successfully retrieve the PositionTitle.  I am not able to retrieve the ContactPersonType, which comes from the schemas:

 

I have my fingers crossed that this works, but I'm starting to get nervous.

 

-Sam

Reply via email to