We are trying to unmarshall XML to an Object. The XML comes in as a SOAP Response as follows:
The Class definition is as follows:
This works ok up until Java 1.8.0_40, but beyond that the unmarshalling doesn't seem to work. All the values in the LegacyResponse object are null. Any help would be appreciated. The logs print the following:
YashYash
30211 gold badge77 silver badges2020 bronze badges
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Browse other questions tagged javaxmlspringjaxbmarshalling or ask your own question.
Do you know of a JAXB setting to prevent standalone='yes' from being generated in the resulting XML?
user177800
Johan PelgrimJohan Pelgrim
4,26866 gold badges3333 silver badges4444 bronze badges
10 Answers
can be used to have no
However i wouldnt consider this best practice.
mmdemirbas
7,23422 gold badges3434 silver badges5050 bronze badges
SamSam
5,24944 gold badges3636 silver badges5151 bronze badges
mmdemirbas
7,23422 gold badges3434 silver badges5050 bronze badges
so_mvso_mv
Marshaller Java Avoid Encoding Windows 10
3,21944 gold badges2525 silver badges3939 bronze badges
You can either use
or
to disable the default XML declaration, and then add your custom XML declaration,
by
to the generated xml, thus avoiding the standalone='yes' property.
Gray
98.3k1515 gold badges237237 silver badges307307 bronze badges
WarFoxWarFox
4,06833 gold badges2323 silver badges3131 bronze badges
just if someone else is still struggeling with this problem, you may consider using
to remove all of the XML declaration and just write your own
String at the beginning of your output stream / method
benezbenez
If you make document dependent on
DOCTYPE (e.g. use named entities) then it will stop being standalone, thus standalone='yes' won't be allowed in XML declaration.
However standalone XML can be used anywhere, while non-standalone is problematic for XML parsers that don't load externals.
I don't see how this declaration could be a problem, other than for interoperability with software that doesn't support XML, but some horrible regex soup.
KornelKornel
78k2929 gold badges178178 silver badges242242 bronze badges
This worked for me with JDK1.7. standalone='no' can be removed to get only rest of the xml part
Debasis DasDebasis Das
If you are using only the default javax.xml package, you could set the JAXB_FRAGMENT option of the marshaller to 'true' (this omits the default xml processing instruction) and use the writeProcessingInstruction method of the XMLStreamWriter to insert your own:
eddoeddo
You can use: marshaller.setProperty('jaxb.fragment', Boolean.TRUE);
It works for me on Java 8
William Funchal PereiraWilliam Funchal Pereira
In case you are getting property exception, add the following configuration:
JoSSte
1,08822 gold badges1818 silver badges3333 bronze badges
Alisha SetiaAlisha Setia
I don't have a high enough 'reputation' to have the 'privilege' to comment. ;-)
@Debasis, note that the property you've specified:
should be:
If I use the 'internal' property as you did, I get a javax.xml.bind.PropertyException
AriAri
Not the answer you're looking for? Browse other questions tagged xmlxsdjaxbxml-binding or ask your own question.
This is the code what I'm using.and I'm getting output as following.
Here I want to remove standalone='yes' and want output as
I checked link JAXB - Remove 'standalone='yes' from generated XMLbut answers here are removing complete
part
I don't want that..
Please help me.
Communityâ¦
vg123vg123
7022 gold badges22 silver badges1111 bronze badges
Marshaller Java Avoid Encoding Definition1 Answer
There are a couple of issues that need to be addressed in your question: Hp laptop monthly payment no credit check.
ISSUE #1 - Encoding
The
'jaxb.encoding' property when sets directly affects the encoding when the output is an OutputStream . If you are using an output that (such as Writer ) that is reponsible for handling its own encoding then you need to make sure that you handle that as part of the Writer .
For More Information
ISSUE #2 -
standalone='yes'
You can create a StAX (JSR-173)
XMLStreamWriter to wrap your StringWriter for your XML output and marshal to that.
Output
ALTERNATE APPROACH
Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group.
There are other JAXB (JSR-222) providers such as MOXy that do not output bdoughanbdoughan
standalone='yes' as part of the XML Output that you can use.
133k1515 gold badges238238 silver badges340340 bronze badges
Got a question that you canât ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Not the answer you're looking for? Browse other questions tagged javaxmlformattingjaxbjaxb2 or ask your own question.Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign up
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking âSign up for GitHubâ, you agree to our terms of service and privacy statement. Weâll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Commentscommented Aug 26, 2014
commented Aug 26, 2014
commented Sep 16, 2014
commented Sep 16, 2014
commented Sep 16, 2014
commented Oct 14, 2014
referenced this issue Jun 2, 2015Openflag for controlling HTMLEscape when Marshalling #141referenced this issue Dec 30, 2015ClosedSlack messages can't send urls as markup #207referenced this issue Mar 9, 2016MergedIgnore transfer-encoding and content-length headers #9locked and limited conversation to collaborators Jun 25, 2016
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.
I configured my web service client to use
Moxy to marshall / unmarshall the service payloads. My service client does not have a control on the Jaxb configuration .That said, I have configured my client to use Moxy by adding a jaxb.properties file with the entry as follows::
I have a requirement to change the encoding of the payload so that its::
Is this possible by adding an entry to DamoDamo
jaxb.properties (as it would be a lot of work for me to inject this value via code, due to the various frameworks we have in place).
46833 gold badges66 silver badges1919 bronze badges
1 Answer
Encoding for MOXy and all JAXB implementations is controlled by the bdoughanbdoughan
JAXB_ENCODING property set on the Marshaller .
133k1515 gold badges238238 silver badges340340 bronze badges
Got a question that you canât ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Not the answer you're looking for? Browse other questions tagged encodingpropertiesjaxb or ask your own question.Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |