web service question

G

gk

String endpoint = "http://localhost:8080/axis/AddFunction.jws";
Service service = new Service();
Call call = (Call) service.createCall();
call.setOperationName(new QName(endpoint, "addInt")); // what is
QName ?
call.setTargetEndpointAddress( new java.net.URL(endpoint) ); //
what this does ?
Integer ret = (Integer)call.invoke(new Object[]{new Integer(5),
new Integer(6)});


hi, i dont understand the commented questions. can you please answer ?

thanks
 
G

gk

/ File: AddFunction.jws
public class AddFunction {
int addInt(int a, int b){
return(a+b);
}
}



In original function in the server side we had

int addInt(int a, int b)




but the client side is calling this way....
Integer ret = (Integer)call.invoke(new Object[]{new Integer(5),new
Integer(6)});

why they are making Integer(5),Integer(6)....why not simplty int as in
the server side function ?
 
R

Roedy Green

call.setOperationName(new QName(endpoint, "addInt")); // what is
QName ?

I would interpret the question to mean "Show me the code for class
QName"
 
G

gk

ok....here is the full code



import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import javax.xml.namespace.QName;

public class AddFunctionClient {
public static void main(String [] args) {
try {
String endpoint = "http://localhost:8080/axis/AddFunction.jws";
Service service = new Service();
Call call = (Call) service.createCall();
call.setOperationName(new QName(endpoint, "addInt"));
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
Integer ret = (Integer)call.invoke(new Object[]{new Integer(5),
new Integer(6)});
System.out.println("addInt(5, 6) = " + ret);
} catch (Exception e) {
System.err.println("Execution failed. Exception: " + e);
}
}
}
 
M

Mike Schilling

gk said:
String endpoint = "http://localhost:8080/axis/AddFunction.jws";
Service service = new Service();
Call call = (Call) service.createCall();
call.setOperationName(new QName(endpoint, "addInt")); // what is
QName ?
A qualified name, like an XML tag anme: a namespace plus a local name.
call.setTargetEndpointAddress( new java.net.URL(endpoint) ); //
what this does ?

It sets the address the message will be sent to.
 
M

Mike Schilling

gk said:
/ File: AddFunction.jws
public class AddFunction {
int addInt(int a, int b){
return(a+b);
}
}



In original function in the server side we had

int addInt(int a, int b)




but the client side is calling this way....
Integer ret = (Integer)call.invoke(new Object[]{new Integer(5),new
Integer(6)});

why they are making Integer(5),Integer(6)....why not simplty int as in
the server side function ?

Because invoke() always uses an array of Object to hold parameters, and
int's aren't Objects.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,219
Latest member
KristieKoh

Latest Threads

Top