Subject: | Issue with XOP escaped quotes with Apache CXF (JAX-WS) |
Date: | Tue, 6 Oct 2015 13:52:29 -0700 |
To: | bug-XML-Compile-SOAP [...] rt.cpan.org, xml-compile [...] lists.scsys.co.uk |
From: | Derek Hausauer <hausauer [...] gmail.com> |
I’m using XML-Compile-SOAP-3.12 to send a payload with attachments to a SOAP server running on Apache CXF 3.0.4.redhat-620133. It looks like CXF doesn’t like the escaped quotes that appear in the type="…; charset=\"utf-8\"" header.
According to the comments at lines 113-114 of http://grepcode.com/file/repo1.maven.org/maven2/org.apache.cxf/cxf-core/3.0.4/org/apache/cxf/helpers/HttpHeaderHelper.java, CXF does not expect content types to have escaped quotes.
I recommend that XML::Compile::XOP stop quoting the charsets by updating SOAPHTTP.pm:94
- $content_type = qq{$mime; charset="$charset”};
+ $content_type = qq{$mime; charset=$charset};
And line :98
- $content_type = qq{$mime; charset="$charset"$sa};
+ $content_type = qq{$mime; charset=$charset$sa};
Here is an example of the SOAP message generated by ->call():
POST http://192.168.56.22:8182/cxf/xcad-ws/XCadService HTTP/1.1
User-Agent: libwww-perl/6.13
Content-Type: multipart/related; boundary=MIME-boundary-8745; type="application/xop+xml"; start="<xml@localhost>"; start-info="text/xml; charset=\"utf-8\""
SOAPAction: ""
X-LWP-Version: 6.13
X-XML-Compile-Cache-Version: 1.04
X-XML-Compile-SOAP-Version: 3.12
X-XML-Compile-Version: 1.50
X-XML-LibXML-Version: 2.0110
--MIME-boundary-8745
Content-Type: application/xop+xml; charset="utf-8"; type="text/xml; charset=\"utf-8\""
Content-ID: <xml@localhost>
Content-Transfer-Encoding: 8bit
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body>
... snipped …
Apache CXF throws the following exception; note that CXF does not properly un-escape double quotes in the charset:
Server Error Caused by: java.io.IOException: Invalid character set \"utf-8\" in request.
at org.apache.cxf.transport.http.AbstractHTTPDestination.setEncoding(AbstractHTTPDestination.java:436)
at org.apache.cxf.transport.http.AbstractHTTPDestination.setupMessage(AbstractHTTPDestination.java:358)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:236)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:171)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:293)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:212)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:268)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503)
at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:69)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:240)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:75)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:982)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1043)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:745)
—
Derek