// Method 1: Generate the client code call method. (This method can simplify a lot of code)
//
// Use the plug-in tool to generate client code for calling. For example, if a service is
// Http: // 127.0.0.1: 8000/axis2/services/helloworld? WSDL
// Save As helloworld. WSDL.
Code is automatically generated, including helloworldproxy. Java
Public static void main (string [] ARGs ){
Uploadproxy up = new uploadproxy ();
Up. setendpoint ("http: // 127.0.0.1: 70/uploadimg/services/uploadimg ");
// The Image Upload fileinputstream is omitted.
Up. updateimage ("", uploadbuffer, 0, 0 ,"","","","");}
// Generated using the plug-inSmssendservicestub. Java. The called client code is as follows:
Public static void main (string [] ARGs) throws exception {
Helloworldstub stub;
Stub = new helloworldstub ();
Helloworldstub. getname helloworld = new helloworldstub. getname ();//
Helloworld. setname ("peipan ");
System. Out. println (stub. getname (helloworld). get_return ());
}
// Method 2: Use axis2.rpc. Client. rpcserviceclient.
// Public static void main (string [] ARGs) throws exception {
// Getwsbyaxis2 Ws = new getwsbyaxis2 ();
// Ws. wsurl = "http: // 127.0.0.1: 8000/axis2/services/helloworld ";
// String result;
// Try {
// Result = ws. getstr ("getname", "peipan ");
// System. Out. println (result );
//} Catch (axisfault e ){
// E. printstacktrace ();
//}
//}
-------------------------------------------------
Package test;
Import javax. xml. namespace. QNAME;
Import org. Apache. axis2.axisfault;
Import org. Apache. axis2.addressing. endpointreference;
Import org. Apache. axis2.client. options;
Import org. Apache. axis2.rpc. Client. rpcserviceclient;
Public class getwsbyaxis2 {
Private Static string endpointurl;
Private Static string qurl = "http://ws.apache.org/axis2 ";
Private QNAME opaddentry;
Public String wsurl;
Public rpcserviceclient setoption () throws axisfault
{
Rpcserviceclient serviceclient = new rpcserviceclient ();
Options = serviceclient. getoptions ();
Endpointreference targetepr = new endpointreference (wsurl );
Options. setto (targetepr );
Return serviceclient;
}
Public QNAME getqname (string option ){
Return new QNAME (qurl, option );
}
// Return string
Public String getstr (string option, string why) throws axisfault
{
Rpcserviceclient serviceclient = This. setoption ();
Opaddentry = This. getqname (option );
String STR = (string) serviceclient. invokeblocking (opaddentry,
New object [] {why}, new class [] {string. Class}) [0];
Return STR;
}
// Returns a one-dimensional string array.
Public String [] getarray (string option) throws axisfault
{
Rpcserviceclient serviceclient = This. setoption ();
Opaddentry = This. getqname (option );
String [] strarray = (string []) serviceclient. invokeblocking (opaddentry,
New object [] {}, new class [] {string []. Class}) [0];
Return strarray;
}
// Return the instance of an object from WebService
Public object GetObject (string option, object O) throws axisfault
{
Rpcserviceclient serviceclient = This. setoption ();
QNAME = This. getqname (option );
Object object = serviceclient. invokeblocking (QNAME, new object [] {}, new class [] {o. getclass ()}) [0];
Return object;
}
//////////////////////////////////////// /Readers can encapsulate their own data types, data types such as int, byte, and float
}