You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by mattmadhavan <ma...@yahoo.com> on 2007/09/04 21:06:45 UTC

Help in annotating Java beans as paramater to a web service!

Hello,
Please bear with me, I am new to CXF. 

I am doing a Java first development and I have one webservice method called
addProductInfo, which takes a paramter, ProductInfo. 


@WebService(name = "ProductInfo",
        targetNamespace = "http://vibes.contentmanagement")
public interface IAddProductInfo extends Serializable {
	@WebMethod(operationName="addProductInfo", action="urn:addProductInfo")	
	@WebResult(name="return")
	public Integer addProductInfo(@WebParam(name="productInfo")BaseProduct
product);
}

My BaseProduct class is as follows:

public class BaseProduct extends BaseEntity {

    private String name = "";
    private String description;
    private float price;
    private String keyword = "";
    private String shortCode;
}

All the fields are required except, keyword and short code! How do I
annotate the webmethod and the individual fields on the BaseProduct class?

Can someone point me to right documentations.

Thanks
Matt




-- 
View this message in context: http://www.nabble.com/Help-in-annotating-Java-beans-as-paramater-to-a-web-service%21-tf4379704.html#a12484583
Sent from the cxf-user mailing list archive at Nabble.com.


RE: Help in annotating Java beans as paramater to a web service!

Posted by Christopher Moesel <Ch...@avid.com>.
Matt,

Sorry-- the text-wrapping must have messed up the first link.  Try this:
http://tinyurl.com/2hvv5o

I think you need to annotate the JavaBean's class with @XmlRootElement
and the members of the class with @XmlElement and @XmlAttribute
(depending how you want it represented).  If you look at the docs on
@XmlElement and @XmlAttribute in the 2nd link I sent, you'll see how to
mark if it's required or not.

Another way of doing it (that would be longer) would be to not do
anything special to the JavaBean, then have CXF generate the WSDL.
Next, modify the WSDL the way you want it (setting required attributes,
etc) and then have CXF generate Java code based off the modified WSDL.
You could then look at the generated Java code to see how to annotate
those things you want.  This of course, would not be how you normally do
your development-- but it might be a good way to play around with JAXB.

-Chris

-----Original Message-----
From: mattmadhavan [mailto:mattmadhavan@yahoo.com] 
Sent: Tuesday, September 04, 2007 3:40 PM
To: cxf-user@incubator.apache.org
Subject: RE: Help in annotating Java beans as paramater to a web
service!


Hi Chris,
The first link you sent does n't seem to work. Can you re-send it?

My question is regardless of the underlying mapping, is there anyway to
JAX-WS annotate a JavaBean as opposed to a simple param? All the
examples I
have seen so far only take simple params. Any example using a Java Bean
as a
param having both optional and required a attributes will be
appreciated.


Thanks
Matt



Christopher Moesel wrote:
> 
> Hi Matt,
> 
> If you're using the default data binding (JAXB 2.0), then you may want
> to check out JAXB's documentation on annotating classes.
> 
> For starter's, you can see Kohsuke's blog entry on using JAXB:
>
http://weblogs.java.net/blog/kohsuke/archive/2005/02/using_jaxb_20_t.htm
> l
> 
> Then for all the gritty details on the possible annotations, check out
> the JAXB section of the JEE tutorial:
> http://java.sun.com/javaee/5/docs/tutorial/doc/JAXB5.html
> 
> -Chris
> 
> -----Original Message-----
> From: mattmadhavan [mailto:mattmadhavan@yahoo.com] 
> Sent: Tuesday, September 04, 2007 3:07 PM
> To: cxf-user@incubator.apache.org
> Subject: Help in annotating Java beans as paramater to a web service!
> 
> 
> Hello,
> Please bear with me, I am new to CXF. 
> 
> I am doing a Java first development and I have one webservice method
> called
> addProductInfo, which takes a paramter, ProductInfo. 
> 
> 
> @WebService(name = "ProductInfo",
>         targetNamespace = "http://vibes.contentmanagement")
> public interface IAddProductInfo extends Serializable {
> 	@WebMethod(operationName="addProductInfo",
> action="urn:addProductInfo")	
> 	@WebResult(name="return")
> 	public Integer
> addProductInfo(@WebParam(name="productInfo")BaseProduct
> product);
> }
> 
> My BaseProduct class is as follows:
> 
> public class BaseProduct extends BaseEntity {
> 
>     private String name = "";
>     private String description;
>     private float price;
>     private String keyword = "";
>     private String shortCode;
> }
> 
> All the fields are required except, keyword and short code! How do I
> annotate the webmethod and the individual fields on the BaseProduct
> class?
> 
> Can someone point me to right documentations.
> 
> Thanks
> Matt
> 
> 
> 
> 
> -- 
> View this message in context:
>
http://www.nabble.com/Help-in-annotating-Java-beans-as-paramater-to-a-we
> b-service%21-tf4379704.html#a12484583
> Sent from the cxf-user mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context:
http://www.nabble.com/Help-in-annotating-Java-beans-as-paramater-to-a-we
b-service%21-tf4379704.html#a12485143
Sent from the cxf-user mailing list archive at Nabble.com.


RE: Help in annotating Java beans as paramater to a web service!

Posted by mattmadhavan <ma...@yahoo.com>.
Hi Chris,
The first link you sent does n't seem to work. Can you re-send it?

My question is regardless of the underlying mapping, is there anyway to
JAX-WS annotate a JavaBean as opposed to a simple param? All the examples I
have seen so far only take simple params. Any example using a Java Bean as a
param having both optional and required a attributes will be appreciated.


Thanks
Matt



Christopher Moesel wrote:
> 
> Hi Matt,
> 
> If you're using the default data binding (JAXB 2.0), then you may want
> to check out JAXB's documentation on annotating classes.
> 
> For starter's, you can see Kohsuke's blog entry on using JAXB:
> http://weblogs.java.net/blog/kohsuke/archive/2005/02/using_jaxb_20_t.htm
> l
> 
> Then for all the gritty details on the possible annotations, check out
> the JAXB section of the JEE tutorial:
> http://java.sun.com/javaee/5/docs/tutorial/doc/JAXB5.html
> 
> -Chris
> 
> -----Original Message-----
> From: mattmadhavan [mailto:mattmadhavan@yahoo.com] 
> Sent: Tuesday, September 04, 2007 3:07 PM
> To: cxf-user@incubator.apache.org
> Subject: Help in annotating Java beans as paramater to a web service!
> 
> 
> Hello,
> Please bear with me, I am new to CXF. 
> 
> I am doing a Java first development and I have one webservice method
> called
> addProductInfo, which takes a paramter, ProductInfo. 
> 
> 
> @WebService(name = "ProductInfo",
>         targetNamespace = "http://vibes.contentmanagement")
> public interface IAddProductInfo extends Serializable {
> 	@WebMethod(operationName="addProductInfo",
> action="urn:addProductInfo")	
> 	@WebResult(name="return")
> 	public Integer
> addProductInfo(@WebParam(name="productInfo")BaseProduct
> product);
> }
> 
> My BaseProduct class is as follows:
> 
> public class BaseProduct extends BaseEntity {
> 
>     private String name = "";
>     private String description;
>     private float price;
>     private String keyword = "";
>     private String shortCode;
> }
> 
> All the fields are required except, keyword and short code! How do I
> annotate the webmethod and the individual fields on the BaseProduct
> class?
> 
> Can someone point me to right documentations.
> 
> Thanks
> Matt
> 
> 
> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Help-in-annotating-Java-beans-as-paramater-to-a-we
> b-service%21-tf4379704.html#a12484583
> Sent from the cxf-user mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Help-in-annotating-Java-beans-as-paramater-to-a-web-service%21-tf4379704.html#a12485143
Sent from the cxf-user mailing list archive at Nabble.com.


RE: Help in annotating Java beans as paramater to a web service!

Posted by Christopher Moesel <Ch...@avid.com>.
Hi Matt,

If you're using the default data binding (JAXB 2.0), then you may want
to check out JAXB's documentation on annotating classes.

For starter's, you can see Kohsuke's blog entry on using JAXB:
http://weblogs.java.net/blog/kohsuke/archive/2005/02/using_jaxb_20_t.htm
l

Then for all the gritty details on the possible annotations, check out
the JAXB section of the JEE tutorial:
http://java.sun.com/javaee/5/docs/tutorial/doc/JAXB5.html

-Chris

-----Original Message-----
From: mattmadhavan [mailto:mattmadhavan@yahoo.com] 
Sent: Tuesday, September 04, 2007 3:07 PM
To: cxf-user@incubator.apache.org
Subject: Help in annotating Java beans as paramater to a web service!


Hello,
Please bear with me, I am new to CXF. 

I am doing a Java first development and I have one webservice method
called
addProductInfo, which takes a paramter, ProductInfo. 


@WebService(name = "ProductInfo",
        targetNamespace = "http://vibes.contentmanagement")
public interface IAddProductInfo extends Serializable {
	@WebMethod(operationName="addProductInfo",
action="urn:addProductInfo")	
	@WebResult(name="return")
	public Integer
addProductInfo(@WebParam(name="productInfo")BaseProduct
product);
}

My BaseProduct class is as follows:

public class BaseProduct extends BaseEntity {

    private String name = "";
    private String description;
    private float price;
    private String keyword = "";
    private String shortCode;
}

All the fields are required except, keyword and short code! How do I
annotate the webmethod and the individual fields on the BaseProduct
class?

Can someone point me to right documentations.

Thanks
Matt




-- 
View this message in context:
http://www.nabble.com/Help-in-annotating-Java-beans-as-paramater-to-a-we
b-service%21-tf4379704.html#a12484583
Sent from the cxf-user mailing list archive at Nabble.com.