Bug 1167348 - (6.4.0) Wrong content type (text/xml) in outgoing multipart SOAPMessage (expected multipart/related; ...)
Summary: (6.4.0) Wrong content type (text/xml) in outgoing multipart SOAPMessage (expe...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Web Services
Version: 6.3.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ER1
: EAP 6.4.0
Assignee: Alessio Soldano
QA Contact: Rostislav Svoboda
URL:
Whiteboard:
Depends On:
Blocks: 1168625 1168630
TreeView+ depends on / blocked
 
Reported: 2014-11-24 14:01 UTC by Martin Swiech
Modified: 2019-08-02 07:27 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1168625 (view as bug list)
Environment:
Last Closed: 2019-08-02 07:27:13 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
reproducer test (11.27 KB, application/zip)
2014-11-24 14:07 UTC, Martin Swiech
no flags Details
jbossws-cxf-4.3.x patch (757 bytes, patch)
2014-11-26 13:42 UTC, Tomas Hofman
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker JBWS-3857 0 Major Closed Wrong content type (text/xml) in outgoing multipart SOAPMessage (expected multipart/related; ...) 2016-11-03 15:48:27 UTC

Description Martin Swiech 2014-11-24 14:01:43 UTC
Description of problem:
There is wrong content type (text/xml) in multipart SOAPMessage when sending it using javax.xml.soap API. So target system is unable to parse it.

How reproducible:
always

Steps to Reproduce:
1. Create test app which will send multipart SOAPMessage (using javax.xml.soap API).
2. Catch http communication and watch message content type.

Actual results:
Content type is text/xml.

Expected results:
Content type should be multipart/related; ...


Additional info:
It's also wrong in EAP 6.2.
EAP 6.1 is OK.


Code I used to send multipart SOAPMessage:

	final MessageFactory msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
	final SOAPMessage msg = msgFactory.createMessage();
	final SOAPBodyElement bodyElement = msg.getSOAPBody().addBodyElement(
			new QName("urn:ledegen:soap-attachment:1.0", "echoImage"));
	bodyElement.addTextNode("cid:" + IN_IMG_NAME);

	final AttachmentPart ap = msg.createAttachmentPart();
	ap.setDataHandler(getResource(IN_IMG_RESOURCE));
	ap.setContentId(IN_IMG_NAME);
	msg.addAttachmentPart(ap);

	final SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance();
	final SOAPConnection connection = conFactory.createConnection();
	final SOAPMessage response = connection.call(msg, new URL(TEST_SERVLET_URL));

Comment 1 Martin Swiech 2014-11-24 14:07:16 UTC
Created attachment 960804 [details]
reproducer test

Comment 2 Martin Swiech 2014-11-24 14:11:37 UTC
Catched communication (EAP 6.3 - wrong):

POST /reproducer-eap-wrong-multipart/testServlet HTTP/1.1
Content-Type: text/xml
Accept: application/soap+xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
User-Agent: Apache CXF 2.7.11.redhat-3
Cache-Control: no-cache
Pragma: no-cache
Host: localhost:8080
Connection: keep-alive
Content-Length: 483

------=_Part_1_516422819.1416584343265
Content-Type: application/soap+xml; charset=utf-8

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Header/><env:Body><echoImage xmlns="urn:ledegen:soap-attachment:1.0">cid:test.png</echoImage></env:Body></env:Envelope>
------=_Part_1_516422819.1416584343265
Content-Type: image/png
Content-ID: test.png

.....binary content....

Comment 3 Martin Swiech 2014-11-24 14:14:03 UTC
Catched communication (EAP 6.1 - OK):

POST /reproducer-eap-wrong-multipart/testServlet HTTP/1.1
Accept: application/soap+xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Content-Type: multipart/related; type="application/soap+xml"; boundary="----=_Part_0_1586848051.1416584243093"
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Java/1.7.0_67
Host: localhost:8080
Connection: keep-alive
Content-Length: 486

------=_Part_0_1586848051.1416584243093
Content-Type: application/soap+xml; charset=utf-8

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Header/><env:Body><echoImage xmlns="urn:ledegen:soap-attachment:1.0">cid:test.png</echoImage></env:Body></env:Envelope>
------=_Part_0_1586848051.1416584243093
Content-Type: image/png
Content-ID: test.png

.....binary content....

Comment 4 Martin Swiech 2014-11-24 14:35:34 UTC
This bug is also in EAP 6.3.2.

Comment 5 Martin Swiech 2014-11-24 15:33:50 UTC
Probably cause is that EAP 6.2 and 6.3 are using a module org.jboss.ws.jaxws-client. Maybe the bug in this module. 

There is the file modules/system/layers/base/org/jboss/ws/saaj-impl/main/module.xml with this dependency:
<module name="org.jboss.ws.jaxws-client" services="import"/> <!-- to pull the jbossws-cxf SOAPConnection impl -->

The test is passing after I have removed this dependency.

There isn't this dependency in the same file in EAP 6.1.

Comment 6 Tomas Hofman 2014-11-26 13:42:29 UTC
Created attachment 961670 [details]
jbossws-cxf-4.3.x patch

JBoss 6.3 is using org.jboss.wsf.stack.cxf.saaj.SOAPConnectionImpl implementation (from jbossws-cxf-client) of javax.xml.soap.SOAPConnection, while JBoss 6.1 is using com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.

What HttpSOAPConnection does and SOAPConnectionImpl does not, is calling following (HttpSOAPConnection:210):

if (message.saveRequired())
    message.saveChanges();

before reading the message headers. Correct content type is set during saveChanges() call.

I'm attaching a patch that introduces the same behaviour in the jbossws-cxf-client.

Comment 7 Jan Blizňák 2015-01-14 10:51:08 UTC
Verified on 6.4.0.ER1

Comment 8 JBoss JIRA Server 2015-04-25 20:26:56 UTC
Alessio Soldano <asoldano> updated the status of jira JBWS-3857 to Closed


Note You need to log in before you can comment on or make changes to this bug.