1. The jar packages that need to be used are as follows:
axis.jar, axis-ant.jar, commons-discovery-0.2.jar, commons-logging-1.0.4.jar , Jaxrpc.jar, log4j-1.2.8.jar, saaj.jar, wsdl4j-1.5.1.jar
2. Examples of calling codes are as follows
< pre> /**
* Query user mobile phone information
* This interface is an interface provided free of charge on the Internet, you need a computer to connect to the Internet to access
*/
public static void getMobileCodeInfo(){
String endpoint = “http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl”;
String nameSpace = “http://WebXml.com.cn/”;
String method = “getMobileCodeInfo”;
try {
//New service
Service service = new Service();
//Generate the client
Call call = (Call) service.createCall();
//Configure endpoint
call.setTargetEndpointAddress(new URL(endpoint));
//Configuration namespace and method
call.setOperationName(new QName(nameSpace,method));
//Configuration parameter names and parameter values
call.addParameter(new QName(nameSpace,”mobileCode”), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter(new QName(nameSpace,”userID”), XMLType.XSD_STRING, ParameterMode.IN);
Object[] paramValues = new Object[]{“18705187159″,””};
//Set the return value type
call.setReturnType(XMLType.XSD_STRING);
//SoapAction configuration, enter wsdl in the browser url, Search for soapAction in the results. If there is a value, you need to set it. If there is no value, you can set it or not.
call.setUseSOAPAction(true);
call.setSOAPActionURI(nameSpace+method);
//Call interface
String result = (String) call.invoke(paramValues);
} catch (Exception e) {
System.out.println(“The call to interface getMobileCodeInfo failed! The exception information is as follows:”);
System.out.println(e.toString());
}
}
* Query user mobile phone information
* This interface is an interface provided free of charge on the Internet, you need a computer to connect to the Internet to access
*/
public static void getMobileCodeInfo(){
String endpoint = “http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl”;
String nameSpace = “http://WebXml.com.cn/”;
String method = “getMobileCodeInfo”;
try {
//New service
Service service = new Service();
//Generate the client
Call call = (Call) service.createCall();
//Configure endpoint
call.setTargetEndpointAddress(new URL(endpoint));
//Configuration namespace and method
call.setOperationName(new QName(nameSpace,method));
//Configuration parameter names and parameter values
call.addParameter(new QName(nameSpace,”mobileCode”), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter(new QName(nameSpace,”userID”), XMLType.XSD_STRING, ParameterMode.IN);
Object[] paramValues = new Object[]{“18705187159″,””};
//Set the return value type
call.setReturnType(XMLType.XSD_STRING);
//SoapAction configuration, enter wsdl in the browser url, Search for soapAction in the results. If there is a value, you need to set it. If there is no value, you can set it or not.
call.setUseSOAPAction(true);
call.setSOAPActionURI(nameSpace+method);
//Call interface
String result = (String) call.invoke(paramValues);
System.out.println(
“result->”+result); //result->18705187159: Jiangsu Nanjing Jiangsu Mobile Global Pass Card} catch (Exception e) {
System.out.println(“The call to interface getMobileCodeInfo failed! The exception information is as follows:”);
System.out.println(e.toString());
}
}
/**
* Query entity class collection json
* This interface is an interface constructed by myself in another eclipse, and I need to start the interface program in another project to access it
*/
public static void listBeanTest(){
String endpoint = "http://localhost:8080/test2?wsdl";
String nameSpace = "http://webservice.ws.glaway.com/";
String method = "listBeanTest";
try {
//New service
Service service = new Service();
//Generate the client
Call call = (Call) service.createCall();
//Configure endpoint
call.setTargetEndpointAddress(new URL(endpoint));
//Configuration namespace and method
call.setOperationName(new QName(nameSpace,method));
//Configuration parameter names and parameter values
Object[] paramValues = new Object[0];
//Set the return value type
call.setReturnType(XMLType.XSD_STRING);
//SoapAction configuration, enter wsdl in the browser url, Search for soapAction in the results. If there is a value, you need to set it. If there is no value, you can set it or not.
// call.setUseSOAPAction(true);
// call.setSOAPActionURI(nameSpace+method);
//Call interface
String result = (String) call.invoke(paramValues);
System.out.println("result->"+result); //result->{"code":"success","data":[{"age":25,"name":"1"},{"age":8,"name":"2" }]}
} catch (Exception e) {
System.out.println("The call to interface listBeanTest failed! The exception information is as follows:");
System.out.println(e.toString());
}
}
/**
* Query user mobile phone information
* This interface is an interface provided free of charge on the Internet, you need a computer to connect to the Internet to access
*/
public static void getMobileCodeInfo(){
String endpoint = "http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl";
String nameSpace = "http://WebXml.com.cn/";
String method = "getMobileCodeInfo";
try {
//New service
Service service = new Service();
//Generate the client
Call call = (Call) service.createCall();
//Configure endpoint
call.setTargetEndpointAddress(new URL(endpoint));
//Configuration namespace and method
call.setOperationName(new QName(nameSpace,method));
//Configuration parameter names and parameter values
call.addParameter(new QName(nameSpace,"mobileCode"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter(new QName(nameSpace,"userID"), XMLType.XSD_STRING, ParameterMode.IN);
Object[] paramValues = new Object[]{"18705187159",""};
//Set the return value type
call.setReturnType(XMLType.XSD_STRING);
//SoapAction configuration, enter wsdl in the browser url, Search for soapAction in the results. If there is a value, you need to set it. If there is no value, you can set it or not.
call.setUseSOAPAction(true);
call.setSOAPActionURI(nameSpace+method);
//Call interface
String result = (String) call.invoke(paramValues);
System.out.println("result->"+result); //result->18705187159: Jiangsu Nanjing Jiangsu Mobile Global Pass Card
} catch (Exception e) {
System.out.println("The call to interface getMobileCodeInfo failed! The exception information is as follows:");
System.out.println(e.toString());
}
}
/**
* Query entity class collection json
* This interface is an interface constructed by myself in another eclipse, and I need to start the interface program in another project to access it
*/
public static void listBeanTest(){
String endpoint = "http://localhost:8080/test2?wsdl";
String nameSpace = "http://webservice.ws.glaway.com/";
String method = "listBeanTest";
try {
//New service
Service service = new Service();
//Generate the client
Call call = (Call) service.createCall();
//Configure endpoint
call.setTargetEndpointAddress(new URL(endpoint));
//Configuration namespace and method
call.setOperationName(new QName(nameSpace,method));
//Configuration parameter names and parameter values
Object[] paramValues = new Object[0];
//Set the return value type
call.setReturnType(XMLType.XSD_STRING);
//SoapAction configuration, enter wsdl in the browser url, Search for soapAction in the results. If there is a value, you need to set it. If there is no value, you can set it or not.
// call.setUseSOAPAction(true);
// call.setSOAPActionURI(nameSpace+method);
//Call interface
String result = (String) call.invoke(paramValues);
System.out.println("result->"+result); //result->{"code":"success","data":[{"age":25,"name":"1"},{"age":8,"name":"2" }]}
} catch (Exception e) {
System.out.println("The call to interface listBeanTest failed! The exception information is as follows:");
System.out.println(e.toString());
}
}