试了好多方法(如axis2、xfire),一直报错,后来才知道用java的基础包就可以。汗~~
来贴上代码吧
1 import javax.jws.WebMethod; 2 import javax.jws.WebParam; 3 import javax.jws.WebResult; 4 import javax.jws.WebService; 5 import javax.xml.bind.annotation.XmlSeeAlso; 6 import javax.xml.namespace.QName; 7 import javax.xml.ws.RequestWrapper; 8 import javax.xml.ws.ResponseWrapper; 9 import javax.xml.ws.Service; 10 import java.net.URL; 11 12 public class HXZKServiceHelper { 13 public static String HXZKServiceUrl = "http://ip:端口/services/autherCenter?wsdl"; 14 15 // 认证方法接口 16 @WebService(name = "Service Name", targetNamespace = "targetNamespace") 17 @XmlSeeAlso({}) 18 public interface IService { 19 @WebMethod 20 @WebResult 21 @RequestWrapper(localName = "input Name", targetNamespace = "targetNamespace",
className = "com.hxzk.system.beltWebService.service.client.AutherCenter") 22 @ResponseWrapper(localName = "output Name", targetNamespace = "targetNamespace",
className = "com.hxzk.system.beltWebService.service.AutherCenterResponse") 23 String unifiedAuthentication(@WebParam(name = "safetyInfo", targetNamespace = "") String safetyInfo,
@WebParam(name = "serviceInfo", targetNamespace = "") String serviceInfo); 24 } 25 26 // 认证 27 public static String CheckAuther(String serviceInfo) throws Exception { 28 return CheckAuther(HXZKServiceUrl, serviceInfo); 29 } 30 31 // 认证 32 public static String CheckAuther(String wsUrl, String serviceInfo) throws Exception { 33 URL url = new URL(wsUrl); 34 Service service = Service.create(url, new QName("targetName", "Service Name")); 35 IService hs = service.getPort(new QName("targetName", "port Name"), IService.class); 36 return hs.unifiedAuthentication("", serviceInfo); 37 }38}