【neusoft】 WebService 的学习与使用

目录

 

一.什么是WebService?

二.WebService的两种类型是什么?

三.WebService技术都包含什么具体的框架?

四.Apache CXF HelloWord ?

五.WebService 的工作流程?

六.WebService的核心组件有哪些?

七.SOAP协议解析。

八.WSDL报文解析。

九.怎么使用JAXB?

十.怎么使用JAXWS?


一.什么是WebService?

Web Service技术, 能使得运行在不同机器上的不同应用无须借助附加的、专门的第三方软件或硬件, 就可相互交换数据或集成。依据Web Service规范实施的应用之间, 无论它们所使用的语言、 平台或内部协议是什么, 都可以相互交换数据。

简单的说,WebService就是一种跨编程语言跨操作系统平台的远程调用技术

注意,WebService是一项技术,而不是具体的某个框架,例如Spring框架。WebService技术可以使一个项目的Client代码远程调用另一个项目的Server代码。

二.WebService的两种类型是什么?

1.一种是以SOAP协议风格的Webservice。

2.一种是Restful风格的Webservice。

三.WebService技术都包含什么具体的框架?

WebService技术包含一下3种框架,如下图:

1.Axis: axis全称Apache Extensible Interaction System 即阿帕奇可扩展交互系统。Axis本质上就是一个SOAP引擎,提供创建服务器端、客户端和网关SOAP操作的基本框架。Axis目前版本是为Java编写的,不过为C++的版本正在开发中。但Axis并不完全是一个SOAP引擎,它还是一个独立的SOAP服务器和一个嵌入Servlet引擎(例如Tomcat)的服务器。

   Axis分为1.x和2.x两个不同的系列,两个系列体系结构和使用方式有很大的区别,相对而言,1.x的版本更加稳定并且文档也比较齐全。

2.XFire:XFire 是下一代的SOAP框架(相对于Axis)。XFire提供了非常简单的API,使用这些API可以使开发面向服务(SOA)。它支持性能标准,性能优良。

  上面提到一个词叫SOA,那么什么使SOA呢?

  面向服务的架构(SOA)是一个组件模型,它将应用程序的不同功能单元(称为服务)进行拆分,并通过这些服务之间定义良好的接口和协议联系起来。接口是采用中立的方式进行定义的,它应该独立于实现服务的硬件平台、操作系统和编程语言。这使得构建在各种各样的系统中的服务可以以一种统一和通用的方式进行交互。

  简单来说,SOA就是面向服务的架构,是一种架构方式,这种架构方式使我们只需要注重开发某个具体的服务,而不用关心其他,服务之间的调用通过已定义好的接口和协议联系起来。

3.CXF:cxf = Celtix +XFire,开始叫 Apache CeltiXfire,后来更名为 Apache CXF 了,以下简称为 CXF。CXF 继承了 Celtix 和 XFire 两大开源项目的精华,提供了对 JAX - WS 全面的支持,并且提供了多种 Binding 、DataBinding、Transport 以及各种 Format 的支持,并且可以根据实际项目的需要,采用代码优先(Code First)或者 WSDL 优先(WSDL First)来轻松地实现 Web Services 的发布和使用。Apache CXF已经是一个正式的Apache顶级项目。

四.Apache CXF HelloWord ?

现在用CXF框架编写一个HelloWord程序,一共分为5个步骤:

1.创建一个Maven工程,并在pom.xml文件中引入CXF的jar包。

		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-frontend-jaxws</artifactId>
			<version>3.2.1</version>
		</dependency>

		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-core</artifactId>
			<version>3.2.1</version>
		</dependency>

		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-transports-http</artifactId>
			<version>3.2.1</version>
			<exclusions>
				<exclusion>
					<groupId>org.springframework</groupId>
					<artifactId>spring-web</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-transports-http-jetty</artifactId>
			<version>3.2.1</version>
			<exclusions>
				<exclusion>
					<groupId>org.springframework</groupId>
					<artifactId>spring-web</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

2.创建所需要发布的接口。

package cn.cxf;

import javax.jws.WebService;

@WebService
public interface HelloWord {

    public String sayHello(String name,Integer age);

}

3.编写实现类实现接口。

package cn.cxf;

public class HelloWordImpl implements HelloWord {

    @Override
    public String sayHello(String name,Integer age){

        return name + "今年" + age;

    }
}

4.编写MainServer类,来向外发布服务。

package cn.cxf;

import org.apache.cxf.endpoint.Server;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;

public class MainServer {
    public static void main(String[] args){
        JaxWsServerFactoryBean jaxWsServerFactoryBean = new JaxWsServerFactoryBean();
        jaxWsServerFactoryBean.setAddress("http://localhost:9999/springboot-config--autoconfigyuanli");
        jaxWsServerFactoryBean.setServiceClass(HelloWordImpl.class);

        Server server = jaxWsServerFactoryBean.create();
        server.start();
    }
}

5.编写client客户端。

package cn.cxf;

import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;

public class Client {
    public static void main(String[] args){

        JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
        jaxWsProxyFactoryBean.setAddress("http://localhost:9999/springboot-config--autoconfigyuanli");
        jaxWsProxyFactoryBean.setServiceClass(HelloWord.class);

        HelloWord helloWord = (HelloWord)jaxWsProxyFactoryBean.create();
        String result = helloWord.sayHello("张三",18);

    }
}

通过上述的代码一个简单的由CXF框架编写的HelloWord程序就编写好了。我们只需要在idea按MainServer,Client文件的顺序执行" run 'MainServer.main() "就可以向外发布服务和访问服务了,发布服务的容器是jetty服务器,这个内置jetty我们在pom.xml中已经引入对应的jar包了。

测试结果:

其中要注意的是,setAddress() 方法中的参数一定要是正确的地址,也就是说是正确的ip,端口,项目访问名称。

在接口中的@WebService注解是javax包下的,而不是apache.cxf包下的,而且经过我自己测试,不在接口上使用这个注解的话,仍然能向外发布接口。

通过上面的例子,想到一个问题,既然服务端setServiceClass()指向的是实现类,而客户端setServiceClass()只向的是接口,那么如果服务端创建了多个服务,每个服务的" 执行者 "是实现类都实现同一个接口,那么客户端通过接口i访问服务端的时候,怎么知道" 执行者 "是哪一个实现类呢?

五.WebService 的工作流程?

webService结构

工作流程如上图,用文字描述一下就是:

1.客户端先获得UDDI的地址。

2.通过访问这个UDDI地址,获得描述这个服务的wsdl文本。

3.基于这个wsdl文本的内容向服务端发送基于soap协议的request请求。

4.服务端响应请求。

六.WebService的核心组件有哪些?

1.XML和HTTP。

2.SOAP: 简单对象访问协议。

3.WSDL: WebService描述语言。

4.UDDI:统一描述、发现和集成协议。

由于客户端和服务端之间数据传输是基于HTTP和SOAP协议的,而SOAP协议的请求体又是基于XML的。所以,WebService的核心组件就是上面的这4个。

这里可以简单的说一下什么是协议,我的理解就是,协议(例如HTTP,SOAP)就是客户端和服务端之间进行数据传输时所规定的数据格式(模板)。

七.SOAP协议解析。

1.什么是SOAP协议呢?

SOAP(Simple Object Access Protocol):简单对象访问协议是交换数据的一种协议规范,是一种轻量的、简单的、基于XML的协议,它被设计成在WEB上交换结构化的和固化的信息

SOAP 是基于 XML 的简易协议,可使应用程序在 HTTP 之上进行信息交换。

2.SOAP的构建模块。

一条 SOAP 消息就是一个普通的 XML 文档,包含下列元素:

(1).必需的 Envelope 元素,可把此 XML 文档标识为一条 SOAP 消息。

(2).可选的 Header 元素,包含头部信息。

(3).必需的 Body 元素,包含所有的调用和响应信息。

(4).可选的 Fault 元素,提供有关在处理此消息所发生错误的信息。

3.SOAP 消息的基本结构。

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Header>
...
</soap:Header>

<soap:Body>
...
  <soap:Fault>
  ...
  </soap:Fault>
</soap:Body>

</soap:Envelope>

4.Idea安装TunnelliJ插件来查看请求和响应信息。

先去Tunnellij官网下载TunnelliJ_8534.jar,然后将插件按照下图安装到Idea中:

5.查看请求信息。 

运行上面的HelloWord例子,通过TunnelliJ我们看到我们访问WebService服务时的请求信息。注意这里我们访问路径的端口要变成TunnelliJ的模拟端口访问。

POST /springboot-config--autoconfigyuanli HTTP/1.1
Content-Type: text/xml; charset=UTF-8
Accept: */*
SOAPAction: ""
User-Agent: Apache-CXF/3.2.1
Cache-Control: no-cache
Pragma: no-cache
Host: localhost:9999
Connection: keep-alive
Content-Length: 199

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <ns2:sayHello xmlns:ns2="http://cxf.cn/">
      <arg0>张三</arg0>
      <arg1>18</arg1>
    </ns2:sayHello>
  </soap:Body>
</soap:Envelope>

 这个信息的含义是,在cn.cxf包下有一个已经发布的接口,去执行接口实现类中的sayHello()方法,传入方法的参数是“张三”和“李四”。

6.查看响应信息。 

运行上面的HelloWord例子,通过TunnelliJ我们看到我们访问WebService服务后的相应信息。

HTTP/1.1 200 OK
Date: Sun, 04 Apr 2021 15:09:34 GMT
Content-Type: text/xml;charset=utf-8
Content-Length: 212
Server: Jetty(9.4.8.v20171121)

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <ns2:sayHelloResponse xmlns:ns2="http://cxf.cn/">
      <return>张三今年18</return>
    </ns2:sayHelloResponse>
  </soap:Body>
</soap:Envelope>

图片中的下部分就是响应的SOAP协议内容。

一次WebService的调用,不是方法的调用 ,而是SOAP(xml格式规范的文档片段)消息在客户端和服务端之间的输入输出。

八.WSDL报文解析。

1.什么时wsdl报文?

简单来说,WSDL(Web Services Description Language)就是用来描述WebService接口的xml文件。描述的内容例如:接口所在的包,方法的名称,方法所需要的参数等等。

2.WSDL 元素有哪些?

    WSDL 元素基于XML语法描述了与服务进行交互的基本元素:

    Type(消息类型):数据类型定义的容器,它使用某种类型系统(如 XSD)。

    Message(消息):通信数据的抽象类型化定义,它由一个或者多个 part 组成。

    Part:消息参数

    Operation(操作):对服务所支持的操作进行抽象描述,WSDL定义了四种操作: 1.单向(one-way):端点接受信息;2.请求-响应(request-response):端点接受消息,然后发送相关消息;3.要求-响应(solicit-response):端点发送消息,然后接受相关消息;4.通知(notification):端点发送消息。

    Port Type(端口类型):特定端口类型的具体协议和数据格式规范。

    Binding:特定端口类型的具体协议和数据格式规范。

    Port:定义为绑定和网络地址组合的单个端点。

Service:相关端口的集合,包括其关联的接口、操作、消息等。

3.获取wsdl报文。

在浏览器中输入要访问的 服务的地址 + ?wsdl 就可以在浏览器显示这个服务的wsdl报文。例如:http://localhost:4444/springboot-config--autoconfigyuanli?wsdl

我获取的报文如下:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://cxf.cn/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="HelloWordImplService" targetNamespace="http://cxf.cn/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://cxf.cn/" elementFormDefault="unqualified" targetNamespace="http://cxf.cn/" version="1.0">
<xs:element name="sayHello" type="tns:sayHello"/>
<xs:element name="sayHelloResponse" type="tns:sayHelloResponse"/>
<xs:complexType name="sayHello">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="xs:string"/>
<xs:element minOccurs="0" name="arg1" type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="sayHelloResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="sayHello">
<wsdl:part element="tns:sayHello" name="parameters"> </wsdl:part>
</wsdl:message>
<wsdl:message name="sayHelloResponse">
<wsdl:part element="tns:sayHelloResponse" name="parameters"> </wsdl:part>
</wsdl:message>
<wsdl:portType name="HelloWord">
<wsdl:operation name="sayHello">
<wsdl:input message="tns:sayHello" name="sayHello"> </wsdl:input>
<wsdl:output message="tns:sayHelloResponse" name="sayHelloResponse"> </wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloWordImplServiceSoapBinding" type="tns:HelloWord">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sayHello">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="sayHello">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="sayHelloResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloWordImplService">
<wsdl:port binding="tns:HelloWordImplServiceSoapBinding" name="HelloWordImplPort">
<soap:address location="http://localhost:9999/springboot-config--autoconfigyuanli"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

 4.解析wsdl报文

           下面解析一下这个报文,部分隐藏之后如下图:

我们先看<wsdl:types>部分:

 上面图片说明wsdl报文描述了一个接口,这个接口的方法名为sayHello(),调用方法时需要传两个参数(顺序不能错),一个是String类型,一个是int类型,并且方法的返回值是一个String类型的参数。

<wsdl:message>部分:

上面图片说明wsdl报文描述了接口拥有的方法。

<wsdl:portType>部分:

上面图片说明wsdl报文描述了接口的名称为HelloWord,和接口中的方法sayHello()。 

<wsdl:binding>部分:

 上面图片说明wsdl报文描述了接口的名称为HelloWord,而接口的实现类为HelloWordImpl。 

<wsdl:service>部分:

  上面图片说明wsdl报文描述了接口的服务地址,和执行服务的实现类。

总结:

经过上面的所有图片,当我们从后往前推的时候,我们就知道了这个WSDL报文想要告诉我们什么信息:在http://localhost:9999/springboot-config--autoconfigyuanli上发布了一个服务,服务的处理者是HelloWordImpl实现类,这个实现类绑定的接口是HelloWord接口,接口中有sayHello()方法,并且描述了sayHello()方法所需要的参数。

 5.自定义报文中的参数名称。

    可以在接口中通过下面的注解,在生成wsdl报文的时候,报文的方法参数名称就是我们在注解中指定的名称。

package cn.cxf;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;

@WebService
public interface HelloWord {

    @WebMethod
    @WebResult(name = "sayHelloReturn")
    public String sayHello(@WebParam(name = "name") String name, @WebParam(name = "age")Integer age);

}

我在这里遇到个问题,为什么Idea都已经关掉了,但我还是可以在浏览器访问刚才发布的服务的wsdl呢? 

九.怎么使用JAXB?

1.什么是JAXB?

JAXB(Java Architecture for XML Binding) 是一个业界的标准,是一项可以根据XML Schema产生Java类的技术。该过程中,JAXB也提供了将XML实例文档反向生成Java对象树的方法,并能将Java对象树的内容重新写到 XML实例文档。

Jaxb 2.0是JDK 1.6的组成部分。我们不需要下载第三方jar包 即可做到轻松转换。Jaxb2使用了JDK的新特性,如:Annotation、GenericType等,需要在即将转换的JavaBean中添加annotation注解。

简单来说,JAXB可以进行Java类和xml文件的相互转换。

2.编写Marshaller代码,将Java对象输出成xml文件。

package cn.cxf;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import java.io.StringWriter;

public class JaxbTest {

    public static void main(String[] args){
        test();
    }

    public static void test(){
        JAXBContext jaxbContext = null;
        try{
            jaxbContext = JAXBContext.newInstance(Book.class);
            Marshaller marshaller = jaxbContext.createMarshaller();
            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);  //使输出的xml文件格式化样式
            marshaller.setProperty(Marshaller.JAXB_ENCODING, "utf-8");
            marshaller.marshal(new Book("三国演义","99"),System.out);
        }catch (Exception e){

        }
    }
}

除了上面的代码,我们还需要在BOOK类上用@XmlRootElement注解

3.编写Unmarshaller代码,将xml文件输出成Java对象。

package cn.cxf;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import java.io.StringReader;
import java.io.StringWriter;

public class JaxbTest {

    public static void main(String[] args){
        test();

    }

    public static void test(){
        JAXBContext jaxbContext = null;
        try{
            jaxbContext = JAXBContext.newInstance(Book.class);
            Unmarshaller unmarshalle = jaxbContext.createUnmarshaller();
            String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"+
                    "<book>"+
                    "  <name>三国演义</name>"+
                    "  <price>99</price>"+
                    "</book>";
            Book book = (Book)unmarshalle.unmarshal(new StringReader(xml));
            System.out.println(book);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

上面就是对于JAXB的简单使用,这个功能是在javax包中的。

 

十.怎么使用JAXWS?

1.什么使JAXWS?

JAX-WS(Java API for XML Web Services)规范是一组XML web services的Java-API,JAX-WS允许开发者可以选择RPC-oriented或者message-oriented 来实现自己的web services。

在 JAX-WS中,一个远程调用可以转换为一个基于XML的协议例如SOAP,在使用JAX-WS过程中,开发者不需要编写任何生成和处理SOAP消息的代码。JAX-WS的运行时实现会将这些API的调用转换成为对应的SOAP消息。

2.自动生成客户端代码。

由于在上面的例子中,我们是在一个Web工程中同时写client和server,是在一个项目中进行接口的调用,在实际开发中是不可能这样的,肯定是多个工程之间的相互调用,那么这个时候就需要使用JAXWS了。

我们首先下载cxf的jar包https://downloads.apache.org/cxf/3.4.3/apache-cxf-3.4.3.zip

之后我们在命令行运行命令:

F:\JAVA\install\apache-cxf-3.4.3\apache-cxf-3.4.3\bin>wsdl2java http://localhost:9999/springboot-config--autoconfigyuanli?wsdl

F:\JAVA\install\apache-cxf-3.4.3\apache-cxf-3.4.3\bin>

在这个路径下会生成文件夹,这个文件夹的代码就是我们访问这个接口的client代码。

把代码粘贴到Idea中我们看到一共生成了6个文件:

其中,最后两个文件是将WebService的入参和出参封装成实体类,没有什么用。

第四个文件是描述接口所在的包是哪个包,里面只有两行代码:

@javax.xml.bind.annotation.XmlSchema(namespace = "http://cxf.cn/")
package cn.cxf;

后四个文件完全没有用,我们可以直接删除掉,只留上面的两个文件就可以了。

3.JAXWS的使用?

HelloWord文件:

package cn.cxf;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;

@WebService(targetNamespace = "http://cxf.cn/", name = "HelloWord")
@XmlSeeAlso({ObjectFactory.class})
public interface HelloWord {

    @WebMethod
    @RequestWrapper(localName = "sayHello", targetNamespace = "http://cxf.cn/", className = "cn.cxf.SayHello")
    @ResponseWrapper(localName = "sayHelloResponse", targetNamespace = "http://cxf.cn/", className = "cn.cxf.SayHelloResponse")
    @WebResult(name = "return", targetNamespace = "")
    public String sayHello(

            @WebParam(name = "arg0", targetNamespace = "")
                    String arg0,
            @WebParam(name = "arg1", targetNamespace = "")
                    Integer arg1
    );
}

HelloWordImplService文件:

package cn.cxf;

import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.Service;

@WebServiceClient(name = "HelloWordImplService",
                  wsdlLocation = "http://localhost:9999/springboot-config--autoconfigyuanli?wsdl",
                  targetNamespace = "http://cxf.cn/")
public class HelloWordImplService extends Service {

    public final static URL WSDL_LOCATION;

    public final static QName SERVICE = new QName("http://cxf.cn/", "HelloWordImplService");
    public final static QName HelloWordImplPort = new QName("http://cxf.cn/", "HelloWordImplPort");
    static {
        URL url = null;
        try {
            url = new URL("http://localhost:9999/springboot-config--autoconfigyuanli?wsdl");
        } catch (MalformedURLException e) {
            java.util.logging.Logger.getLogger(HelloWordImplService.class.getName())
                .log(java.util.logging.Level.INFO,
                     "Can not initialize the default wsdl from {0}", "http://localhost:9999/springboot-config--autoconfigyuanli?wsdl");
        }
        WSDL_LOCATION = url;
    }

    public HelloWordImplService(URL wsdlLocation) {
        super(wsdlLocation, SERVICE);
    }

    public HelloWordImplService(URL wsdlLocation, QName serviceName) {
        super(wsdlLocation, serviceName);
    }

    public HelloWordImplService() {
        super(WSDL_LOCATION, SERVICE);
    }

    public HelloWordImplService(WebServiceFeature ... features) {
        super(WSDL_LOCATION, SERVICE, features);
    }

    public HelloWordImplService(URL wsdlLocation, WebServiceFeature ... features) {
        super(wsdlLocation, SERVICE, features);
    }

    public HelloWordImplService(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) {
        super(wsdlLocation, serviceName, features);
    }

    @WebEndpoint(name = "HelloWordImplPort")
    public HelloWord getHelloWordImplPort() {
        return super.getPort(HelloWordImplPort, HelloWord.class);
    }

    @WebEndpoint(name = "HelloWordImplPort")
    public HelloWord getHelloWordImplPort(WebServiceFeature... features) {
        return super.getPort(HelloWordImplPort, HelloWord.class, features);
    }

}

编写ClientTest代码:

package cn.cxf;

public class ClientTest {

    public static void main(String[] args){
        HelloWord helloWord = new HelloWordImplService().getHelloWordImplPort();
        helloWord.sayHello("张三",18);
    }
}

通过这两行代码,和HelloWord接口和HelloWordImplService实现类就能够跨项目访问WebService接口了。

这里需要注意一点的就是,客户端HelloWord中的@WebParam的name值要和服务端发布接口的@WebParam的name一致,否则会报错。

 

OK。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值