jax ws - What should I change to get a different element name on the response XSD of an automatically generated JAX-WS? -


i have created web service in java jax-ws. simple 1 returns uppercased version of string:

@webservice(endpointinterface = "mod2.mod2") public class mod2impl implements mod2 {      @override     public string mod2(string x) {          return x.touppercase();      } } 

and interface:

@webservice public interface mod2 {      @webmethod     string mod2(string x);  } 

jax generates mod2.jaxws package me relevant classes. response this:

@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;      /**      *       * @return      *     returns string      */     public string getreturn() {         return this._return;     }      /**      *       * @param _return      *     value _return property      */     public void setreturn(string _return) {         this._return = _return;     }  } 

when deployed generates proper wsdl file import xsd. 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, want change element named "return" in xsd whatever want. have tried changing @xmlelement(name = "return", namespace = "") in mod2response class throws following error:

grave: wsservlet11: failed parse runtime descriptor: javax.xml.ws.webserviceexception: class mod2.jaxws.mod2response not have property of name return 

what have change achieve this?

i have found answer here.

i added @webresult(name="mod2result") interface:

@webservice public interface mod2 {      @webmethod     @webresult(name="mod2result")     string mod2(string x);  } 

and run wsgen again. generated following response:

@xmlrootelement(name = "mod2response", namespace = "http://mod2/") @xmlaccessortype(xmlaccesstype.field) @xmltype(name = "mod2response", namespace = "http://mod2/") public class mod2response {      @xmlelement(name = "mod2result", namespace = "")     private string mod2result;      /**      *       * @return      *     returns string      */     public string getmod2result() {         return this.mod2result;     }      /**      *       * @param mod2result      *     value mod2result property      */     public void setmod2result(string mod2result) {         this.mod2result = mod2result;     }  } 

which has @xmlelement(name = "mod2result") stated joshi changed name of variable, setter , getter. tried @xmlelement straight in response class no success.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -