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));
Created attachment 960804 [details] reproducer test
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....
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....
This bug is also in EAP 6.3.2.
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.
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.
Verified on 6.4.0.ER1
Alessio Soldano <asoldano> updated the status of jira JBWS-3857 to Closed