Srini,

Lets say your code is in package com.srini.myapp and below. There will be a
folder somewhere that contains the 'com' folder which contains the 'srini'
folder and so forth. Since you are using Eclipse, this folder (the one
containing 'com') will be one of the source folders you configure in the
project properties. You choose "java classpath" in the list at the left of
the properties box and then select the leftmost tab to configure the
sources.

Now, lets futher say your generated code is in packages below
com.ibm.webservice. You have two choices:

1) Put the generated code in the same folder space as your own source. That
means that you end up with both 'srini' and 'ibm' folders in the 'com'
folder mentioned in the paragraph above. Under the 'ibm' folder there is a
'webservice' folder and all the generated source is below that.

2) Another way to do it works pretty well. You put a 'src' folder in the
root of your Eclipse project. The 'com.srini.myapp' source code goes under
'src' and you configure (as described above) Eclipse so that 'src' is a
source folder. Then you make a 'generated-src' folder in the root of the
same Eclipse project (next to the 'src' folder) and put all the generated
code in it. That means 'com' is under 'generated-src' and 'ibm' is under
'com' and so forth with the .java files in this source tree. Then you
configure Eclipse so that 'generated-src' is an additional source folder.
With this method, there are two source folders.

After either of these, you will need to clean and rebuild the entire
project. Eclipse has an option to do this under the 'project' menu.

One way to check whether you got it all done right, after the rebuild, is to
go to one of your own source java files that references one of the generated
classes. Put the cursor on the name of the generated class or a method in
that class and press F3. (You can hold down the Ctrl button and click on the
same name or method with the mouse to do the same thing.) Eclipse should
open the generated source file when you do this.

One further thing I do helps avoid a common mistake. I go into the Windows
file system and set all the generated source files to read-only. This makes
it so that Eclipse lets you know if you are trying to change one of the
generated files and save the change. Since you will probably regenerate now
and then, its not a good idea to make any changes. (I actually set up the
process that generates the classes so they are changed to read-write before
generation and end up read-only afterwards. I do that in an ant script.)

On 9/19/07, srini <[EMAIL PROTECTED]> wrote:
>
> Hi Lee,
>
> Great,  thanks for reply. I appreciate it.  When I tried to move generated
> code to same disk space I am writing I got an errors as generated packages
> are not recognized as they reflect service providers structure, from your
> reply it seems like I will have edit that code.
>
> I use Eclipse 3.2, what do you mean by 4th point (adding source code to
> project), do you mean create new classes and copy the code from generated
> files?
>
> Thanks in advance.
>
> Regards,
> Srinis
>
> ----- Original Message ----
> From: Lee Meador <[EMAIL PROTECTED]>
> To: [email protected]
> Sent: Wednesday, September 19, 2007 2:57:16 PM
> Subject: Re: [xfire-user] Consuming services from different application
>
> The generated code has to be on the classpath when you compile the code
> that uses it.
>
> Some alternatives are to:
>
> 1) compile the generated code and put it into a jar, which goes on the
> compile and runtime classpaths.
> 2) move the generated code to the same disk folder space as the code you
> are writing.
> 3) add to the classpath to point to wherever the generated code is
> 4) if you are in an IDE like Eclipse or Netbeans (or whatever) there is a
> way to add the generated source code to your project
> 5) if you are using maven to do the build you want to use the xfire plugin
> to generate the code and add it to the build path\
>
> Thanks.
>
> -- Lee
>
> On 9/18/07, srinivas kamisetty <[EMAIL PROTECTED]> wrote:
> >
> > Hello All,
> >
> > I am beginning to pick up on xfire. I created my first web service in
> > ¡°Application A(Service providing application¡±)  with java class
> > User.java and implentation class UserImpl.java and was able to test it
> > following Tomek's input with success, so far good. I feel like I am almost
> > there.  All my web service does is return a simple string that it gets.
> >
> > Now to the part of consuming the service.  I have to pass this string
> > from different ¡°Application B (Service consuming application)¡± . I
> > generated code using xFire plugin in Application B that generated following
> > classes.
> >
> > 1. User.java
> >  2. UserImpl.java
> > 3. UserClient.java
> > 4. UserPortType.java
> >  5. UserResponse.java
> > 6. ObjectFactory.java
> > 7. package-info.java
> >
> > Here is the problem, ok I downloaded all the above files to folder
> > called " com.soa" in application B and to default package.  All I need
> > to do now is just pass a string to Application A and get it back. I want try
> > something like 'User.getMeString ("Srini");
> >
> > He is the first probelm, as soon as downloaded above file thru plugin ,
> > it downloaded with same package declarations as in Applcation A. But my
> > client application B doesn't show any errors.  I tried to use above
> > classes in my action classes I get errors as my Application B doesn¡¯t
> > recognize any of the above classes. My idea was to do something like
> > following in my action class to import package where I have above classes.
> > When I downloaded to com.soa, it created com.soa*.com.cma.soa *(the bold
> > part is from Application A, do not why that happens)
> >
> > My plan is to do to import above package into my struts action class so
> > I can do something like import com.soa*.com.cma.soa.*; *to get access to
> > above classes. But I get error saying the package doesn¡¯t exist.
> >
> >  So my questions are.  How do I use generated classes in my consumer
> > application (Application B) to consume and how can I access those classes.
> >  If anyone  has sample code to pass a string to a service (of different
> > application)  and get it back and how to make generated classes
> > available to consuming application I will appreciate it very much.
> >
> > As of now it seems like it is very easy to generate java classes from
> > wsdl if you give url location but it seems like your consuming application
> > doesn't recognize any of those as generated classes still have package
> > declaration from service provider where as consuming app can't recognize
> > those packages.
> >
> > Sorry for long text, I am new to xFire and web services. Hope it all
> > make sense.
> >
> > Regards,
> >  Srini
> >
> >
> > ------------------------------
> > Looking for a deal? Find great prices on flights and 
> > hotels<http://us.rd.yahoo.com/evt=47094/*http://farechase.yahoo.com/;_ylc=X3oDMTFicDJoNDllBF9TAzk3NDA3NTg5BHBvcwMxMwRzZWMDZ3JvdXBzBHNsawNlbWFpbC1uY20->with
> >  Yahoo! FareChase.
> >
> >
>
>
> --
> -- Lee Meador
> Sent from gmail. My real email address is lee AT leemeador.com
>
>
> ------------------------------
> Looking for a deal? Find great prices on flights and 
> hotels<http://us.rd.yahoo.com/evt=47094/*http://farechase.yahoo.com/;_ylc=X3oDMTFicDJoNDllBF9TAzk3NDA3NTg5BHBvcwMxMwRzZWMDZ3JvdXBzBHNsawNlbWFpbC1uY20->with
>  Yahoo! FareChase.
>



-- 
-- Lee Meador
Sent from gmail. My real email address is lee AT leemeador.com

Reply via email to