1 Reply Latest reply on May 28, 2010 2:30 AM by Magesh Bojan

    SOAPClient, OGNL, empty optionals elements and xs:date

    Guillaume Bourgois Newbie

      Hi !

       

      It seems that when we use an OGNL map the generated soap contains all optional element with empty value.

       

      For example, with the following xsd :

       

      <?xml version="1.0" encoding="UTF-8"?><xs:schema targetNamespace="http://webservice_consumer/test"
          elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"
          xmlns:tns="http://webservice_consumer/test">
          <xs:element name="root">
              <xs:complexType>
                  <xs:sequence>
                      <xs:element name="mandatoryElement" type="xs:string" />
                      <xs:element name="optionalStringElement" type="xs:string"
                          minOccurs="0" />
                      <xs:element name="optionalElement" type="tns:optionalElementType"
                          minOccurs="0" />
                  </xs:sequence>
              </xs:complexType>
          </xs:element>
          <xs:complexType name="optionalElementType">
              <xs:sequence>
                  <xs:element name="aString" type="xs:string" minOccurs="0" />
                  <xs:element name="aDate" type="xs:date" minOccurs="0" />
              </xs:sequence>
          </xs:complexType>
      </xs:schema>

       

      and the requestMap

       

      {code}requestMap.put("root.mandatoryElement","A");{code}

       

      the generated soap is (from soapUI software)

       

      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:test="http://webservice_consumer/test">
         <soapenv:Header/>
         <soapenv:Body>
            <test:root>
               <test:mandatoryElement>A</test:mandatoryElement>
               <!--Optional:-->
               <test:optionalStringElement/>
               <!--Optional:-->
               <test:optionalElement>
                  <!--Optional:-->
                  <test:aString/>
                  <!--Optional:-->
                  <test:aDate/>
               </test:optionalElement>
            </test:root>
         </soapenv:Body>
      </soapenv:Envelope>

       

      soapUI accept that but not my esb service (webservice="true") even without the comments, unless I remove the "aDate" element, wich must be a type issue.

       

      So my question : how avoid the generation of optionnals elements without values ?