开发者

Unmarshalled Objects null with XMLBeans on Glassfish 2.1 with JDK 1.6

开发者 https://www.devze.com 2023-03-12 14:19 出处:网络
I am using XJC Maven plugin with XMLBeans binding to generate code from WSDL + XSD. The code is deployed on Glassfish 2.1.1 running on JDK 1.6

I am using XJC Maven plugin with XMLBeans binding to generate code from WSDL + XSD. The code is deployed on Glassfish 2.1.1 running on JDK 1.6

I am trying to parse a XML String using the generated objects. The object parsing is fine without errors but when I call the getXXX() methods on the object, they are all null.

I have been scouting and hunting for some hints on how to fix it but without avail.

Any help will be appreciated.

The XML that is being parsed:


<ccs:printAdReturn xmlns:ccs="http://www.huntingtonmast.com/ccssAdInfo">
    <ccs:adPrice>244.0</ccs:adPrice>
    <ccs:sap-order-request>
        <sap-order-request xmlns="http://huntmast/pas">
            <business-partner xmlns="">2010011755</business-partner>
            <source-system xmlns="">05</source-system>
            <authorizer-name xmlns="">Unknown user</authorizer-name>
            <item-ad xmlns="">
                <booking-unit>JOBSFRZ</booking-unit>
                <content-component>905</content-component>
                <promo-code />
                <price-group>JB</price-group>
                <non-package>
                    <ad-schedule>
                        <publication-date>2009-09-26-04:00</publication-date>
                        <basic-booking-unit>JOBSFRZ</basic-booking-unit>
                    </ad-schedule>
                    <ad-schedule>
                        <publication-date>2009-09-27-04:00</publication-date>
                        <basic-booking-unit>JOBSFRZ</basic-booking-unit>
                    </ad-schedule>
                </non-package>
                <ad-content>
                    <template-id>CCSS_JOBS3_B</template-id>
                    <proof-required>false</proof-required>
                    <panel-field>
                        <field-name>JOB-TITLE</field-name>
                        <field-value>
                            <![CDATA[TECHS NEEDED!]]>
                        </field-value>
                    </panel-field>
                    <panel-field>
                        <field-name>KEYWORD</field-name>
                        <field-value>
                            <![CDATA[HVAC]]>
                        </field-value>
                    </panel-field>
                    <panel-field>
                        <field-name>CCSS-SIG2</field-name>
                        <field-value />
                    </panel-field>
                    <panel-field>
                        <field-name>J-FONT1</field-name>
                        <field-value>
                            <![CDATA[08]]>
                        </field-value>
                    </panel-field>
                    <panel-field>
                        <field-name>CCSS-SIG1</field-name>
                        <field-value />
                    </panel-field>
                    <panel-field>
                        <field-name>CCSS-ADTEXT1</field-name>
                        <field-value>
                            <![CDATA[Hello World, How are you ?]]>
                        </field-value>
                    </panel-field>
                </ad-content>
            </item-ad>
        </sap-order-request>
    </ccs:sap-order-request>
    <ccs:numberLines>8</ccs:numberLines>
</ccs:printAdReturn>

The Java Code for Parsing

            oPrintResponse.setStatus(SUCCESS_CODE);
            oPrintResponse.setStatusMessage(STATUS_SUCCESS);

 开发者_运维百科           XmlOptions validateOptions = new XmlOptions();
            validateOptions.setCharacterEncoding("utf-8");
            validateOptions.setValidateOnSet();
            ArrayList errorList = new ArrayList(); 
            validateOptions.setErrorListener(errorList); 

            PrintAdReturnDocument oAdReturnDocument = PrintAdReturnDocument.Factory.parse(pXml,validateOptions);

            oPrintResponse.setStatus(SUCCESS_CODE);
            oPrintResponse.setStatusMessage(STATUS_SUCCESS);

            XmlOptions validateOptions = new XmlOptions();
            validateOptions.setCharacterEncoding(cd.getSysAdmin(CCSS_XML_CHARACTER_ENCODING));
            validateOptions.setValidateOnSet();
            ArrayList errorList = new ArrayList(); 
            validateOptions.setErrorListener(errorList); 

            PrintAdReturnDocument oAdReturnDocument = PrintAdReturnDocument.Factory.parse(pXml,validateOptions);

                    if(oPrintAdReturn == null)
            {
                log.warn("getPrintAdReturn - oPrintAdReturn is null");
                return null;
            }
            CCSSPrint oCCSSPrint = new CCSSPrint();
            oCCSSPrint.setPrice(oPrintAdReturn.getAdPrice());

The oPrintAdReturn.getAdPrice() always returns 0.0, and any other getters return null.

0

精彩评论

暂无评论...
验证码 换一张
取 消