Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1087893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:59:53+00:00 2026-05-16T22:59:53+00:00

We are connecting to a third party using Jersey. We then want to extract

  • 0

We are connecting to a third party using Jersey. We then want to extract the returned xml into our class. This is actually working fine except for one node in the xml that is in a subnode.
Here is the xml returned:

<response>  
...  
<langISO>en</langISO>  
<acquirerAmount>1000</acquirerAmount>  
<acquirerCurrency>GBP</acquirerCurrency>
<subXml>  
<authCode>122958</authCode>  
</subXml>  
</response>

Note that the authCode node is in a subnode (called subXml).

OurResponse myriadResponse = response.getEntity(OurResponse.class);

Here is our class, but it is not parsing out the authCode

package com.xxx;  

import javax.ws.rs.Consumes;  
import javax.ws.rs.Path;  
import javax.xml.bind.annotation.XmlElement;  
import javax.xml.bind.annotation.XmlRootElement;  

@XmlRootElement  
@Consumes("application/xml")  
public class OurResponse {  
    private String authCode;  

    @XmlElement(name = "subXml/authCode")  
    public String getAuthCode() {  
        return authCode;  
    }  

    @XmlElement(name = "subXml/authCode")  
    public void setAuthCode(String authCode) {  
        this.authCode = authCode;  
    }  
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:59:53+00:00Added an answer on May 16, 2026 at 10:59 pm

    You have a couple different options:

    Option 1 – MOXy JAXB & @XmlPath

    You could use the MOXy JAXB implementation and the @XmlPath extension to achieve the desired result:

    import javax.xml.bind.annotation.XmlRootElement;
    import org.eclipse.persistence.oxm.annotations.XmlPath;
    
    @XmlRootElement(name="response")
    public class OurResponse {
        private String authCode;
    
        @XmlPath("subXml/authCode/text()")
        public String getAuthCode() {
            return authCode;
        }
    
        public void setAuthCode(String authCode) {
            this.authCode = authCode;
        }
    
    }
    

    For more information see:

    • http://bdoughan.blogspot.com/2010/09/xpath-based-mapping-geocode-example.html

    Option 2 – Any JAXB Impl and @XmlJavaTypeAdapter

    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlRootElement;
    import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
    
    @XmlRootElement(name="response")
    public class OurResponse {
        private String authCode;
    
        @XmlJavaTypeAdapter(AuthCodeAdapter.class)
        @XmlElement(name="subXml")
        public String getAuthCode() {
            return authCode;
        }
    
        public void setAuthCode(String authCode) {
            this.authCode = authCode;
        }
    
    }
    

    with

    import javax.xml.bind.annotation.adapters.XmlAdapter;
    
    public class AuthCodeAdapter extends XmlAdapter<SubXml, String> {
    
        @Override
        public String unmarshal(SubXml v) throws Exception {
            return v.getAuthCode();
        }
    
        @Override
        public SubXml marshal(String v) throws Exception {
            SubXml subXml = new SubXml();
            subXml.setAuthCode(v);
            return subXml;
        }
    
    }
    

    and

    public class SubXml {
    
        private String authCode;
    
        public String getAuthCode() {
            return authCode;
        }
    
        public void setAuthCode(String authCode) {
            this.authCode = authCode;
        }
    
    }
    

    For more information see:

    • http://bdoughan.blogspot.com/2010/07/xmladapter-jaxbs-secret-weapon.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm connecting to a third party service using SOAP. This service will return SoapFaults
In an old project we are using a third party assembly with a class
We have a third party application that accept calls using an XML RPC mechanism
I am connecting to a third-party end point via WCF and I have one
I am trying to integrate some third party tracking code into one of my
I'm using an existing database made by a third party with sqlalchemy. However, I'm
i am reading an RSS feed from a third party and then import data
I'm connecting to a web service hosted by a third-party provider. I've added a
I am currently using a third party component to handle telnet connections in .NET.
Our app is hosted at Heroku, so no local file storage. A third party

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.