zoukankan      html  css  js  c++  java
  • WebService Client端

    pom

            <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-spring-boot-starter-jaxws</artifactId>
                <version>3.5.0</version>
                <exclusions>
                    <exclusion>
                        <artifactId>asm</artifactId>
                        <groupId>org.ow2.asm</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
    
            <dependency>
                <groupId>javax.xml.bind</groupId>
                <artifactId>jaxb-api</artifactId>
                <version>2.2.1</version>
            </dependency>
    
            <dependency>
                <groupId>javax.xml</groupId>
                <artifactId>jaxb-impl</artifactId>
                <version>2.1</version>
            </dependency>
    
            <dependency>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-xjc</artifactId>
                <version>2.3.0</version>
            </dependency>

    java是核心包,javax的x是extension的意思,也就是扩展包。

    client

    package com.test;
    
    import org.apache.cxf.endpoint.Client;
    import org.apache.cxf.interceptor.LoggingInInterceptor;
    import org.apache.cxf.interceptor.LoggingOutInterceptor;
    import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
    
    public class Test {
    
        public static void main(String[] args) throws Exception {
            JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
            Client client = factory.createClient("http://localhost:8000/order/api?wsdl");
            //打印发出的消息
            client.getInInterceptors().add(new LoggingInInterceptor());
            //打印进入的消息
            client.getOutInterceptors().add(new LoggingOutInterceptor());
    
            Object[] res = client.invoke("yxxczyNoticeWorkOrder", "test");
    
            System.out.println("Echo response: " + res[0]);
        }
    }

    cxf不支持jdk11, 目前只支持jdk1.8, 官网有说明

  • 相关阅读:
    Java代理(jdk静态代理、动态代理和cglib动态代理)
    Hive安装
    Spark 集群安装
    Flume 远程写HDFS
    Spark Idea Maven 开发环境搭建
    oracle 通不过网络的原因
    oracle一些基本问题
    linux-redhat配置yum源
    liunx虚拟机网络连接
    redhat安装jdk、tomcat、mysql
  • 原文地址:https://www.cnblogs.com/smileblogs/p/15579394.html
Copyright © 2011-2022 走看看