• 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}
  • 相关阅读:
    xiaopiu产品原型设计与团队实时协作平台
    asp.net webform过滤器(注意我们可以在拦截请求的同时设置回调函数)
    wdScrollTab
    pageoffice实现网页打开编辑保存word文档(基于SSM框架)
    ESB企业服务总线
    JRebel for IntelliJ
    dtcms 手机浏览
    maven仓库添加jar架包
    shell脚本实现FTP自动上传文件
    mysql创建数据库指定字符集
  • 原文地址:https://www.cnblogs.com/fwpsl/p/7326182.html
Copyright © 2020-2023  润新知