Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-4973

MTOM attachment parsing issue with generated code

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.5.4
    • Fix Version/s: None
    • Component/s: codegen
    • Labels:
    • Environment:
      JDK EE 6 with JRE 1.6.0_22

      Description

      Input:
      Used a WSDL which have this attachment structure:
      <xs:complexType name="AttachmentType">
      <xs:sequence>
      <xs:element name="AttachmentName" type="xs:string" minOccurs="0"/>
      <xs:element name="AttachmentData" type="xs:base64Binary" minOccurs="0"/>
      </xs:sequence>
      </xs:complexType>

      this is inside of <xs:element name="Attachment" type="ns1:AttachmentType" minOccurs="0" maxOccurs="3"/>
      this is inside of a complex structure (let is be <MyStruct>) and that can be reoccur infinite times.

      I used the latest 1.5.4 axis2's wsdl2java with no extra options enabled to make a java stub for the client side.

      Problem:
      After getting a response with the required aforementioned structure, if there is no attachment then the parsing is ok.
      If there is an MTOM attachment (using <ns1:Include xmlns:ns1="http://www.w3.org/2004/08/xop/include" href="cid:this_is_anid"/> inside of AttachmentData tag) then the parsing have problems:

      • In some cases, I got unexpected subelement error to the next MyStruct which is after the currently parsed struct if there is an attachment inside of it. However, the attachment is retrieved if I try to remove the unexpected element exceptions manually.
      • in some other cases (added 2 other <Attachment/> tags after the first to be 3 attachment tags) the MyStruct structure which helds Attachment tag will be parsed successfully, but the second seems to be not AND I get an unexpected subelement for the next structure which is after MyStruct in the WSDL definition in the sequence.

      __________________________________________________________________
      __________________________________________________________________

      I have found the workaround for this lately
      generating code with this:
      <xs:simpleType name="AttachmentDataType">
      <xs:restriction base="xs:base64Binary" />
      </xs:simpleType>
      ...
      <xs:complexType name="AttachmentType">
      <xs:sequence>
      <xs:element name="AttachmentName" type="xs:string" minOccurs="0"/>
      <xs:element name="AttachmentData" type="ns1:AttachmentDataType" minOccurs="0"/>
      </xs:sequence>
      </xs:complexType>

      This will give a code which doesn't fail on attachments.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              n3whous3 Újházi, Béla
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: