WebService-validateEmail Email 电子邮件地址验证 WEB 服务

首先进入项目的src目录下按Shift 和右键WebService-validateEmail Email 电子邮件地址验证 WEB 服务_第1张图片WebService-validateEmail Email 电子邮件地址验证 WEB 服务_第2张图片

进入cmd 命令窗口 # 按这个运行命令

如果是调用.net编写的WebService

使用java语言调用.net编写的WebService时,会出现解析错误。
需要修改wsdl文件。
实现步骤:
将wsdl文件保存到本地。
将wsdl文件中的


替换为

通过本地文件生成Java代码
D:\Java\workspace\getWeather\src>wsimport -p com.lxit.weather -keep D:\Java\workspace\getWeather\src\weather.wsdl

package com.znsd.webservice.demo;

import java.util.Arrays;
import java.util.List;

import com.znsd.email.validate.ValidateEmailWebService;
import com.znsd.email.validate.ValidateEmailWebServiceSoap;
import com.znsd.webservice.ArrayOfString;
import com.znsd.webservice.WeatherWS;
import com.znsd.webservice.WeatherWSSoap;
import com.znsd.webservice1.WeatherService;
import com.znsd.webservice1.WeatherServiceImplService;

public class Demo1 {
	public static void main(String[] args) {
		emailValidate();
	}

	private static void emailValidate() {
		ValidateEmailWebServiceSoap validate = new ValidateEmailWebService().getValidateEmailWebServiceSoap();
		short s = validate.validateEmailAddress("[email protected]");
		System.out.println(s);
	}

	private static void webXml() {
		WeatherWSSoap ws = new WeatherWS().getWeatherWSSoap();
		ArrayOfString provinces = ws.getRegionProvince();
		
		ArrayOfString weather = ws.getWeather("深圳",null);
		System.out.println(Arrays.toString(provinces.getString().toArray()));
		System.out.println(Arrays.toString(weather.getString().toArray()));
	}

	private static void myWeather() {
		WeatherService weather = new WeatherServiceImplService().getWeatherServiceImplPort();
		List list = weather.getProvince();
		System.out.println(Arrays.toString(list.toArray()));
		List list1 = weather.getCities("A");
		for (String string : list1) {
			System.out.println(string);
		}
	}
}

以上就完成了

myWeather是我自己写的server

package com.znsd.service;

import java.util.List;
import java.util.Set;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

@WebService
public interface WeatherService {
	@WebMethod
	Set getProvince();
	
	@WebMethod
	List  getCities(@WebParam(name = "city") String province);
}




package com.znsd.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.jws.WebService;

import com.znsd.service.WeatherService;

@WebService(endpointInterface = "com.znsd.service.WeatherService")
public class WeatherServiceImpl implements WeatherService {

	private static Map> provinces;

	static {
		provinces = new HashMap<>();
		ArrayList array1 = new ArrayList<>();
		array1.add("a");
		array1.add("aa");
		array1.add("aaa");
		
		ArrayList array2 = new ArrayList<>();
		array2.add("c");
		array2.add("cc");
		array2.add("ccc");
		
		ArrayList array3 = new ArrayList<>();
		array3.add("e");
		array3.add("ee");
		array3.add("eee");
		
		provinces.put("A",array1);
		provinces.put("B",array2);
		provinces.put("C",array3);
	}


	@Override
	public Set getProvince() {
		return provinces.keySet();
	}

	@Override
	public List getCities(String province) {
		return provinces.get(province);
	}

}



package com.znsd.demo;

import java.util.HashMap;
import java.util.Map;

import javax.xml.ws.Endpoint;

import com.znsd.service.impl.WeatherServiceImpl;

public class Demo1 {
	public static void main(String[] args) {
		String address = "http://localhost:9999/weather/getweathers";
		Endpoint.publish(address, new WeatherServiceImpl());
		Map map = new HashMap<>();
		map.put("a","23123");
		map.put("b","23123");
		map.put("a","23123");
		System.out.println(map.keySet());
		
		System.out.println(123);
	}
}


你可能感兴趣的:(WebService-validateEmail Email 电子邮件地址验证 WEB 服务)