String being escaped
nicksyd Jul 30, 2009 11:28 AMHi,
I've got a sample webservice that I'm deploying to JBoss 4.2.2.GA with JBoss-WS 3.0.2
<?xml version="1.0" encoding="UTF-8"?> <definitions targetNamespace="http://roundtrip.developerWorks.ibm.com" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:impl="http://roundtrip.developerWorks.ibm.com" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"> <types> <schema targetNamespace="http://roundtrip.developerWorks.ibm.com" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <complexType name="life"> <sequence> <element name="deathday" nillable="true" type="xsd:dateTime"/> <element name="birthday" nillable="true" type="xsd:dateTime"/> <element name="str" nillable="false" type="xsd:string" form="qualified"/> </sequence> </complexType> </schema> </types> <message name="GetALifeRequest"/> <message name="GetALifeResponse"> <part name="GetALifeReturn" type="impl:life"/> </message> <portType name="population"> <operation name="GetALife"> <input message="impl:GetALifeRequest" name="GetALifeRequest"/> <output message="impl:GetALifeResponse" name="GetALifeResponse"/> </operation> </portType> <binding name="populationSoapBinding" type="impl:population"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="GetALife"> <wsdlsoap:operation soapAction=""/> <input name="GetALifeRequest"> <wsdlsoap:body namespace="http://roundtrip.developerWorks.ibm.com" use="literal"/> </input> <output name="GetALifeResponse"> <wsdlsoap:body namespace="http://roundtrip.developerWorks.ibm.com" use="literal"/> </output> </operation> </binding> <service name="populationService"> <port binding="impl:populationSoapBinding" name="population"> <wsdlsoap:address location="http://localhost:9080/Roundtrip2/services/population"/> </port> </service> </definitions>
<?xml version="1.0" encoding="UTF-8"?> <webservices version="1.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd"> <webservice-description> <webservice-description-name>populationService</webservice-description-name> <wsdl-file>WEB-INF/wsdl/Roundtrip2.wsdl</wsdl-file> <jaxrpc-mapping-file>WEB-INF/wsdl/Roundtrip2_mapping.xml</jaxrpc-mapping-file> <port-component> <port-component-name>population</port-component-name> <wsdl-port xmlns:pfx="http://roundtrip.developerWorks.ibm.com">pfx:population</wsdl-port> <service-endpoint-interface>com.ibm.developerWorks.roundtrip.population</service-endpoint-interface> <service-impl-bean> <servlet-link>population</servlet-link> </service-impl-bean> </port-component> </webservice-description> </webservices>
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="WebApp_ID" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <servlet> <servlet-name>population</servlet-name> <servlet-class>org.jboss.wsf.stack.jbws.EndpointServlet</servlet-class> <init-param> <param-name>jboss.ws.endpoint</param-name> <param-value>com.ibm.developerWorks.roundtrip.populationImpl</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>population</servlet-name> <url-pattern>/ws/*</url-pattern> </servlet-mapping> </web-app>
The populationImpl.java
package com.ibm.developerWorks.roundtrip; import java.util.Calendar; import java.util.Date; public class populationImpl implements population { public life GetALife() { life aLife = new life(); Calendar cal = Calendar.getInstance(); cal.set(1910, 4, 15); aLife.birthday = cal.getTime(); cal.set(2002, 11, 25); aLife.deathday = cal.getTime(); String str=new String("<![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\"?>]]>"); aLife.str=str; aLife._value=str; System.out.println("The value is " + str); return aLife; } }
The response I'm getting is as follows,
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Header/> <env:Body> <roun:GetALifeResponse xmlns:roun="http://roundtrip.developerWorks.ibm.com"> <GetALifeReturn xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <deathday>2002-12-24T14:14:47.646Z</deathday> <birthday>1910-05-14T15:14:47.646Z</birthday> <ns_str:str xmlns:ns_str="http://roundtrip.developerWorks.ibm.com"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>]]></ns_str:str> </GetALifeReturn> </roun:GetALifeResponse> </env:Body> </env:Envelope>
For some reason the CDATA inside the element is being escaped. Can I specify anywhere in JBoss not to escape the string being returned ?
Thanks