If you annotate the data object with XmlType and specify a namespace it
will put the data object in that namespace in the WSDL. However, with just
an XmlType annotation, the data object falls in the umbrella namespace of
the web service.

Basically, without explicitly specifying a namespace everything (the web
service, all data objects) falls into one namespace. This is very easily
recreatable, but I will whip up an example shortly.

tia,
rouble

On Wed, May 9, 2012 at 10:40 PM, Mark Streit <[email protected]> wrote:

> If your type classes are in different packages (and this is often the
> case), we have always done this,
>
> package *com.acme.book.services.dvo;*
>
> import javax.xml.bind.annotation.XmlAccessType;
> import javax.xml.bind.annotation.XmlAccessorType;
> import javax.xml.bind.annotation.XmlType;
>
> /**
>  * @project BookOrderManagerWS
>  * @filename Publisher.java
>  *
>  */
>
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "Publisher",* namespace="
> http://dvo.services.book.acme.com/";
> *)
> public class Publisher {
> ....
> ....
> .....
> }
>
> using the *namespace *attribute of the @XmlType annotation in our projects
> to insure the namespace and package names align and it has always worked.
>
> The generated XSDs wind up looking like this:
>
> <?xml version="1.0" encoding="utf-8"?><xs:schema xmlns:xs="
> http://www.w3.org/2001/XMLSchema"; xmlns:ns1="
> http://webservices.book.acme.com/"; *xmlns:tns="
> http://dvo.services.book.acme.com/"* *targetNamespace="
> http://dvo.services.book.acme.com/"* version="1.0">
> <xs:import namespace="http://webservices.book.acme.com/";
> schemaLocation="BookOrderManagerService_schema1.xsd"/>
> <xs:complexType name="BookOrder">
>    <xs:sequence>
>      <xs:element minOccurs="0" name="orderID" type="xs:string"/>
>      <xs:element name="orderType" type="xs:int"/>
>      <xs:element maxOccurs="unbounded" minOccurs="0" name="books"
> nillable="true" type="tns:Book"/>
>    </xs:sequence>
>  </xs:complexType>
> <xs:complexType name="Book">
>    <xs:sequence>
>      <xs:element minOccurs="0" name="bookID" type="xs:string"/>
>      <xs:element minOccurs="0" name="bookTitle" type="xs:string"/>
>      <xs:element minOccurs="0" name="authorName" type="xs:string"/>
>      <xs:element minOccurs="0" name="ISBN" type="xs:string"/>
>      <xs:element minOccurs="0" name="bookTypeCode" type="xs:string"/>
>      <xs:element minOccurs="0" name="bookPublisher" type="tns:Publisher"/>
>      <xs:element name="bookRetail" type="xs:float"/>
>      <xs:element name="bookCost" type="xs:float"/>
>      <xs:element name="pageCount" type="xs:int"/>
>    </xs:sequence>
>  </xs:complexType>
> *<xs:complexType name="Publisher">*
>    <xs:sequence>
>      <xs:element minOccurs="0" name="publisherKey" type="xs:string"/>
>      <xs:element minOccurs="0" name="publisherName" type="xs:string"/>
>      <xs:element name="publisherID" type="xs:int"/>
>      <xs:element minOccurs="0" name="publisherAddress" type="tns:Address"/>
>    </xs:sequence>
> </xs:complexType>
>
>
> Is this what you're looking for?
>
>
> On Wed, May 9, 2012 at 9:56 PM, Daniel Kulp <[email protected]> wrote:
>
> > On Tuesday, May 08, 2012 03:51:05 PM rouble wrote:
> > > CXF Gurus,
> > >
> > > If I have a java first web service:
> > >
> > > package com.example;
> > >
> > > @WebService
> > > FooWebService {
> > >     void updateItem(Item item);
> > > }
> > >
> > > Where Item lives in:
> > >
> > > package com.somewhere.else;
> > >
> > > public class Item {
> > > }
> > >
> > > If I deploy this web service, Item's namespace is the same as
> > > FooWebService's namespace which is "http://example.com";. Is there a
> > global
> > > config which causes the data objects to have their namespace based on
> > > their package?
> >
> > That should be the case.   At least if you put an @XmlType annotation on
> > it.
> > Can you whip up an example?
> >
> > Dan
> >
> >
> > > I know I can have a package-info.java file in the Item's directory that
> > > will override it's namespace - but I am wondering if there is a more
> > > convenient way of achieving this behavior globally?
> > >
> > > tia,
> > > rouble
> > --
> > Daniel Kulp
> > [email protected] - http://dankulp.com/blog
> > Talend Community Coder - http://coders.talend.com
> >
> >
>
>
> *Mark
> *
>

Reply via email to