You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Jens Meuller <su...@googlemail.com> on 2009/09/23 11:09:43 UTC

WSDL2Java and javax.xml.ws.Service => Why is WSDL Required for Instanciation?

Hello,

I would be kind to help me with my question. As the CFX Website states in
the (WSDL2Java) "Consumer" examples, for a Consumer it is always necessary
to have the "Original" WSDL File available from whicht the Code was
generated. This WSDL is either passed (see cited text below) via the
Parametered-Constructor or seems to be implicitly called at the original
adress if the Service ist instanciated via the default Constructor. (The
Code generated by CXF WSDL2Java seems to generate a static member with the
URL and then uses the parametered Constructor for Instanciation...)

1. Isn't that an enourmous waste of resources if the WSDL file is called for
every (or at least the first) invocation (in case this url is cached
somehow)?
2. What is the idea behind the retrieval of the WSDL file? As the client
Code has already been generated via WSDL2Java any change in the WSDL file
can't be "integrated" in the code anymore. The code is static and compiled
and has all the information needed to run properly(?) Why is the WSDL file
useful here and retrieved at all?

I spent a lot of thinking about that but was not able to figure this out.

Thank you very much!
Jens


#### Cited from: http://cwiki.apache.org/CXF20DOC/developing-a-consumer.html####


public class ServiceName extends javax.xml.ws.Service
{
  ...
  public ServiceName(URL wsdlLocation, QName serviceName) { }

  public ServiceName() { }

  public Greeter getPortName() { }
  .
  .
  .
}

 The ServiceName class in
Example2<http://cwiki.apache.org/CXF20DOC/developing-a-consumer.html#DevelopingaConsumer-Example2>defines
the following methods:

   - Constructor methods - the following forms of constructor are defined:
      - *ServiceName*(URL *wsdlLocation*, QName *serviceName*) constructs a
      service object based on the data in the *serviceName* service in the
      WSDL contract that is obtainable from *wsdlLocation*.
      - *ServiceName*() is the default constructor, which constructs a
      service object based on the service name and WSDL contract that were
      provided at the time the stub code was generated (for example,
when running
      the CeltiXfire wsdl2java command). Using this constructor
presupposes that
      the WSDL contract remains available at its original location.

##########

Re: WSDL2Java and javax.xml.ws.Service => Why is WSDL Required for Instanciation?

Posted by Benson Margulies <bi...@gmail.com>.
If you don't have the WSDL, you don't have the parameter names, and possibly
other customizations that are only represented in the WSDL.

On Wed, Sep 23, 2009 at 5:09 AM, Jens Meuller <su...@googlemail.com>wrote:

> Hello,
>
> I would be kind to help me with my question. As the CFX Website states in
> the (WSDL2Java) "Consumer" examples, for a Consumer it is always necessary
> to have the "Original" WSDL File available from whicht the Code was
> generated. This WSDL is either passed (see cited text below) via the
> Parametered-Constructor or seems to be implicitly called at the original
> adress if the Service ist instanciated via the default Constructor. (The
> Code generated by CXF WSDL2Java seems to generate a static member with the
> URL and then uses the parametered Constructor for Instanciation...)
>
> 1. Isn't that an enourmous waste of resources if the WSDL file is called
> for
> every (or at least the first) invocation (in case this url is cached
> somehow)?
> 2. What is the idea behind the retrieval of the WSDL file? As the client
> Code has already been generated via WSDL2Java any change in the WSDL file
> can't be "integrated" in the code anymore. The code is static and compiled
> and has all the information needed to run properly(?) Why is the WSDL file
> useful here and retrieved at all?
>
> I spent a lot of thinking about that but was not able to figure this out.
>
> Thank you very much!
> Jens
>
>
> #### Cited from:
> http://cwiki.apache.org/CXF20DOC/developing-a-consumer.html####
>
>
> public class ServiceName extends javax.xml.ws.Service
> {
>  ...
>  public ServiceName(URL wsdlLocation, QName serviceName) { }
>
>  public ServiceName() { }
>
>  public Greeter getPortName() { }
>  .
>  .
>  .
> }
>
>  The ServiceName class in
> Example2<
> http://cwiki.apache.org/CXF20DOC/developing-a-consumer.html#DevelopingaConsumer-Example2
> >defines
> the following methods:
>
>   - Constructor methods - the following forms of constructor are defined:
>      - *ServiceName*(URL *wsdlLocation*, QName *serviceName*) constructs a
>      service object based on the data in the *serviceName* service in the
>      WSDL contract that is obtainable from *wsdlLocation*.
>      - *ServiceName*() is the default constructor, which constructs a
>      service object based on the service name and WSDL contract that were
>      provided at the time the stub code was generated (for example,
> when running
>      the CeltiXfire wsdl2java command). Using this constructor
> presupposes that
>      the WSDL contract remains available at its original location.
>
> ##########
>

Re: WSDL2Java and javax.xml.ws.Service => Why is WSDL Required for Instanciation?

Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Jens,

you can instantiate a service without a wsdl at runtime. There are some 
case though where some information only is present in the wsdl.
I have reworked the wsdl first example on trunk. There I show how to 
instantiate the service without using the wsdl:
svn co 
http://svn.apache.org/repos/asf/cxf/trunk/distribution/src/main/release/samples/wsdl_first/

Dan explained the cases where the wsdl is needed in a thread on the dev 
list below:
http://www.nabble.com/Re%3A-How-do-I-write-and-test-a-sample--p25510778.html

Greetings

Christian


Jens Meuller schrieb:
> Hello,
>
> I would be kind to help me with my question. As the CFX Website states in
> the (WSDL2Java) "Consumer" examples, for a Consumer it is always necessary
> to have the "Original" WSDL File available from whicht the Code was
> generated. This WSDL is either passed (see cited text below) via the
> Parametered-Constructor or seems to be implicitly called at the original
> adress if the Service ist instanciated via the default Constructor. (The
> Code generated by CXF WSDL2Java seems to generate a static member with the
> URL and then uses the parametered Constructor for Instanciation...)
>
> 1. Isn't that an enourmous waste of resources if the WSDL file is called for
> every (or at least the first) invocation (in case this url is cached
> somehow)?
> 2. What is the idea behind the retrieval of the WSDL file? As the client
> Code has already been generated via WSDL2Java any change in the WSDL file
> can't be "integrated" in the code anymore. The code is static and compiled
> and has all the information needed to run properly(?) Why is the WSDL file
> useful here and retrieved at all?
>
> I spent a lot of thinking about that but was not able to figure this out.
>
> Thank you very much!
> Jens
>
>
> #### Cited from: http://cwiki.apache.org/CXF20DOC/developing-a-consumer.html####
>
>
> public class ServiceName extends javax.xml.ws.Service
> {
>   ...
>   public ServiceName(URL wsdlLocation, QName serviceName) { }
>
>   public ServiceName() { }
>
>   public Greeter getPortName() { }
>   .
>   .
>   .
> }
>
>  The ServiceName class in
> Example2<http://cwiki.apache.org/CXF20DOC/developing-a-consumer.html#DevelopingaConsumer-Example2>defines
> the following methods:
>
>    - Constructor methods - the following forms of constructor are defined:
>       - *ServiceName*(URL *wsdlLocation*, QName *serviceName*) constructs a
>       service object based on the data in the *serviceName* service in the
>       WSDL contract that is obtainable from *wsdlLocation*.
>       - *ServiceName*() is the default constructor, which constructs a
>       service object based on the service name and WSDL contract that were
>       provided at the time the stub code was generated (for example,
> when running
>       the CeltiXfire wsdl2java command). Using this constructor
> presupposes that
>       the WSDL contract remains available at its original location.
>
> ##########
>
>   


-- 

Christian Schneider
---
http://www.liquid-reality.de


Re: WSDL2Java and javax.xml.ws.Service => Why is WSDL Required for Instanciation?

Posted by Daniel Kulp <dk...@apache.org>.
On Wed September 23 2009 5:09:43 am Jens Meuller wrote:
> Hello,
> 
> I would be kind to help me with my question. As the CFX Website states in
> the (WSDL2Java) "Consumer" examples, for a Consumer it is always necessary
> to have the "Original" WSDL File available from whicht the Code was
> generated. This WSDL is either passed (see cited text below) via the
> Parametered-Constructor or seems to be implicitly called at the original
> adress if the Service ist instanciated via the default Constructor. (The
> Code generated by CXF WSDL2Java seems to generate a static member with the
> URL and then uses the parametered Constructor for Instanciation...)
> 
> 1. Isn't that an enourmous waste of resources if the WSDL file is called
>  for every (or at least the first) invocation (in case this url is cached
>  somehow)? 

The WSDL is cached, so it is a first client creation hit.   That said, 
internally, we need schema for various reasons so if the WSDL is not used (no 
schema provided), we have JAXB create a Schema for us so the end result may be 
about the same if wsdl is used or not.  (except for possibly delays obtaining 
the wsdl like via https or slow connections or similar)


> 2. What is the idea behind the retrieval of the WSDL file? 

Not everything in the wsdl is generated into code per jaxws spec.   The 
primary missing piece is that actual endpoint URL.   No where in the generated 
code is the actual URL to communicate with.      


> As the client
> Code has already been generated via WSDL2Java any change in the WSDL file
> can't be "integrated" in the code anymore. The code is static and compiled
> and has all the information needed to run properly(?) Why is the WSDL file
> useful here and retrieved at all?

There are others cases as well.   RPC/Lit has issues if operation namespaces 
don't match the service namespace (rare).   WSDL's with policies in them (like 
security policies and mtom and ws-addressing and such) also don't result in 
the policies being output into the generated code.   Thus, the WSDL is needed 
for them.      Policies are the big one really.   You COULD update a security 
policy or turn on ws-addressing or something in the wsdl and not have to 
regenerate the code.   


-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog