Avatar billede fredand Forsker
15. april 2005 - 16:47 Der er 21 kommentarer og
1 løsning

How to create a Web Service for this client?

Hello!

I'm trying to learn how to write Web Services.

I need to create a Web Service built on Axis from Apache that respond to my client below on.

I have the following problems:

1) I do not manage to config my Orion server for Axis. I think I need to put it in a web server.

2) I have not found any nice example for a Web Service that would respond to something that look like my client.

So if you could help me with this it would be great!

I have created the Client like:

import java.net.*;
import org.apache.axis.client.*;
import javax.xml.namespace.*;

public class SoapWsdlClient
{
    public SoapWsdlClient()
    {
        try
        {
            Service service = new Service();
            Call call = (Call)service.createCall();
            call.setTargetEndpointAddress(new URL("http://localhost/axis/services/TimeService"));
            call.setOperationName(new QName("http://localhost/axis/services/TimeService", "getTime"));
            String time = (String) call.invoke( new Object[] { "getTime" } );
            System.out.println("Time from server:" + time);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public static void main(String[] args)
    {
        SoapWsdlClient SoapWsdlClient = new SoapWsdlClient();
    }
}
Avatar billede arne_v Ekspert
15. april 2005 - 16:56 #1
re 1)

I have not tried on Orion, but you should be able to deploy the Axis webapp
on all servlet 2.something compliant servlet engines

but maybe you need to package it in a war
Avatar billede arne_v Ekspert
15. april 2005 - 16:59 #2
re 2)

Usually the srever is give and you develop the client from that.

The above looks like:

Time.jws
--------

public class Time {
    public String getTime(String notused) {
        return "15-Apr-2005 17:00:00";
    }
}
Avatar billede fredand Forsker
20. april 2005 - 14:29 #3
Hello!

I gave up the attempts of deploying it in a Orion so i tried to install it with a Tomcat according to the install doc with Axis. Axis seems to recomend Tomcat. But I do not mange to get it right.

I have put it like:
Tomcat/webapps/axis

But when i start Tomcat I get the following exceptions (see screen images cause I can not copy strangely):

http://www.dsv.su.se/~fr-ander/tomcat1.JPG
http://www.dsv.su.se/~fr-ander/tomcat2.JPG

When I try to enter the site at: http://127.0.0.1:8080/axis/
I just get a 404

So if any one know what to do to get axis running in a Tomcat plese let me know!

Best regards
Fredrik
Avatar billede arne_v Ekspert
20. april 2005 - 14:36 #4
What version of Tomcat and what version of Axis ?
Avatar billede fredand Forsker
20. april 2005 - 14:48 #5
Hello!

Tomcat is 5.5.9 according to the zip-file-name.
Axis is 1_2RC3 acording to zip-file_name.

Correct me if I have get the wrong verions numbers.

Regards
Fredrik
Avatar billede arne_v Ekspert
20. april 2005 - 14:59 #6
No that should be OK.

5.5.x + 1.1final does not work

what JDK ?
Avatar billede fredand Forsker
20. april 2005 - 15:01 #7
Java is jdk1.5.0
and
JAVA_HOME is set to C:\Program\Java\jdk1.5.0
Avatar billede arne_v Ekspert
20. april 2005 - 15:04 #8
also fine

have you unzipped the axis zip somewhere else and then copied the relevant
subdir to tomcat webapps ?
Avatar billede fredand Forsker
20. april 2005 - 15:07 #9
Yes that is correct!

Do you think I should delete the first unzipped folder?

BTW
I do not have any path to that unzipped folder.

/Fredrik
Avatar billede fredand Forsker
20. april 2005 - 15:13 #10
I just tried to delete the unzipped folder and tried to start the Tomcat again and the exeption remains!

But I do not think you thought that it would do any differens either.
/Fredrik
Avatar billede fredand Forsker
20. april 2005 - 15:31 #11
Hello!

When I deploy an app in Orion I have to add these lines in 2 xml files, is ther anything like taht in Tomcat?

default-web-site.xml
<web-app application="XXXX" name="XXXX" root="/XXXX" />

server.xml
<application name="XXXX" path="../applications/XXXX.ear" />

/Fredrik
Avatar billede fredand Forsker
20. april 2005 - 16:39 #12
Hello!

I found this thread:
http://w4toolkit.com/forum/read.php?f=16&i=972&t=972
And I tried to change the servlet-api.jar to:
Tomcat 4.1.24
Tomcat 5.0.27
Tomcat 5.0.28

But without any luck!

/Fredrik
Avatar billede arne_v Ekspert
20. april 2005 - 16:41 #13
Yes.

But you only need to do that if you want to use:

http://www.domain.dk/YourServlet

instead of

http://www.domain.dk/yourwebapp/YourServlet
Avatar billede arne_v Ekspert
20. april 2005 - 16:44 #14
How do you start Tomcat ?
Avatar billede fredand Forsker
20. april 2005 - 16:52 #15
Hello!

By clicking on startup.bat

/Fredrik
Avatar billede arne_v Ekspert
20. april 2005 - 18:05 #16
Have you deployed anything else than Axis on Tomcat ?
Avatar billede fredand Forsker
20. april 2005 - 18:37 #17
Hello!

No, it is just a fresh unzipped Tomcat. And a fresh Axis put in the Tomcat\webbapps.

Very strange?

Fredrik
Avatar billede arne_v Ekspert
20. april 2005 - 20:44 #18
yes
Avatar billede fredand Forsker
22. april 2005 - 12:36 #19
Hello!

I found the error!

I had put axis.jar in to C:\Program\Java\jdk1.5.0\jre\lib\ext for easy compiling. Tomcat togehter with axis did not like that.

When I removed it it started to work fine.

Give a svar so I can reward you my friend!

Best regards
Fredrik
Avatar billede arne_v Ekspert
22. april 2005 - 12:47 #20
ouch

two rules:
  - never put anything in kre/lib/ext
  - never put anything (except maybe .) in global CLASSPATH
Avatar billede arne_v Ekspert
22. april 2005 - 12:47 #21
if you think I deserve points
Avatar billede fredand Forsker
22. april 2005 - 15:29 #22
Absolutely!
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester