?
Solved

Jax ws client failing because of UTF-8 BOM - woodstox-core-asl-4.1.2.jar:4.1.2

Posted on 2015-02-14
11
Medium Priority
?
538 Views
Last Modified: 2015-05-16
I have web service client written in JAX-WS.
I'm receiving a response with a UTF-8 BOM.

[0xef][0xbb][0xbf]<?xml ....

So When the same jax-ws client code is deployed to Tomcat server we did have any problem. May be because of tomcat using a different parser.

But we have to deploy our code only in JBoss server - where the application parser is being picked up - woodstox-core-asl-4.1.2.jar:4.1.2. (I will have to use a specific parser only for this jax-ws client if changing the parser is a solution).

Stack trace:

12:27:24,867 FINE  [org.apache.cxf.phase.PhaseInterceptorChain] (http--0_0_0_0_0_0_0_0-8080-2) Invoking handleFault on interceptor org.apache.cxf.ws.policy.PolicyInInterceptor@389dd05c
12:27:24,868 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (http--0_0_0_0_0_0_0_0-8080-2) Interceptor for {urn:cache-claim:2003-09-30}WebService#{urn:cache-claim:2003-09-30}MOClaimFastEnqLimits has thrown exception, unwinding now: java.lang.RuntimeException: Couldn't parse stream.
                at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1178)
                at org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(StaxInInterceptor.java:104)
                at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
                at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:795)


Caused by: com.ctc.wstx.exc.WstxIOException: Unexpected first character (char code 0xEF), not valid in xml document: could be mangled UTF-8 BOM marker. Make sure that the Reader uses correct encoding or pass an InputStream instead
                at com.ctc.wstx.io.ReaderBootstrapper.bootstrapInput(ReaderBootstrapper.java:174) [woodstox-core-asl-4.1.2.jar:4.1.2]

Please kindly help me with a solution, I'm desparete to get this working ?
0
Comment
Question by:Faiz03
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
11 Comments
 
LVL 62

Expert Comment

by:gheist
ID: 40610711
probably you have 2 conflicting versions of com.ctc.wstx arount your application/server/jdk.
0
 

Author Comment

by:Faiz03
ID: 40610730
No I Have only woodstox-core-asl-4.1.2.jar. And this stax is part of the application in class path.I don't want to use this stax as it is failing(i.e. It cannot handle UTF-8 BOM) - ReaderBootstrapper.class If you look at the source of this class you find this

if (c == 0xEF) {
 throw new WstxIOException("Unexpected first character (char code 0xEF), not valid in xml document: could be mangled UTF-8 BOM marker. Make sure that the Reader uses correct encoding or pass an InputStream instead");  }

Open in new window


So i would like to use different stax implementation for my Jax ws client or any other solution.
0
 
LVL 62

Expert Comment

by:gheist
ID: 40610745
Well you have some other UTF problem - you have first part of UTF only. There is some problem with UTF generator chopping strings by bytes not by characters.
0
Threat Trends for MSPs to Watch

See the findings.
Despite its humble beginnings, phishing has come a long way since those first crudely constructed emails. Today, phishing sites can appear and disappear in the length of a coffee break, and it takes more than a little know-how to keep your clients secure.

 

Author Comment

by:Faiz03
ID: 40610761
I have verified the response from the third party - Web Service provider (.net) and they are valid response, but they also send the BOM - Byte order mark. Which i have already mentioned,

i have written a Web Serivce client in JAX-WS Which use the stax implementaion in class path - woodstox. And the wood stox parser dosent handle BOM. While the response is still correctly parsed by different stax implemetation etc. I'm sure if i change the stax implemtation this will work but i would like to change this only for Jax -ws client and not for the whole application or any solution that will help solve this problem.
0
 
LVL 62

Expert Comment

by:gheist
ID: 40610769
why dont you fill a bug report with them?
0
 

Accepted Solution

by:
Faiz03 earned 0 total points
ID: 40610779
I have raised this with third party asking for not sending the byte order mark - BOM but i'm if they are going to resolve this by not sending the BOM. If they do so Happy days. I don't have to change anything.

If i have to file a bug report with woodstox i don't think it is going to get me anything.

I just have time for  a week. And I'm pretty sure that there are alternate ways around this Stax implementation issue but i dont know what they are.
0
 
LVL 62

Expert Comment

by:gheist
ID: 40610884
You can open bug report. BOM is legal beginning of XML.
I'd say most XML toolkits will fail with BOM in network stream.
0
 

Author Comment

by:Faiz03
ID: 40610922
Yes i did fingers crossed. I'm still working/searching for a workaround for this.
0
 
LVL 62

Expert Comment

by:gheist
ID: 40611042
Stop microsoft from adding useless BOM character?
0
 

Author Closing Comment

by:Faiz03
ID: 40780618
Because this is what i have ended up with.
0

Featured Post

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When coding a Webservice to provide data, the normal way is to create a method that returns a Dataset object.   But a Dataset cannot be used easily from another platform, such as PHP,  FLAS (FLEX) , etc. Solution : Return a XML Document instea…
New Relic recently released its Synthetics product that allows for the creation of performance monitors that periodically test a site's performance. If you wish to test an interactive workflow New Relic employs Selenium WebDriverJS to run those test…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month11 days, 22 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question