XMLStreamException occurs when invoking a .NET ASMX (Soap) web service using JAX-WS
I am trying to call a .NET web service using开发者_如何学Python NetBeans. One of my web method returns a complex type and Java is throwing an exception while processing the response. The exception message is: "Content is not allowed in prolog".
Using Fiddler, I was able to see the exact response that the web service gives, and I believe that the problem lies in the UTF-8 BOM sequence (EF BB BF) at the beginning of the content.
I found a similar question on Stack Overflow regarding the BOM sequence and invoking Java Web Services from .NET, but nothing on the reverse scenario.
1) Is this something that JAX-WS can handle?
2) If not, is it possible to control and disable the outputting of the UTF-8 BOM? I tried setting the Response ContentEncoding to omit the UTF-8 BOM by adding the following line in my Global.asax at the start of every request: Response.ContentEncoding = new System.Text.UTF8Encoding(false);
I know that this answer comes a bit late, but as I faced the same problem and no clear answer came up, here is my solution:
Instead of using the standard implementation by Oracle, which is used by default, use Apache CXF. You only need to add the required libraries to the classpath. The classloader then loads Apache CXF instead of the Oracle one and your are done. I didn't have to change any line of code.
If you are using Maven, this artifact adds the necessary (client) libs of Apache CXF:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
精彩评论