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}
  • 相关阅读:
    python---函数补充(变量传递),语句执行顺序(入栈顺序)
    python---基础知识回顾(十)进程和线程(多线程)
    python---方法解析顺序MRO(Method Resolution Order)<以及解决类中super方法>
    FindMe
    Android Studio系列教程五--Gradle命令详解与导入第三方包
    Material Design
    asmack
    AlarmDemo-with-Database
    ZhuGongpu CloudX-for-Android
    SaundProgressBar
  • 原文地址:https://www.cnblogs.com/fwpsl/p/7326182.html
Copyright © 2011-2022 走看看