AXIS WebServices开发

官网地址:http://axis.apache.org/axis/

api文档:http://axis.apache.org/axis/java/apiDocs/index.html

当前最新版本:Axis 1.4 Final 



2. 自定义部署-wsdd


Service:

package com.service;

import java.rmi.RemoteException;

import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;

import org.apache.axis.Constants;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;


public class AixsService {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String endpoint = "http://localhost:8080/Test2/services/TestService?wsdl";
		Service service = new Service();
		try {
			Call call = (Call)service.createCall();
			call.setTargetEndpointAddress(endpoint);
			call.setOperationName("receive");  //Client端调用的方法名
			//call.addParameter("somebody", XMLType.SOAP_STRING, ParameterMode.IN);
		        //call.setReturnType(Constants.XSD_STRING);
			String xxx = (String)call.invoke(new Object[] {"This is the message!"});  //传输的数据
			System.out.println("Service Receive:"+xxx);      //打印:Service Receive:thank you!
		} catch (ServiceException e) {
			e.printStackTrace();
		} catch (RemoteException e) {
			e.printStackTrace();
		}

	}

}

Client:

package com.client;

public class AixsClient {
	
	public String receive(String xmlMsg){
		System.out.println("Client Receive:" + xmlMsg);  //打印:Client Receive:This is the message!
		return "thank you!";
	}
}



你可能感兴趣的:(AXIS WebServices开发)