Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

web service question

Thread view: 
gk - 01 May 2006 05:00 GMT
     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
gk - 01 May 2006 05:18 GMT
/ 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 ?
gk - 01 May 2006 05:38 GMT
anyone please help me
Mike Schilling - 01 May 2006 07:37 GMT
>/ File: AddFunction.jws
> public class AddFunction {
[quoted text clipped - 13 lines]
> 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.
Roedy Green - 01 May 2006 05:43 GMT
>  call.setOperationName(new QName(endpoint, "addInt"));  // what is
>QName ?

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

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

gk - 01 May 2006 05:59 GMT
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);
   }
 }
}
Mike Schilling - 01 May 2006 07:36 GMT
>      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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.