I have written a soap/web service that returns a string such as:
"<GeocodeResponse><City>Denver</City><State>CO</State></GeocodeResponse>"
I have defined a schema for this data:
<xs:element name="GeocodeResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="City"/>
<xs:element name="State"/>
</xs:sequence>
</xs:complexType>
</xs:element>
and this is returned as the response for my web service method
<xs:complexType name="standardizeResponse">
<xs:sequence>
<GeocodeResponse/>
</xs:sequence>
</xs:complexType>
Within the soap envelope, the Xml is escaped so instead of getting the xml I want, I get something like:
<GeocodeResponse><City>Denver</City><State>CO</State></GeocodeResponse>
I thought that by using the schema to define what is returned in the string that I would avoid having the string escaped.
When you provide a raw string to an XML processor, the understanding is that the meaning of the string is to be conveyed to a receiver such that the actual string can be reconstructed. This means that the processor will escape any of the reserved XML characters (< > & % ‘) so that they are not misconstrued as part of the document rather than the message in the document.
If you use xjc to generate objects to reflect the schemas (or, better yet, wsimport to generate objects and service stubs from a WSDL), you can populate the generated object with the data and then use a Marshaller to construct the response message which will then be rendered as properly tagged XML. The Marshaller documentation actually provides good examples of usage to marshal into various forms (http://docs.oracle.com/javase/6/docs/api/javax/xml/bind/Marshaller.html).
I am making assumptions to make up for a lack of context so if this answer does not seem to apply, please respond as such and include the actual service endpoint code and I (or another responder) can revisit.
Good luck!