Hey Patrick it all resolved now, thanks.
I'll take a look at the BPEL engines that you have mentioned.
Paulo Sérgio.
Patrick Martin wrote:
Ah: I should have gone a little further and say, once you've imported a
required exception you can either handle it in code, or add it to the throws
clause.
The problem here is the javax.xml.rpc.ServiceException exception that might be
thrown when creating the service, and you'll find another when the call is made.
This code should work: note you can just create this in an IDE like Eclipse as
a plain Java file, which makes things a lot quicker...
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
public class Soma6 {
public int soma(int valor1) throws ServiceException, RemoteException {
String local = "http://ese.cos.ufrj.br:8081/axis/Soma.jws";
Call call = (Call) new Service().createCall();
call.setTargetEndpointAddress(local);
call.setOperationName("soma");
Object[] param = new Object[]{new Integer(valor1), new Integer(6)};
Integer ret = (Integer)call.invoke(param);
return ret.intValue();
}
}
As to what you're trying to do: I can see now.
Perhaps such a product already exists in some form, example some of the BPEL
engines that now exist allow for calling of arbritary Web Services and much
more...
Hope this helps,
Patrick
-----Original Message-----
From: Paulo Sérgio [mailto:[EMAIL PROTECTED]
Sent: 06 January 2005 20:18
To: [EMAIL PROTECTED]
Subject: Re: Importing packages
Patrick, thanks for your attention...
Your advice didn't work...you can see it by yourself in
http://ese.cos.ufrj.br:8081/axis/Soma6.jws (Soma = sum in portuguese ;)
), here is the code again:
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
import java.rmi.RemoteException;
public class Soma6 {
public int soma(int valor1){
String local = "http://ese.cos.ufrj.br:8081/axis/Soma.jws";
Call call = (Call) new Service().createCall();
call.setTargetEndpointAddress(local);
call.setOperationName("soma");
Object[] param = new Object[]{new Integer(valor1),
Integer(6)};
Integer ret = (Integer)call.invoke(param);
return ret.intValue();
}
}
Like i said before, it's just a test. The reason for call a service with
other service is that im trying to create a "service configurator", in that, user will be able to configure an existing service (that can be
in anywhere in internet) chosing all parameters that he want to use
and/or default values to parameters,
and it will generate the java code to put behind axis (automagically
with it's WSDL :) ).
In this test that im trying to do, i've configured the service sum
generating sum6 (chosing one parameter, and defining a fixed value (6)
for the other).
So, can anyone help?
Paulo Sérgio.
Patrick Martin wrote:
Do you really need to have a web service calling another web service
directly?
This adds more things to consider (exceptions to handle, as you've
found).
You can easily add
import java.rmi.RemoteException;
To Sum6.jws
But wouldn't it be easier to have the Sum class in a .jar in the web
application lib directory, and import that class for all the web
services that need to call it internally. This way there's only one web
service call, and it's come from the external client?
Just a thought: hope this helps,
Patrick
p.s. you also need to change the return statement to return
ret.intValue();
-----Original Message-----
From: psm041 [mailto:[EMAIL PROTECTED]
Sent: 06 January 2005 16:09
To: [EMAIL PROTECTED]
Subject: Importing packages
Hi all, im new to the list (and to axis too) and i have one question to
start...
I`ve published the following service just for test and all went well
(Sum.jws):
public class Sum {
public int sum(int valor1, int valor2) {
return valor1 + valor2;
}
}
Now i want to publish another service that uses the one above, here is
the
code (Sum6.jws):
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
public class Sum6 {
public int sum(int valor1)
{
String local = "http://localhost:8081/axis/Sum.jws";
Call call = (Call) new Service().createCall();
call.setTargetEndpointAddress(local);
call.setOperationName("sum");
Object[] param = new Object[]{new Integer(valor1), Integer(6)}
Integer ret = (Integer)call.invoke(param);
return ret;
}
}
...and i've got the following from axis (while generating wsdl):
AXIS error
Sorry, something seems to have gone wrong... here are the details:
Fault - Error while compiling:
/usr/local/jakarta-tomcat-4.1.27/webapps/axis/WEB-INF/jwsClasses/Soma6.java
AxisFault
faultCode: {http://xml.apache.org/axis/}Server.compileError
faultSubcode:
faultString: Error while compiling:
/usr/local/jakarta-tomcat-4.1.27/webapps/axis/WEB-INF/jwsClasses/Soma6.java
faultActor:
faultNode:
faultDetail:
{}Errors: Error compiling
/usr/local/jakarta-tomcat-4.1.27/webapps/axis/WEB-INF/jwsClasses/Soma6.java:
Line 0, column 0: could not parse error message: Note: sun.tools.javac.Main
has been deprecated.
/usr/local/jakarta-tomcat-4.1.27/webapps/axis/WEB-INF/jwsClasses/Soma6.java:10:
Exception javax.xml.rpc.ServiceException must be caught, or it must be
declared in the throws clause of this method.
Call call = (Call) new Service().createCall();
^
Line 14, column 7: Method Integer(int) not found in class Soma6.
Line 15, column 36: Exception java.rmi.RemoteException must be caught, or
it must be declared in the throws clause of this method.
Line 16, column 2: Incompatible type for return. Can't convert
java.lang.Integer to int.
Line 0, column 0:
4 errors, 1 warning
ps: i've put axis.jar file in
/usr/local/jakarta-tomcat-4.1.27/webapps/axis/WEB-INF/classes/ directory for
the imports, right?
Any help will be REALLY appreciated :)
Paulo Sérgio.