You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Christian Schneider <ch...@die-schneider.net> on 2009/09/16 13:34:02 UTC

How do I write and test a sample?

Hi,

I currently try to create a new wsdl first example in response to a long 
standing jira issue. (https://issues.apache.org/jira/browse/CXF-52)

The example already works quite well with maven. I can simply define the 
dependencies in the pom and also directly test from the checkout folder.

For ant it seems to be more difficult. When I try to execute an ant 
build it complains about not finding the libs as they do not exist in 
the checkout folder. When I do a full build of the distribution module I 
can of course test after extracting the final zip. This of course 
creates a quite painfull long build / test cycle. Is there a way to make 
the ant build work directly in the checkout?

My other problem is that I want to add some dependencies to the wsdl 
first example (log4j and junit). How do I do this for the ant build? 
They do not seem to be copied to the lib folder when I add them to the 
pom.xml and do a maven build of distribution. Is there some special 
place where they are defined?

Greetings

Christian


Re: How do I write and test a sample?

Posted by Daniel Kulp <dk...@apache.org>.
On Fri September 18 2009 2:38:50 am Christian Schneider wrote:
> The following issues describe a way to read WSDLs from a maven repo or
> to write WSDLs to a maven repo.
> https://issues.apache.org/jira/browse/CXF-2276
> https://issues.apache.org/jira/browse/CXF-2275
> 
> So you can specifiy that the WSDL for client and server is simply read
> from the maven repo.
> 
> Btw. you can avoid using the WSDL at runtime. If you generate the code
> and configure your service like this in spring the WSDL is not necessary:
>     <jaxws:client id="customerService"
>         serviceName="customer:CustomerServiceService"
>         endpointName="customer:CustomerServiceEndpoint"
>         address="http://localhost:9090/CustomerServicePort"
>         serviceClass="com.example.customerservice.CustomerService">
>     </jaxws:client>
> 
> ServiceName and endpointName are arbitrary names. They only matter if
> someone tries to look at the generated wsdl with ?wsdl.

Just a point of note, NOT using the WSDL works fine MOST of the time, but not 
always.   There are definitely a bunch of cases where not using the wsdl 
causes problems.    The main two I know about are:

1) RPC/lit endpoints - if the targetnamespace for the operations is different 
than the service namespace, then you need the wsdl as that namespace isn't 
burned in anywhere.

2) If the wsdl has any policy requirements (like security-policy things), you 
obviously need the wsdl.

Dan



> 
> Greetings
> 
> Christian
> 
> Glen Mazza schrieb:
> > Normally, you're creating the SOAP client for somebody else's web
> > service, so, yes, you'll have the code generation within the client's
> > pom.  My SOAP-client only example does that:
> > http://www.jroller.com/gmazza/entry/creating_a_soap_client_with
> >
> > Creating a special jar for the wsdl-first example was just a simplicity
> > issue so as not to duplicate the JAX-WS code generation for both service
> > and client.  It's not perfect; namely, the *Service.java file will still
> > hardcode a specific default reference to the WSDL file on the local
> > machine, not helpful if the client and service are on different machines.
> >  To increase portability, I was thinking of somehow including the WSDL in
> > the JAR file and having the *Service.java file point to *that* WSDL if
> > possible. Still, for a simple tutorial the current method works.
> >
> > Glen
> >
> > Christian Schneider wrote:
> >> So I think my problem is solved but thanks for the nice example. I have
> >> a question about the example. You create code from the wsdl into a
> >> special jar. Wouldn´t it be easier to include the code generation into
> >> the client and the server pom?
> >>
> >> Greetings
> >>
> >> Christian
> 

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

Re: How do I write and test a sample?

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

perhaps you can use what implemented some days ago.

The following issues describe a way to read WSDLs from a maven repo or 
to write WSDLs to a maven repo.
https://issues.apache.org/jira/browse/CXF-2276
https://issues.apache.org/jira/browse/CXF-2275

So you can specifiy that the WSDL for client and server is simply read 
from the maven repo.

Btw. you can avoid using the WSDL at runtime. If you generate the code 
and configure your service like this in spring the WSDL is not necessary:
    <jaxws:client id="customerService"
        serviceName="customer:CustomerServiceService"
        endpointName="customer:CustomerServiceEndpoint"
        address="http://localhost:9090/CustomerServicePort"
        serviceClass="com.example.customerservice.CustomerService">
    </jaxws:client>

ServiceName and endpointName are arbitrary names. They only matter if 
someone tries to look at the generated wsdl with ?wsdl.

Greetings

Christian


Glen Mazza schrieb:
> Normally, you're creating the SOAP client for somebody else's web service,
> so, yes, you'll have the code generation within the client's pom.  My
> SOAP-client only example does that:
> http://www.jroller.com/gmazza/entry/creating_a_soap_client_with
>
> Creating a special jar for the wsdl-first example was just a simplicity
> issue so as not to duplicate the JAX-WS code generation for both service and
> client.  It's not perfect; namely, the *Service.java file will still
> hardcode a specific default reference to the WSDL file on the local machine,
> not helpful if the client and service are on different machines.  To
> increase portability, I was thinking of somehow including the WSDL in the
> JAR file and having the *Service.java file point to *that* WSDL if possible. 
> Still, for a simple tutorial the current method works.
>
> Glen
>
>
> Christian Schneider wrote:
>   
>> So I think my problem is solved but thanks for the nice example. I have 
>> a question about the example. You create code from the wsdl into a 
>> special jar. Wouldn´t it be easier to include the code generation into 
>> the client and the server pom?
>>
>> Greetings
>>
>> Christian
>>
>>     
>
>   


Re: How do I write and test a sample?

Posted by Glen Mazza <gl...@gmail.com>.
Normally, you're creating the SOAP client for somebody else's web service,
so, yes, you'll have the code generation within the client's pom.  My
SOAP-client only example does that:
http://www.jroller.com/gmazza/entry/creating_a_soap_client_with

Creating a special jar for the wsdl-first example was just a simplicity
issue so as not to duplicate the JAX-WS code generation for both service and
client.  It's not perfect; namely, the *Service.java file will still
hardcode a specific default reference to the WSDL file on the local machine,
not helpful if the client and service are on different machines.  To
increase portability, I was thinking of somehow including the WSDL in the
JAR file and having the *Service.java file point to *that* WSDL if possible. 
Still, for a simple tutorial the current method works.

Glen


Christian Schneider wrote:
> 
> So I think my problem is solved but thanks for the nice example. I have 
> a question about the example. You create code from the wsdl into a 
> special jar. Wouldn´t it be easier to include the code generation into 
> the client and the server pom?
> 
> Greetings
> 
> Christian
> 

-- 
View this message in context: http://www.nabble.com/How-do-I-write-and-test-a-sample--tp25470529p25501102.html
Sent from the cxf-dev mailing list archive at Nabble.com.


Re: How do I write and test a sample?

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

I have found out that the common_build.xml file from the cxf samples 
already was prepared for a maven like directory structure. So I was able 
to simply rename my directories to src/main/java and src/main/resources 
and it worked. Dan also explained that I have to add extra dependencies 
to the pom of the distribution module. They are then available to the 
examples for ant builds.

So I think my problem is solved but thanks for the nice example. I have 
a question about the example. You create code from the wsdl into a 
special jar. Wouldn´t it be easier to include the code generation into 
the client and the server pom?

Greetings

Christian


Glen Mazza schrieb:
> My WSDL-first example provides both a Maven- and an Ant-way to create the
> project  (See Step #3).  The Ant script closely follows the Maven standard
> directory layout and can be used interchangably with the Maven pom files. 
> It's also in beautifully fluent, error-free German for you:  
>
> http://www.jroller.com/gmazza/entry/wsdl_first_webservices_mit_apache
>
> If helpful for you of course feel free to use.
>
> HTH,
> Glen
>
>
> Christian Schneider wrote:
>   
>> So what I would prefer 
>> is some way to do this that follows closely the default build process of 
>> cxf.
>>
>>     
>
>   


Re: How do I write and test a sample?

Posted by Glen Mazza <gl...@gmail.com>.
My WSDL-first example provides both a Maven- and an Ant-way to create the
project  (See Step #3).  The Ant script closely follows the Maven standard
directory layout and can be used interchangably with the Maven pom files. 
It's also in beautifully fluent, error-free German for you:  

http://www.jroller.com/gmazza/entry/wsdl_first_webservices_mit_apache

If helpful for you of course feel free to use.

HTH,
Glen


Christian Schneider wrote:
> 
> So what I would prefer 
> is some way to do this that follows closely the default build process of 
> cxf.
> 

-- 
View this message in context: http://www.nabble.com/How-do-I-write-and-test-a-sample--tp25470529p25480288.html
Sent from the cxf-dev mailing list archive at Nabble.com.


Re: How do I write and test a sample?

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

thanks for the info. I could perhaps define my own goal to not interfere 
with the normal install process. There is even a copy-dependencies 
plugin for maven that would copy all dependencies. The problem though is 
that the install process of distribution already seems to copy certain 
libs. If I do this differently then I will have the problem that the 
libs I test with are perhaps not the ones that get copied with the 
default mvn install from the distribution module. So what I would prefer 
is some way to do this that follows closely the default build process of 
cxf.

Greetings

Christian


Eamonn Dwyer schrieb:
> Hi Christian
> for part 1 of the issue could you do something like this to your pom.xml to copy the libs prior to building/running the demo.
>
>        <plugin>
>                 <artifactId>maven-antrun-plugin</artifactId>
>                 <executions>
>                     <execution>
>                         <id>copylibs</id>
>                         <phase>install</phase>
>                         <goals>
>                             <goal>run</goal>
>                         </goals>
>                         <configuration>
>                             <tasks>
>                                <copy 
>                                    file="cxf-bundle.jar"
>                                    tofile="${checkout.folder}/cxf-bundle.jar">
>                                </copy>
>                                ....
>                             </tasks>
>                         </configuration>
>                     </execution>
>                 </executions>
>             </plugin>
>
> To build and run the demo you could use the tasks defined in
> http://ant.apache.org/manual/CoreTasks/ant.html
>
> Hope this helps
> Eamonn
>
>   
>> Date: Wed, 16 Sep 2009 13:34:02 +0200
>> From: chris@die-schneider.net
>> To: dev@cxf.apache.org
>> Subject: How do I write and test a sample?
>>
>> Hi,
>>
>> I currently try to create a new wsdl first example in response to a long 
>> standing jira issue. (https://issues.apache.org/jira/browse/CXF-52)
>>
>> The example already works quite well with maven. I can simply define the 
>> dependencies in the pom and also directly test from the checkout folder.
>>
>> For ant it seems to be more difficult. When I try to execute an ant 
>> build it complains about not finding the libs as they do not exist in 
>> the checkout folder. When I do a full build of the distribution module I 
>> can of course test after extracting the final zip. This of course 
>> creates a quite painfull long build / test cycle. Is there a way to make 
>> the ant build work directly in the checkout?
>>
>> My other problem is that I want to add some dependencies to the wsdl 
>> first example (log4j and junit). How do I do this for the ant build? 
>> They do not seem to be copied to the lib folder when I add them to the 
>> pom.xml and do a maven build of distribution. Is there some special 
>> place where they are defined?
>>
>> Greetings
>>
>> Christian
>>
>>     
>
> _________________________________________________________________
> Get 30 Free Emoticons for your Windows Live Messenger
> http://www.livemessenger-emoticons.com/funfamily/en-ie/
>   


RE: How do I write and test a sample?

Posted by Eamonn Dwyer <ea...@hotmail.com>.
Hi Christian
for part 1 of the issue could you do something like this to your pom.xml to copy the libs prior to building/running the demo.

       <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copylibs</id>
                        <phase>install</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                               <copy 
                                   file="cxf-bundle.jar"
                                   tofile="${checkout.folder}/cxf-bundle.jar">
                               </copy>
                               ....
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

To build and run the demo you could use the tasks defined in
http://ant.apache.org/manual/CoreTasks/ant.html

Hope this helps
Eamonn

> Date: Wed, 16 Sep 2009 13:34:02 +0200
> From: chris@die-schneider.net
> To: dev@cxf.apache.org
> Subject: How do I write and test a sample?
> 
> Hi,
> 
> I currently try to create a new wsdl first example in response to a long 
> standing jira issue. (https://issues.apache.org/jira/browse/CXF-52)
> 
> The example already works quite well with maven. I can simply define the 
> dependencies in the pom and also directly test from the checkout folder.
> 
> For ant it seems to be more difficult. When I try to execute an ant 
> build it complains about not finding the libs as they do not exist in 
> the checkout folder. When I do a full build of the distribution module I 
> can of course test after extracting the final zip. This of course 
> creates a quite painfull long build / test cycle. Is there a way to make 
> the ant build work directly in the checkout?
> 
> My other problem is that I want to add some dependencies to the wsdl 
> first example (log4j and junit). How do I do this for the ant build? 
> They do not seem to be copied to the lib folder when I add them to the 
> pom.xml and do a maven build of distribution. Is there some special 
> place where they are defined?
> 
> Greetings
> 
> Christian
> 

_________________________________________________________________
Get 30 Free Emoticons for your Windows Live Messenger
http://www.livemessenger-emoticons.com/funfamily/en-ie/

Re: How do I write and test a sample?

Posted by Daniel Kulp <dk...@apache.org>.
Christian,

At one point, if you do a full "distribution" build, the common_build.xml in 
the src/main/release/sample detected that and then the ant builds would start 
working in the src/main/release/samples dir.   Thus, it kind of allows 
building/testing sample in the src tree, but you do have to build the kit 
once.

If you look in the common_build.xml, you'll see a place where it searches for 
srcbuild_env.ant.   That file is build from a mvn install in distribution.

Hope that helps.

Dan



On Wed September 16 2009 7:34:02 am Christian Schneider wrote:
> Hi,
> 
> I currently try to create a new wsdl first example in response to a long
> standing jira issue. (https://issues.apache.org/jira/browse/CXF-52)
> 
> The example already works quite well with maven. I can simply define the
> dependencies in the pom and also directly test from the checkout folder.
> 
> For ant it seems to be more difficult. When I try to execute an ant
> build it complains about not finding the libs as they do not exist in
> the checkout folder. When I do a full build of the distribution module I
> can of course test after extracting the final zip. This of course
> creates a quite painfull long build / test cycle. Is there a way to make
> the ant build work directly in the checkout?
> 
> My other problem is that I want to add some dependencies to the wsdl
> first example (log4j and junit). How do I do this for the ant build?
> They do not seem to be copied to the lib folder when I add them to the
> pom.xml and do a maven build of distribution. Is there some special
> place where they are defined?
> 
> Greetings
> 
> Christian
> 

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