webService客户端service方式搭建(四)

package me.gacl.ws.client;

import java.net.URL;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;

import me.gacl.phonenum.MobileCodeWSSoap;



public class weatherService_Service {
	public static void main(String[] args) throws Exception {
		URL url = new URL("http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl");
//		namespaceURI -- 命名空间地址
//		localPart	-- 服务视图名
		
		QName qname = new QName("http://WebXml.com.cn/", "MobileCodeWS");
//		serviceName	--服务名称
//		wsdlDocumentLocation -- wsdl地址
		Service service = Service.create(url,qname);

//		获取service实现类
		MobileCodeWSSoap mobileCodeWSSoap = service.getPort(MobileCodeWSSoap.class);
		String mobileCodeInfo = mobileCodeWSSoap.getMobileCodeInfo("1861234","");
		System.out.println(mobileCodeInfo);
	}
}

  代码如上,获取wsdl方式相同。

原文地址:https://www.cnblogs.com/duyunchao-2261/p/7448235.html