2015-03-28 25 views
8

mia classe wrapper è questo:non introducendo CDATA con un solo valore

@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; 
    } 

} 

Per questa classe wrapper ho questa risposta su 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> 

Se introduco una variabile più di mio Wrapper classe:

@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; 
     } 
    } 

ottengo questa risposta:

<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> 

Non capisco questo comportamento. Voglio avere la stessa risposta sul primo caso che ho sul secondo caso. Come posso fare questo?

+0

http://forums.asp.net/t/1624525.aspx?Prevent+XML+web+servizio+SOAP+da+in+sostenibile+data+in+CDATA+. –

+0

Hai provato ad annotare il campo con '@ XmlTransient' come in http://stackoverflow.com/a/10968561/1295364 – carcaret

+0

Vuoi dire che la prima risposta è generata con tutti i" <"fuggiti? Il motivo principale per cui JAXB/JAXWS automaticamente "CDATA" la tua risposta è se ci sono markup o altri contenuti degni di nota. La tua seconda risposta non sembra che sarebbe stata necessaria. Forse dovresti esaminare il tuo ObjectFactory quanto a * perché * sta accadendo. Per risolvere, basta utilizzare la raccomandazione di carcaret – kolossus

risposta