/**
*@Title:
*@Description:
*@Author:97000805
*@Since:2012-3-15
*@Version:1.1.0
*/
package org.smjm.webservice.client.getstock;
import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
public class GetStock {
public static void main(String[] args) throws Exception {
// WEBSERVICE对应wsdl的WEB路径
String endpoint = "*************************";
// 命名空间对应wsdl中的targetNamespace
String namespace = "************************";
// 接口调用的方法,对应WSDL中的operation属性name
String method = "************";
System.out.println("start web service");
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
//设置客户端调用的方法
call.setOperationName(new QName(namespace, method));
// 设置输入
QName request = new QName(endpoint, "InputType");
// 设置输出
QName response = new QName(endpoint, "OutputType");
//设置输入的类
call.registerTypeMapping(InputType.class, request,
new BeanSerializerFactory(InputType.class, request),
new BeanDeserializerFactory(InputType.class, request));
//设置输出的类
call.registerTypeMapping(OutputType.class, response,
new BeanSerializerFactory(OutputType.class, response),
new BeanDeserializerFactory(OutputType.class, response));
InputType input = new InputType();
input.setRDATE("2012.03.03");
InputType[] inputs = new InputType[1];
inputs[0] = input;
//调用
Object obj = call.invoke(new Object[] { inputs });
System.out.println(obj);
}
}