zoukankan      html  css  js  c++  java
  • 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}
  • 相关阅读:
    js 将图片连接转换称base64格式
    mysql性能优化-慢查询分析、优化索引和配置
    MySQL集群(三)mysql-proxy搭建负载均衡与读写分离
    MySQL集群(二)之主主复制
    MySQL集群(一)之主从复制
    JavaSE(八)之Map总结
    JDBC(二)之JDBC处理CLOB和BLOB及事务与数据库元数据获取
    JavaSE(八)之Collection总结
    JavaSE集合(八)之Map
    JavaSE(八)之集合练习一
  • 原文地址:https://www.cnblogs.com/fwpsl/p/7326182.html
Copyright © 2011-2022 走看看