Axis2
  1. Axis2
  2. AXIS2-5067

content-type header is not generated with SAAJ API

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6.0
    • Fix Version/s: 1.5.6, 1.6.1, 1.7.0
    • Component/s: saaj
    • Labels:
      None

      Description

      In the scenario below :
      SOAPMessage msg = MessageFactory.newInstance().createMessage();
      SOAPPart sp = msg.getSOAPPart();
      SOAPEnvelope envelope = sp.getEnvelope();
      SOAPBody bdy = envelope.getBody();
      SOAPBodyElement sbe = bdy.addBodyElement(envelope.createName("Body1", "ns1", "http://www.helloworld.org"));
      sbe.addChildElement(envelope.createName("c1", "ns1", "http://www.helloworld.org")).addTextNode("HelloWorld");

      URL url = new File("D:\\opensource\\axis2\\axis2\\axis2-1.5\\modules\\saaj
      pom.xml").toURI().toURL();
      AttachmentPart attachmentPart = msg.createAttachmentPart(new DataHandler(url));
      attachmentPart.setContentType("text/xml");
      msg.addAttachmentPart(attachmentPart);
      msg.saveChanges();

      If we use SOAPMessage.writeTo method to write to the message to an servlet outputstream, those boundary, content-id values are generated on the fly. And for the client applications, there is no way to get the corresponding content-type header.

      1. AXIS2-5067.patch
        13 kB
        Ivan
      2. AXIS2-5067-01.patch
        17 kB
        Ivan

        Activity

        Hide
        Ivan added a comment -

        Attach a patch for it, please help to review, thanks.

        Show
        Ivan added a comment - Attach a patch for it, please help to review, thanks.
        Hide
        Ivan added a comment -

        A bit explanation for the patch
        a. From the JavaDoc of saveChanges method in the SOAPMessage class, the codes in the patch will create the content-type header information for the SOAPMessage
        --->
        Updates this SOAPMessage object with all the changes that have been made to it. This method is called automatically when writeTo(OutputStream) is called. However, if changes are made to a message that was received or to one that has already been sent, the method saveChanges needs to be called explicitly in order to save the changes. The method saveChanges also generates any changes that can be read back (for example, a MessageId in profiles that support a message id). All MIME headers in a message that is created for sending purposes are guaranteed to have valid values only after saveChanges has been called.
        In addition, this method marks the point at which the data from all constituent AttachmentPart objects are pulled into the message.
        <---
        b. In the writeTo method, the codes in the patch will try to take the information from contentType and fill them into the OutputFormat. With these changes, if a message with content-type is received, the same contents will be gotten if call writeTo method. Also, if we create a message from scratch, multiple call of writeTo method will get the same message contents.
        Thanks.

        Show
        Ivan added a comment - A bit explanation for the patch a. From the JavaDoc of saveChanges method in the SOAPMessage class, the codes in the patch will create the content-type header information for the SOAPMessage ---> Updates this SOAPMessage object with all the changes that have been made to it. This method is called automatically when writeTo(OutputStream) is called. However, if changes are made to a message that was received or to one that has already been sent, the method saveChanges needs to be called explicitly in order to save the changes. The method saveChanges also generates any changes that can be read back (for example, a MessageId in profiles that support a message id). All MIME headers in a message that is created for sending purposes are guaranteed to have valid values only after saveChanges has been called. In addition, this method marks the point at which the data from all constituent AttachmentPart objects are pulled into the message. <--- b. In the writeTo method, the codes in the patch will try to take the information from contentType and fill them into the OutputFormat. With these changes, if a message with content-type is received, the same contents will be gotten if call writeTo method. Also, if we create a message from scratch, multiple call of writeTo method will get the same message contents. Thanks.
        Hide
        Andreas Veithen added a comment -

        Ivan,

        The two new test cases fail with the SAAJ reference implementation. You can check that by adding a @Validated annotation to the test methods; they will then be executed against the reference implementation before testing the Axis2 implementation.

        Show
        Andreas Veithen added a comment - Ivan, The two new test cases fail with the SAAJ reference implementation. You can check that by adding a @Validated annotation to the test methods; they will then be executed against the reference implementation before testing the Axis2 implementation.
        Hide
        Ivan added a comment -

        Thanks, Andreas, I will check it,

        Show
        Ivan added a comment - Thanks, Andreas, I will check it,
        Hide
        Ivan added a comment -

        I add one more case for the patch. And now all of them should pass with RI. One of the reason the failures with RI is that RI will not add start parameter in the content-type header for it is an optional one.

        Show
        Ivan added a comment - I add one more case for the patch. And now all of them should pass with RI. One of the reason the failures with RI is that RI will not add start parameter in the content-type header for it is an optional one.
        Hide
        Andreas Veithen added a comment -

        Applied your patch with some minor changes (in particular to avoid usage of deprecated constants). Thanks for your contribution.

        Show
        Andreas Veithen added a comment - Applied your patch with some minor changes (in particular to avoid usage of deprecated constants). Thanks for your contribution.
        Hide
        Ivan added a comment -

        Thanks, Andreas.

        Show
        Ivan added a comment - Thanks, Andreas.
        Hide
        Hudson added a comment -

        Integrated in Axis2 #809 (See https://builds.apache.org/job/Axis2/809/)
        AXIS2-5067: Committed patch provided by Ivan (xuhaihong), with minor changes. This implements the saveChanges method and calculates the correct content type for a SOAPMessage.

        veithen :
        Files :

        • /axis/axis2/java/core/trunk/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java
        • /axis/axis2/java/core/trunk/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java
        • /axis/axis2/java/core/trunk/modules/saaj/test/org/apache/axis2/saaj/SOAPMessageTest.java
        Show
        Hudson added a comment - Integrated in Axis2 #809 (See https://builds.apache.org/job/Axis2/809/ ) AXIS2-5067 : Committed patch provided by Ivan (xuhaihong), with minor changes. This implements the saveChanges method and calculates the correct content type for a SOAPMessage. veithen : Files : /axis/axis2/java/core/trunk/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java /axis/axis2/java/core/trunk/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java /axis/axis2/java/core/trunk/modules/saaj/test/org/apache/axis2/saaj/SOAPMessageTest.java
        Hide
        Hudson added a comment -

        Integrated in axis2-1.6 #66 (See https://builds.apache.org/job/axis2-1.6/66/)
        Merged a bunch of changes to the 1.6 branch as requested by the Geronimo project:

        Revision: 1068985
        AXIS2-4952
        Scope dynamic ports to the instance of the service that did the addPort(...). Add TDD Unit test and flag to revert to previous behavior of sharing dynamic ports across services.

        Revision: 1069659
        Message:
        AXIS2-4938
        Patch submitted by Katherine Sanders. BindingProvider.getEndpointReference should put reference parameters from WSDL in returned EPR.

        Revision: 1069898
        AXIS2-4948
        Patch contributed by Katherine Sanders. Wrong WSDL location returned by BindingProvider; was using the local filesystem path instead of the endpoint URL.

        Revision: 1075057
        Prevent index out of bounds exception, or any exception, from attempting to log. Add TDD/UT for same.

        Revision: 1096530
        On JAX-WS Client, treat local exceptions (e.g. ConnectException) as a SOAPFault, driving the JAX-WS handler handleFault methods and throwing a SOAPFAultException back through the client invocation. Also provide a property to revert to previous behavior of creating an empty message, driving the JAX-WS handler handleMessage methods, and throwing a WebServiceException back through the client invocation.

        Revision: 1096557
        Two changes in JAX-WS Endpoint implementation (1) Override setEndpointContext method, (2) Add logic to throw an exception if endpoint publishing is disabled by a property (publishing is enabled by default); per JSR-109 5.3.3 dynamically publishing endpoints in a server environment is non portable and should be disabled. A server runtime can use the property to disabled dynamically publishing JAX-WS endpoints via Endpoint.publish methods.

        Revision: 1103336
        AXIS2-5021: Committed patch provided by Ivan (xuhaihong).

        Revision: 1136177
        AXIS2-5067: Committed patch provided by Ivan (xuhaihong), with minor changes. This implements the saveChanges method and calculates the correct content type for a SOAPMessage.

        veithen :
        Files :

        • /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
        • /axis/axis2/java/core/branches/1_6/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/resourceinjection/sei/ResourceInjectionService.java
        • /axis/axis2/java/core/branches/1_6/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addnumbershandler/AddNumbersClientLogicalHandler3.java
        • /axis/axis2/java/core/branches/1_6/modules/jaxws/test/org/apache/axis2/jaxws/WebServiceExceptionLoggerTests.java
        • /axis/axis2/java/core/branches/1_6/modules/jaxws-integration/test-resources/wsdl/resourceinjection.wsdl
        • /axis/axis2/java/core/branches/1_6/modules/jaxws/test/org/apache/axis2/jaxws/client/dispatch/DynamicPortCachingTests.java
        • /axis/axis2/java/core/branches/1_6
        • /axis/axis2/java/core/branches/1_6/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
        • /axis/axis2/java/core/branches/1_6/modules/metadata/src/org/apache/axis2/jaxws/ExceptionFactory.java
        • /axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java
        • /axis/axis2/java/core/branches/1_6/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
        • /axis/axis2/java/core/branches/1_6/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/resourceinjection/sei/ResourceInjectionPortType.java
        • /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/WebServiceExceptionLogger.java
        • /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/addressing/factory/impl/Axis2EndpointReferenceFactoryImpl.java
        • /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/impl/AxisInvocationController.java
        • /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java
        • /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
        • /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
        • /axis/axis2/java/core/branches/1_6/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
        • /axis/axis2/java/core/branches/1_6/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/ResourceInjectionTests.java
        • /axis/axis2/java/core/branches/1_6/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/resourceinjection/ResourceInjectionPortTypeImpl.java
        • /axis/axis2/java/core/branches/1_6/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
        • /axis/axis2/java/core/branches/1_6/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/resourceinjection/META-INF/resourceinjection.wsdl
        • /axis/axis2/java/core/branches/1_6/modules/jaxws/test/org/apache/axis2/jaxws/client/ReleaseServiceTests.java
        • /axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java
        • /axis/axis2/java/core/branches/1_6/modules/saaj/test/org/apache/axis2/saaj/SOAPMessageTest.java
        • /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java
        • /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/Constants.java
        • /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/context/WebServiceContextImpl.java
        Show
        Hudson added a comment - Integrated in axis2-1.6 #66 (See https://builds.apache.org/job/axis2-1.6/66/ ) Merged a bunch of changes to the 1.6 branch as requested by the Geronimo project: Revision: 1068985 AXIS2-4952 Scope dynamic ports to the instance of the service that did the addPort(...). Add TDD Unit test and flag to revert to previous behavior of sharing dynamic ports across services. Revision: 1069659 Message: AXIS2-4938 Patch submitted by Katherine Sanders. BindingProvider.getEndpointReference should put reference parameters from WSDL in returned EPR. Revision: 1069898 AXIS2-4948 Patch contributed by Katherine Sanders. Wrong WSDL location returned by BindingProvider; was using the local filesystem path instead of the endpoint URL. Revision: 1075057 Prevent index out of bounds exception, or any exception, from attempting to log. Add TDD/UT for same. Revision: 1096530 On JAX-WS Client, treat local exceptions (e.g. ConnectException) as a SOAPFault, driving the JAX-WS handler handleFault methods and throwing a SOAPFAultException back through the client invocation. Also provide a property to revert to previous behavior of creating an empty message, driving the JAX-WS handler handleMessage methods, and throwing a WebServiceException back through the client invocation. Revision: 1096557 Two changes in JAX-WS Endpoint implementation (1) Override setEndpointContext method, (2) Add logic to throw an exception if endpoint publishing is disabled by a property (publishing is enabled by default); per JSR-109 5.3.3 dynamically publishing endpoints in a server environment is non portable and should be disabled. A server runtime can use the property to disabled dynamically publishing JAX-WS endpoints via Endpoint.publish methods. Revision: 1103336 AXIS2-5021 : Committed patch provided by Ivan (xuhaihong). Revision: 1136177 AXIS2-5067 : Committed patch provided by Ivan (xuhaihong), with minor changes. This implements the saveChanges method and calculates the correct content type for a SOAPMessage. veithen : Files : /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java /axis/axis2/java/core/branches/1_6/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/resourceinjection/sei/ResourceInjectionService.java /axis/axis2/java/core/branches/1_6/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addnumbershandler/AddNumbersClientLogicalHandler3.java /axis/axis2/java/core/branches/1_6/modules/jaxws/test/org/apache/axis2/jaxws/WebServiceExceptionLoggerTests.java /axis/axis2/java/core/branches/1_6/modules/jaxws-integration/test-resources/wsdl/resourceinjection.wsdl /axis/axis2/java/core/branches/1_6/modules/jaxws/test/org/apache/axis2/jaxws/client/dispatch/DynamicPortCachingTests.java /axis/axis2/java/core/branches/1_6 /axis/axis2/java/core/branches/1_6/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java /axis/axis2/java/core/branches/1_6/modules/metadata/src/org/apache/axis2/jaxws/ExceptionFactory.java /axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java /axis/axis2/java/core/branches/1_6/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java /axis/axis2/java/core/branches/1_6/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/resourceinjection/sei/ResourceInjectionPortType.java /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/WebServiceExceptionLogger.java /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/addressing/factory/impl/Axis2EndpointReferenceFactoryImpl.java /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/impl/AxisInvocationController.java /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/EndpointImpl.java /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java /axis/axis2/java/core/branches/1_6/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java /axis/axis2/java/core/branches/1_6/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/ResourceInjectionTests.java /axis/axis2/java/core/branches/1_6/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/resourceinjection/ResourceInjectionPortTypeImpl.java /axis/axis2/java/core/branches/1_6/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java /axis/axis2/java/core/branches/1_6/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/resourceinjection/META-INF/resourceinjection.wsdl /axis/axis2/java/core/branches/1_6/modules/jaxws/test/org/apache/axis2/jaxws/client/ReleaseServiceTests.java /axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java /axis/axis2/java/core/branches/1_6/modules/saaj/test/org/apache/axis2/saaj/SOAPMessageTest.java /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/Constants.java /axis/axis2/java/core/branches/1_6/modules/jaxws/src/org/apache/axis2/jaxws/context/WebServiceContextImpl.java
        Hide
        Hudson added a comment -

        Integrated in axis2-1.5 #161 (See https://builds.apache.org/job/axis2-1.5/161/)
        AXIS2-5067: Merged r1036675 and r1136177 to the 1.5 branch.

        veithen :
        Files :

        • /axis/axis2/java/core/branches/1_5/modules/soapmonitor/module/pom.xml
        • /axis/axis2/java/core/branches/1_5/modules/transport/http/pom.xml
        • /axis/axis2/java/core/branches/1_5/modules/soapmonitor/module/src/main/java/org/apache/axis2/handlers
        • /axis/axis2/java/core/branches/1_5
        • /axis/axis2/java/core/branches/1_5/modules/saaj/test/org/apache/axis2/saaj/TestUtils.java
        • /axis/axis2/java/core/branches/1_5/modules/kernel/src/org/apache/axis2/transport/http/util/QueryStringParser.java
        • /axis/axis2/java/core/branches/1_5/modules/soapmonitor/module/src/main/resources/META-INF/module.xml
        • /axis/axis2/java/core/branches/1_5/modules/kernel/test/org/apache/axis2/transport/http/util/QueryStringParserTest.java
        • /axis/axis2/java/core/branches/1_5/modules/soapmonitor/servlet/src/main/java/org/apache/axis2/soapmonitor/servlet
        • /axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java
        • /axis/axis2/java/core/branches/1_5/modules/tool/axis2-repo-maven-plugin
        • /axis/axis2/java/core/branches/1_5/modules/transport/http/src
        • /axis/axis2/java/core/branches/1_5/modules/distribution
        • /axis/axis2/java/core/branches/1_5/modules/soapmonitor/servlet/src/main/java/org/apache/axis2/soapmonitor/applet
        • /axis/axis2/java/core/branches/1_5/modules/transport/local
        • /axis/axis2/java/core/branches/1_5/modules/webapp/src/main/java/org/apache/axis2/webapp/AxisAdminServlet.java
        • /axis/axis2/java/core/branches/1_5/modules/soapmonitor/servlet
        • /axis/axis2/java/core/branches/1_5/modules/webapp/src/main/java/org/apache/axis2/webapp/AdminAgent.java
        • /axis/axis2/java/core/branches/1_5/modules/parent
        • /axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java
        • /axis/axis2/java/core/branches/1_5/modules/saaj/test/org/apache/axis2/saaj/SOAPMessageTest.java
        • /axis/axis2/java/core/branches/1_5/modules/soapmonitor/module
        Show
        Hudson added a comment - Integrated in axis2-1.5 #161 (See https://builds.apache.org/job/axis2-1.5/161/ ) AXIS2-5067 : Merged r1036675 and r1136177 to the 1.5 branch. veithen : Files : /axis/axis2/java/core/branches/1_5/modules/soapmonitor/module/pom.xml /axis/axis2/java/core/branches/1_5/modules/transport/http/pom.xml /axis/axis2/java/core/branches/1_5/modules/soapmonitor/module/src/main/java/org/apache/axis2/handlers /axis/axis2/java/core/branches/1_5 /axis/axis2/java/core/branches/1_5/modules/saaj/test/org/apache/axis2/saaj/TestUtils.java /axis/axis2/java/core/branches/1_5/modules/kernel/src/org/apache/axis2/transport/http/util/QueryStringParser.java /axis/axis2/java/core/branches/1_5/modules/soapmonitor/module/src/main/resources/META-INF/module.xml /axis/axis2/java/core/branches/1_5/modules/kernel/test/org/apache/axis2/transport/http/util/QueryStringParserTest.java /axis/axis2/java/core/branches/1_5/modules/soapmonitor/servlet/src/main/java/org/apache/axis2/soapmonitor/servlet /axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java /axis/axis2/java/core/branches/1_5/modules/tool/axis2-repo-maven-plugin /axis/axis2/java/core/branches/1_5/modules/transport/http/src /axis/axis2/java/core/branches/1_5/modules/distribution /axis/axis2/java/core/branches/1_5/modules/soapmonitor/servlet/src/main/java/org/apache/axis2/soapmonitor/applet /axis/axis2/java/core/branches/1_5/modules/transport/local /axis/axis2/java/core/branches/1_5/modules/webapp/src/main/java/org/apache/axis2/webapp/AxisAdminServlet.java /axis/axis2/java/core/branches/1_5/modules/soapmonitor/servlet /axis/axis2/java/core/branches/1_5/modules/webapp/src/main/java/org/apache/axis2/webapp/AdminAgent.java /axis/axis2/java/core/branches/1_5/modules/parent /axis/axis2/java/core/branches/1_5/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java /axis/axis2/java/core/branches/1_5/modules/saaj/test/org/apache/axis2/saaj/SOAPMessageTest.java /axis/axis2/java/core/branches/1_5/modules/soapmonitor/module

          People

          • Assignee:
            Andreas Veithen
            Reporter:
            Ivan
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development