[jdom-interest] Passing Element parameter in Jax-ws web method

Rolf Lear jdom at tuis.net
Sat Mar 17 08:47:56 PDT 2012


Hi Dehaene

Technically, the Element instance does have a no-arg constructor, only 
it is 'protected', not public.

For you to solve your problem in the short term, you may want to do:

class MyElement extends Element {
   public MyElement() {
     super();
   }
}

Then you can make the method:

public void hello(@WebParam(name = "xmlElement") MyElement element){


I am not familiar enough with the  jax-ws to know whether this will help 
enough.... It will make the implementation a little messier, but, by 
default, JDOM doe s not let you create invalid Elements (which an 
Element without a name would be...).

It is not likely possible to make the no-arg constructor public.

Anothe roption is to create a serialized Element? Element serialization 
(at least in JDOM2) is reliable....

Rolf




On 17/03/2012 11:14 AM, Dehaene Thomas wrote:
> Hello,
>
> I have a problem when accepting a web parameter of the type Element. My code is as follows:
>
>      @WebMethod(operationName = "hello")
>      public void hello(@WebParam(name = "xmlElement") Element element){
>
>          String name = new String();
>          name = element.getChild("FirstName").getValue();
>
>      }
>
> Which generates an error when I try to deploy the web service. Namely that the Element class
> does not have a no-arg constructor.
>
> If this where a normal method, I would simply make it a 'public static void' method,
> but since WebMethods in Jax-ws can't be of the 'final' or 'static' type, I can't seem to
> accept an Element parameter.
>
> Any suggestions how to solve this?
>
>
>
>
> Many thanks and greetings
>
> Thomas Dehaene
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
>



More information about the jdom-interest mailing list