I created a Java web service with JAX-WS . This is a simple one that just returns a version labeled String :
@WebService(endpointInterface = "mod2.Mod2") public class Mod2Impl implements Mod2 { @Override public String mod2(String x) { return x.toUpperCase(); } }
and its interface:
@WebService public interface Mod2 { @WebMethod String mod2(String x); }
JAX generates the mod2.jaxws package for me with the appropriate classes. The answer is:
@XmlRootElement(name = "mod2Response", namespace = "http://mod2/") @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "mod2Response", namespace = "http://mod2/") public class Mod2Response { @XmlElement(name = "return", namespace = "") private String _return; public String getReturn() { return this._return; } public void setReturn(String _return) { this._return = _return; } }
When deployed, it generates the correct WSDL file with import to XSD . This is XSD :
<xs:schema xmlns:tns="http://mod2/" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" targetNamespace="http://mod2/"> <xs:element name="mod2" type="tns:mod2"/> <xs:element name="mod2Response" type="tns:mod2Response"/> <xs:complexType name="mod2"> <xs:sequence> <xs:element name="arg0" type="xs:string" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:complexType name="mod2Response"> <xs:sequence> <xs:element name="return" type="xs:string" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:schema>
Now I want to change the element named "return" in XSD for what I want. I tried changing @XmlElement(name = "return", namespace = "") in the Mod2Response class, but this causes the following error:
GRAVE: WSSERVLET11: failed to parse runtime descriptor: javax.xml.ws.WebServiceException: class mod2.jaxws.Mod2Response do not have a property of the name return
What should I change to achieve this?
source share