Bug 1168625

Summary: (6.3.z) Wrong content type (text/xml) in outgoing multipart SOAPMessage (expected multipart/related; ...)
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Tomas Hofman <thofman>
Component: Web ServicesAssignee: Tomas Hofman <thofman>
Status: CLOSED CURRENTRELEASE QA Contact: Rostislav Svoboda <rsvoboda>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.3.0CC: cdewolf, jbliznak, oskutka, rsvoboda, thofman
Target Milestone: CR1   
Target Release: EAP 6.3.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1167348 Environment:
Last Closed: 2019-08-19 12:38:33 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1167348    
Bug Blocks: 1151405, 1157479    

Description Tomas Hofman 2014-11-27 12:39:31 UTC
+++ This bug was initially created as a clone of Bug #1167348 +++

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));

--- Additional comment from Martin Swiech on 2014-11-24 09:07:16 EST ---



--- Additional comment from Martin Swiech on 2014-11-24 09:11:37 EST ---

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....

--- Additional comment from Martin Swiech on 2014-11-24 09:14:03 EST ---

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....

--- Additional comment from Martin Swiech on 2014-11-24 09:35:34 EST ---

This bug is also in EAP 6.3.2.

--- Additional comment from Martin Swiech on 2014-11-24 10:33:50 EST ---

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.

--- Additional comment from Tomas Hofman on 2014-11-26 08:42:29 EST ---

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 1 Tomas Hofman 2015-01-06 13:18:45 UTC
Fixed in jbossws-cxf-4.3.3

Comment 3 Jan Blizňák 2015-01-19 14:05:27 UTC
Verified on 6.3.3.CP.CR1

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