sessionbeanwstest.java

来自「《精通SOA:基于服务总线的Struts+EJB+Web Service整合应用」· Java 代码 · 共 36 行

JAVA
36
字号
package com.ws.sessionbean;

import java.net.MalformedURLException;
import java.rmi.RemoteException;

import javax.xml.rpc.ServiceException;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

public class SessionBeanWSTest {

	/**
	 * @param args
	 * @throws ServiceException 
	 * @throws MalformedURLException 
	 * @throws RemoteException 
	 */
	public static void main(String[] args) throws ServiceException, MalformedURLException, RemoteException {
	       String endpoint = "http://localhost:" +"7001"+ "/webModule/services/getSessionBeanWsService";//指明服务所在位置

	       Service  service = new Service();  //创建一个Service实例,注意是必须的!
	       Call call = (Call) service.createCall();//创建Call实例,也是必须的!

	     call.setTargetEndpointAddress( new java.net.URL(endpoint) );//为Call设置服务的位置

	        call.setOperationName( "getSessionBeanWs" );//注意方法名与JavaBeanWS.java中一样!!

	         String res = (String) call.invoke( new Object[] {"Aihu"} );//返回String,传入参数 "Aihu"

	                         System.out.println( res );

	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?