• Web service 客户端 应用


    试了好多方法(如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}
  • 相关阅读:
    推荐一份JAVA学习vip路线图,可以参考下学习路径哦
    上传视频到阿里云服务器
    微信小程序授权登陆以及获取获取openid
    Java随笔
    Java随笔
    Java随笔
    Java随笔
    Java随笔
    Java随笔
    AC自动机模板
  • 原文地址:https://www.cnblogs.com/fwpsl/p/7326182.html
Copyright © 2020-2023  润新知