jaxrpcclient.java
来自「精通Jboss——Ejb和Web Services开发精解的随书源代码」· Java 代码 · 共 25 行
JAVA
25 行
package com.liuyang.axis.client;
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import javax.xml.rpc.Call;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.encoding.XMLType;
public class JAXRPCClient {
public static void main(String[] args) throws ServiceException, RemoteException {
Service service = ServiceFactory.newInstance().createService(new QName(""));
Call call = service.createCall(new QName("HelloService"),"sayHello");
call.addParameter( "param1", XMLType.XSD_STRING, ParameterMode.IN );
call.setReturnType(XMLType.XSD_STRING);
String name = "liuyang";
call.setTargetEndpointAddress("http://localhost:8080/axis/services/HelloService");
String ret = (String) call.invoke( new Object [] { name });
System.out.println("返回结果 : " + ret);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?