java - JAX-WS duplicates complex type when generating wsdl -
i'm developing web service several methods taking input identical complex data types. data types have jaxb annotations , setters , getters, , web service class has jax-ws annotations.
template of service.java file:
@webservice(servicename = "servicews") public class sericews { private static serviceif serviceimpl; static { serviceimpl = new serviceimpl(); } public result method1(credentials credentials) { @webparam(name = "credentials") credentials credentials) { return serviceimpl.method1(credentials); } public result method2(credentials credentials) { @webparam(name = "credentials") credentials credentials) { return serviceimpl.method2(credentials); }
}
edit: credentials.java file:
@xmlaccessortype(xmlaccesstype.field) @xmltype(name = "", proporder = { "name", "password" }) @xmlrootelement(name = "credentials") public class credentials implements mybean { @xmlelement(required = true) protected string name; @xmlelement(required = true) protected string password; /** * gets value of name property. * * @return name property of credentials * */ public string getname() { return name; } /** * sets value of name property. * * @param value name property of credentials * */ public void setname(string value) { this.name = value; } /** * gets value of password property. * * @return password property of credentials * */ public string getpassword() { return password; } /** * sets value of password property. * * @param value password property of credentials * */ public void setpassword(string password) { this.password = password; } }
the service deployed in tomcat , wsdl auto-generated. when generating client stubs wsimport duplicate generation of credentials type (credentials, method1.credentials , method2.credentials), i.e. different (inner) class each method.
it seems problem arrises when wsdl , schema generated :
<xs:schema xmlns:tns="http://service.my.package.com/" xmlns:xs="http://www.w3.org/2001/xmlschema" version="1.0" targetnamespace="http://service.my.package.com/"> <xs:element name="credentials"> <xs:complextype> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="password" type="xs:string"/> </xs:sequence> </xs:complextype> </xs:element> .... <xs:complextype name="getlockboxkeys"> <xs:sequence> <xs:element name="credentials" minoccurs="0"> <xs:complextype> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="password" type="xs:string"/> </xs:sequence> </xs:complextype> </xs:element> .....
how can make work such have 1 definition of credentials? quite new web services, jax-ws , jaxb i'm not sure have annotations right.
any appreciated.
i'm not going give complete answer explaining rules, since don't remember/understand them all.
but think if add name
element @xmltype
annotation you'll you're looking (or @ least bit further).
@xmlaccessortype(xmlaccesstype.field) @xmltype(name = "credentials", proporder = { "name", "password" }) @xmlrootelement(name = "credentials") public class credentials {
btw, original service.java file didn't seem paste cleanly (had incorrect braces think) making hard recreate.
Comments
Post a Comment