当前位置:首页 > 开发 > 编程语言 > Web Service > 正文

Webservice axis1 axis2 客户端调用代码

发表于: 2014-03-08   作者:crabdave   来源:转载   浏览:
摘要: Webservice axis1 axis2 客户端调用代码 import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMNamespace; im

Webservice axis1 axis2 客户端调用代码

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;

public class ClientTesterDemo {
	
	private static final String WSDL_PATH = "WSDL路径";
	public static void main(String[] args) throws Exception {

		// 创建客户端
		EndpointReference targetEPR = new EndpointReference(WSDL_PATH);
		ServiceClient serviceClient = new ServiceClient();

		// 参数和配置
		Options options = new Options();
		options.setTo(targetEPR);
		serviceClient.setOptions(options);

		OMFactory fac = OMAbstractFactory.getOMFactory();
		// 创建调用方法
		OMNamespace omNs = fac.createOMNamespace(
				"http://命名空间", "");
		OMElement methodName = fac.createOMElement("方法名", omNs);

		// 提交参数

		OMElement metaData = fac.createOMElement("参数名", omNs);
		metaData.setText("参数值");
		methodName.addChild(metaData);
		
		methodName.build();
		
		OMElement results = serviceClient.sendReceive(methodName);
		System.out.println("返回值:"+results.toString());
	}

}

 

Webservice axis1 axis2 客户端调用代码

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号