Thanks a lot for you advice Geert,

In general I'm moving away from Spring and try to minimize its use. I think
it brings on it's own little world these days which I do not want. It might
of course be an option if there is no other way. It seems like there must be
a way to tell CXF what wsdl to return without using Spring but plain old
java. Isn't there?

/Bengt



2011/10/28 Geert Schuring <[email protected]>

> Bengt,
>
> If you're creating the CXF endpoint in Spring you could use the following
> example:
>
> 1) <jaxws:endpoint
> 2)    id="classImpl"
> 3)    wsdlLocation="wsdl/helloService.wsdl"
> 4)    implementor="org.apache.cxf.jaxws.service.Hello"
> 5)    address="http://localhost:8080/test";
>
> Here you see on line 3 that the endpoint uses a concrete WSDL file bundled
> with your application rather then reconstructing a WSDL using the
> annotations on the SEI. Restrictions and regex patterns in the WSDL cannot
> be translated to annotations on your SEI, which is why the reconstructed
> WSDL does not contain them. The restrictions are lost in the transformation
> to and from JAX-WS and JAX-B. By packaging the original WSDL with your
> implementation the CXF endpoint can simply serve the original WSDL to
> clients that call the something?wsdl url, and use your supplied
> implementation (line 4) to handle the incoming messages.
>
> BTW, you can also enable schema validation on the endpoint. See
>
> http://cxf.apache.org/faq.html#FAQ-HowcanIturnonschemavalidationforjaxwsendpoint%3F
>
> Good luck!
> Geert Schuring.
>
> Links:
> http://cxf.apache.org/docs/jax-ws-configuration.html
>
>
>
> 2011/10/28 Bengt Rodehav <[email protected]>
>
> > Hello Geert. Thanks for your answer.
> >
> > We use wsdl2java to generate an interface (the SEI) that we then
> implement.
> > Sounds like the way you describe it. Is there an alternate way to do this
> > that will preserve the wsdl? Or is there an easy way to just intercept
> the
> > wsdl query and make sure that the original wsdl and xsd's are returned?
> >
> > /Bengt
> >
> > 2011/10/26 Geert Schuring <[email protected]>
> >
> > > Bengt,
> > >
> > > How do you create the CXF endpoint? The behaviour you describe is
> exactly
> > > what I would expect when you generate the SEI from a WSDL document and
> > then
> > > use the SEI to create a CXF endpoint. The SEI will contain JAX-B
> > annotated
> > > types and CXF will reconstruct the WSDL at runtime based on the JAX-WS
> > and
> > > JAX-B annotations on your interface and classes, instead of using the
> > WSDL
> > > you used at compile-time.
> > >
> > > Kind regards,
> > > Geert Schuring.
> > >
> > > 2011/10/3 Bengt Rodehav <[email protected]>
> > >
> > > > I've done some more testing. It seems like restrictions on strings
> that
> > > use
> > > > enumerations are preserved but that's really the only kind of
> "strict"
> > > > typing that seems to be preserved when querying the WSDL in runtime.
> > > Also,
> > > > the documentation is lost.
> > > >
> > > > Using this type definition
> > > >
> > > >  <simpleType name="PositionType">
> > > >    <annotation>
> > > >      <documentation>
> > > >        L = Long (Innehavd/inlånad)
> > > >        S = Short (Utfärdad/utlånad)
> > > >      </documentation>
> > > >    </annotation>
> > > >    <restriction base="string">
> > > >      <enumeration value="L" />
> > > >      <enumeration value="S" />
> > > >    </restriction>
> > > >  </simpleType>
> > > >
> > > > The enumeration is preserved but the documentation is lost. The below
> > > will
> > > > simply be transformed to a "xs:string" in the runtime wsdl - no
> length
> > > > information is preserved:
> > > >
> > > >  <simpleType name="SecurityId">
> > > >    <restriction base="string">
> > > >      <minLength value="0"></minLength>
> > > >      <maxLength value="12"></maxLength>
> > > >    </restriction>
> > > >  </simpleType>
> > > >
> > > > The below will be transformed to a "xs:decimal" without information
> > about
> > > > no
> > > > of digits and decimals:
> > > >
> > > >  <simpleType name="SecurityCount">
> > > >    <restriction base="decimal">
> > > >      <totalDigits value="19" />
> > > >      <fractionDigits value="6" />
> > > >    </restriction>
> > > >  </simpleType>
> > > >
> > > >
> > > > The following will be transformed into a "xs:int" without information
> > > about
> > > > maximum no of digits:
> > > >
> > > >  <simpleType name="AccountId">
> > > >    <restriction base="nonNegativeInteger">
> > > >      <maxInclusive value="99999999" />
> > > >    </restriction>
> > > >  </simpleType>
> > > >
> > > > I think this is serious. Ideally CXF should return the wsdl I started
> > out
> > > > with but containing the correct runtime bindings regarding e g
> address
> > > and
> > > > port. It seems to me that CXF extracts the information that it needs
> > for
> > > > itself and excludes the rest. But the wsdl query's purpose is not for
> > the
> > > > CXF server but for the clients. Clients could be implemented using
> any
> > > > technique which is why all available metadata should be provided.
> Also,
> > > > wsdl
> > > > is a perfect place for documentation but it's all removed. I don't
> > really
> > > > understand why CXF doesn't answer with the original wsdl when "wsdl
> > > first"
> > > > is used.
> > > >
> > > > /Bengt
> > > >
> > > > 2011/10/3 Bengt Rodehav <[email protected]>
> > > >
> > > > > I don't promise anything since we're pretty much under pressure
> here
> > > (as
> > > > > always I guess). But I'll try,
> > > > >
> > > > > /Bengt
> > > > >
> > > > >
> > > > > 2011/10/3 Daniel Kulp <[email protected]>
> > > > >
> > > > >>
> > > > >> Any chance you could file a test case?   We do have some tests to
> > make
> > > > >> sure
> > > > >> the annotations and stuff are preserved.  However, they may be for
> > > > >> external
> > > > >> xsd's, not schemas embedded in the wsdl.   I'd have to dig in more
> > to
> > > > >> check
> > > > >> that, but a test case would be great.
> > > > >>
> > > > >> Dan
> > > > >>
> > > > >>
> > > > >> On Saturday, October 01, 2011 10:08:42 AM Bengt Rodehav wrote:
> > > > >> > Hello,
> > > > >> >
> > > > >> > We're using CXF 2.4.2 to provide a web service API to a legacy
> > > > >> application.
> > > > >> > We are in the process of increasing the quality of the API in a
> > > number
> > > > >> of
> > > > >> > ways.
> > > > >> >
> > > > >> > First, we are typing the interface more strictly. E g instead of
> > > > >> specifying
> > > > >> > that a value is a string, we say that it's exactly one character
> > > long
> > > > >> and
> > > > >> > also enumerate it's valid values. We also try to add
> documentation
> > > to
> > > > >> the
> > > > >> > WSDL. The following is a typical case:
> > > > >> >
> > > > >> > <xs:simpleType name="MyType">
> > > > >> > <xs:annotation>
> > > > >> >  <xs:documentation>
> > > > >> > A = ...
> > > > >> > B = ...
> > > > >> >  C = ...
> > > > >> > </xs:documentation>
> > > > >> > </xs:annotation>
> > > > >> >  <xs:restriction base="xs:string">
> > > > >> > <xs:pattern value="A|B|C" />
> > > > >> >  </xs:restriction>
> > > > >> > </xs:simpleType>
> > > > >> >
> > > > >> > However, even if we feed the above WSDL to CXF (we use WSDL
> > first),
> > > in
> > > > >> > runtime when asking for the WSDL (using ...?wsdl), the above
> > > > information
> > > > >> is
> > > > >> > gone. The type is simply a string and the documentation is gone.
> > > > >> >
> > > > >> > Why is this? Is it a bug? What is best practice regarding strict
> > > > >> interfaces
> > > > >> > and documentation using CXF?
> > > > >> >
> > > > >> > /Bengt
> > > > >> --
> > > > >> Daniel Kulp
> > > > >> [email protected]
> > > > >> http://dankulp.com/blog
> > > > >> Talend - http://www.talend.com
> > > > >>
> > > > >
> > > > >
> > > >
> > >
> >
>

Reply via email to