8

My Wrapper class is this:

@XmlRootElement(name = "GETA")
public class EfGetAResponseWrapperXmlObject {

    private String something;


    @XmlElement(name = "result")
    public String getSomething() {
        return something;
    }

    public void setSomething(String something) {
        this.something = something;
    }

}

For this wrapper class I get this answer on SoapUI:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
       <S:Body>
          <ns2:ef_getAresponse xmlns:ns2="http://service.package/">
             <ef_get_AReturn>&lt;GETA>
        &lt;result>mystring&lt;/result>
    &lt;/GETA></ef_get_AReturn>
          </ns2:ef_get_AResponse>
       </S:Body>
    </S:Envelope>

If I introduce one more variable to my Wrapper class:

@XmlRootElement(name = "GETA")
    public class EfGetAResponseWrapperXmlObject {

        private String something;
        private String other;


        @XmlElement(name = "result")
        public String getSomething() {
            return something;
        }

        public void setSomething(String something) {
            this.something = something;
        }

        public String getOther() {
            return other;
        }
        public void setOther(String other) {
            this.other = other;
        }
    }

I get this answer:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <ns2:ef_getAresponse xmlns:ns2="http://service.package/">
         <ef_get_AReturn><![CDATA[<GETA>
    <result>fasf</result>
    <other>fds</other>
</GETA>]]></ef_get_AReturn>
      </ns2:ef_getAresponse>
   </S:Body>
</S:Envelope>

I dont understand this behaviour. I want to have the same answer on the first case that I have on second case. How can I do this?

Shirkrin
  • 3,993
  • 1
  • 29
  • 35
Goldbones
  • 1,407
  • 3
  • 21
  • 55
  • http://forums.asp.net/t/1624525.aspx?Prevent+XML+web+service+SOAP+from+enclosing+returned+data+in+CData+. – Aleksandr M Jul 28 '15 at 11:12
  • Have you tried annotating the field with `@XmlTransient` as in http://stackoverflow.com/a/10968561/1295364 – carcaret Jul 28 '15 at 12:48
  • Do you mean that the first response is generated with all the "<" escaped? The primary reason why JAXB/JAXWS will automatically "CDATA" your response is if there's markup or some other escape-worthy content in there. Your second response doesn't look like that would have been necessary. Perhaps you should look into your ObjectFactory as to *why* it's happening. To resolve, just use the recommendation from carcaret – kolossus Jul 28 '15 at 16:30
  • The problem is in response. If I have a short answer I do not have ![CDATA[]]. It´s not a java implementation problem, as you answered. In browser I don ´t get: <result>mystring</result> </GETA> I get with CDATA. So the problem is in SoapUI. – Goldbones Jul 28 '15 at 16:34

0 Answers0