package library; import java.io.IOException; import java.io.InputStream; import java.util.Properties; import javax.xml.namespace.QName; import net.sf.json.JSONObject; import org.apache.axis2.AxisFault; import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.client.Options; import org.apache.axis2.rpc.client.RPCServiceClient; import com.dev.swms.server.model.inventory.LibraryTask; import com.dev.swms.server.service.interfaceLog.ApiURL; public class doLibrary { public static String call(String parameters, String method) throws AxisFault { // 使用RPC方式调用WebService RPCServiceClient serviceClient = new RPCServiceClient(); Options options = serviceClient.getOptions(); // 指定调用WebService的URL EndpointReference targetEPR = new EndpointReference( ApiURL.doWMSLibrary); options.setTo(targetEPR); // 指定方法的参数值 Object[] opAddEntryArgs = new Object[]{parameters}; // 指定方法返回值的数据类型的Class对象 Class[] classes = new Class[] {String.class}; // 指定要调用的方法及WSDL文件的命名空间 QName opAddEntry = new QName("ZW.WCS", method); //http://ws.common.jeesite.thinkgem.com/xsd // 调用方法并输出该方法的返回值 Object[] response = serviceClient.invokeBlocking(opAddEntry, opAddEntryArgs, classes); System.out.println((String)response[0]); return (String)response[0]; } public String getPropertiesParm(String obj) { String parm = ""; Properties prop = new Properties(); InputStream in = this.getClass().getResourceAsStream("/hibernate.properties"); try { prop.load(in); parm = prop.getProperty(obj).trim(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return parm; } public static String receiveStoreMove(JSONObject jsonObject) throws AxisFault{ //JSONObject obj = new JSONObject(); /*JSONObject object1 = new JSONObject(); object1.put("WMS_TASK_ID", "1"); object1.put("TYPE", "1"); object1.put("BARCODE", "10001"); object1.put("FROM_CELL_CODE", "1001"); object1.put("TO_CELL_CODE", "01-10-03"); object1.put("RELATION_CODE", "1"); */ return call(jsonObject.toString(),"receiveStoreMove"); } public static void main(String[] args) throws AxisFault, InterruptedException { // receiveStoreMove(); } }