webservice应用–axis1

未分类 , 发表评论

1、 生成bat文件
set Axis_Lib=D:\jar\axis\axis-bin-1_4\axis-1_4\lib
set Java_Cmd=java -Djava.ext.dirs=%Axis_Lib%
set Output_Path=D:\jar\axis\axis-bin-1_4\src
set Package=com.ibusiness.opgw.protocol.ismp.ws
%Java_Cmd% org.apache.axis.wsdl.WSDL2Java -o%Output_Path% -p%Package% http://127.0.0.1:8888/services/XXXEngine?wsdl
*说明:
Axis_Lib:axis1的lib位置
Java_Cmd:这句不用管
Output_Path:代码生成的位置
Package:客户端的package
最后一句最重要:最后的地址为wsdl文件所在的位置,如果是在本地的wsdl文件,则可用
…. -p%Package% D:\jar\axis\axis-bin-1_4\src\XXXEngine?wsdl

2、 双击bat,生成客户端的stub
可以在D:\jar\axis\axis-bin-1_4\src\com\ibusiness\opgw\protocol\ismp\ws下看到生成了一大批java代码

3、 客户端逻辑代码
package com.xp.client;

import java.rmi.RemoteException;

import javax.xml.rpc.ServiceException;

import org.apache.axis.AxisFault;

import com.ibusiness.opgw.protocol.ismp.ws.XXXEngineService;
import com.ibusiness.opgw.protocol.ismp.ws.XXXEngineServiceLocator;
import com.ibusiness.opgw.protocol.ismp.ws.XXXEngineSoapBindingStub;
import com.ibusiness.opgw.protocol.ismp.ws.NotifyManagementInfoReq;
import com.ibusiness.opgw.protocol.ismp.ws.NotifyManagementInfoRsp;

public class ClientDemo {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
notifyManagementInfo();

}

public static void notifyManagementInfo(){
String ID = “1001”;
int IDType=111;
int status = 0;
String streamingNo = “123456”;
XXXEngineSoapBindingStub stub;
try {
XXXEngineService service = new XXXEngineServiceLocator();
stub = (XXXEngineSoapBindingStub)service.getXXXEngine();
NotifyManagementInfoReq notifyManagementInfoReq = new NotifyManagementInfoReq();
notifyManagementInfoReq.setID(ID);
notifyManagementInfoReq.setIDType(IDType);
notifyManagementInfoReq.setStatus(status);
notifyManagementInfoReq.setStreamingNo(streamingNo);
NotifyManagementInfoRsp rsp = stub.notifyManagementInfo(notifyManagementInfoReq);
System.out.print(rsp.getResultCode());
} catch (AxisFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}

这样就可以直接调用到服务端了

发表评论

邮箱地址不会被公开。 必填项已用*标注

昵称 *