`
jnn
  • 浏览: 283491 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Code First vs WSDL Frist

    博客分类:
  • Java
阅读更多
如果要构建一个Web Services,CXF提供了两种构建方式一个是Code First,另一个WSDL First。
那什么是Code First,什么又是WSDL First呢?

大家知道,如果我们要将一个服务发布一个WebService,我们需要定义这个服务所支持的方法,以及调用这些方法所提供的参数并将其转化成为WSDL,供其它的客户端调用。Code First是第一代的WebService开发工具所提供的构建WebService的一种方式。以Java为例,我们可以通过Interface定义一组Web服务所提供的方法,Code First就是通过获取这个Interface的信息构建出Web Services 所需要的信息,并在这些信息的基础上生成WSDL。

而WSDL First就是通过WSDL文件,生成相关的Aritifacts,例如有相关的接口以及实现的代码框架等,这CORBA开发一样,先使用IDL描述我们的CORBA服务,通过IDL2XXX生成相关的接口和实现框架(屏蔽了网络传输中Marshal和Unmarshal的操作)。

这两种构建Web Services各有特点,适合在不同的场景。

接触过WSDL的朋友应该都有这样的感觉,WSDL虽然是用XML来进行描述的,但是如果让你在不借助任何工具的情况下写一个正确的WSDL,或者是改正一个错误的WSDL是很难的。Code First可以说是为我们提供了一个不错的选择。

但是Web Services的Best Practies并不推荐Code First这一Web Services的构建方式。原因是什么呢?

这是因为我们在使用Code First构建方式时很少考虑到Web Services之间的交互是以文档方式进行(这样可以大大提高Web Services的互交互性),如果是使用Code First来构建WSDL信息,在描述描述交互信息的XML Schema都是以我们的Code中定义的类型信息来生成的,这样就可能会暴露一些比较细粒度的信息。同时大家知道不同的语言(C++,Java, C#,PHP)对XML Schema映射是各不相同的,如果我们Code中定义的类型很特殊,就可能产生出一个不能互操作的现象。

所以Best Practies建议你在创建Web Services从交互的消息Schema入手,构建一个中间层来提供一个比较粗粒度的描述,这样可以比较好的解决Web Services的互交互问题。
分享到:
评论

相关推荐

    Apache-cxf-学习笔记.docx

    Celtix 和 XFire 两大开源项目的精华,提供了对 JAX-WS 全面的支持,并且提供了多种 Binding 、DataBinding、Transport 以及各种 Format 的支持,并且可以根据实际项目的需要,采用代码优先(Code First)或者 ...

    apache-cxf-3.0.4

    Celtix 和 XFire 两大开源项目的精华,提供了对 JAX-WS 全面的支持,并且提供了多种 Binding 、DataBinding、Transport 以及各种 Format 的支持,并且可以根据实际项目的需要,采用代码优先(Code First)或者 ...

    cxf-2.5.2.jar

    Celtix 和 XFire 两大开源项目的精华,提供了对 JAX-WS 全面的支持,并且提供了多种 Binding 、DataBinding、Transport 以及各种 Format 的支持,并且可以根据实际项目的需要,采用代码优先(Code First)或者 ...

    webservice框架之CXF-详细技术参考

    Celtix 和 XFire 两大开源项目的精华,提供了对 JAX-WS 全面的支持,并且提供了多种 Binding 、DataBinding、Transport 以及各种 Format 的支持,并且可以根据实际项目的需要,采用代码优先(Code First)或者 ...

    Apache-CXF2.4.0-API.chm

    Celtix 和 XFire 两大开源项目的精华,提供了对 JAX-WS 全面的支持,并且提供了多种 Binding 、DataBinding、Transport 以及各种 Format 的支持,并且可以根据实际项目的需要,采用代码优先(Code First)或者 ...

    Developing Web Services with Apache CXF and Axis2(3rd Edition).zip

    Celtix 和 XFire 两大开源项目的精华,提供了对 JAX-WS 全面的支持,并且提供了多种 Binding 、DataBinding、Transport 以及各种 Format 的支持,并且可以根据实际项目的需要,采用代码优先(Code First)或者 ...

    wsdl2java源码-spring-boot-cxf-integration-noxml:SpringBoot和CXF集成,无需xml配置

    contract-first/wsdl-first/code-last(选择您喜欢的任何名称)方法实现的,但是配置(wsdl2java maven 插件除外)对于代码优先的 Web 服务来说是完全相同的. 逻辑和项目本身非常简单,它没有业务或 Web 层。 由于其...

    CXF WEBSERVICE入门,非常详细实用

    Celtix 和 XFire 两大开源项目的精华,提供了对 JAX-WS 全面的支持,并且提供了多种 Binding 、DataBinding、Transport 以及各种 Format 的支持,并且可以根据实际项目的需要,采用代码优先(Code First)或者 ...

    ApacheCamelDemo:Apache Camel演示(学习示例演示)

    Apache Camel - CXF组件(Code First and WSDL File First) Apache Camel - JMS/ActiveMQ组件 Apache Camel - Jetty组件 Apache Camel - Timer组件 Apache Camel - JDBC组件 Apache Camel - Dynamic Control Route...

    WebService with Apache CXF

    Celtix 和 XFire 两大开源项目的精华,提供了对 JAX-WS 全面的支持,并且提供了多种 Binding 、DataBinding、Transport 以及各种 Format 的支持,并且可以根据实际项目的需要,采用代码优先(Code First)或者 ...

    apache-cxf-3.3.5

    CXF supports both contract first development with WSDL and code first development starting from Java. There is also a JAX-RS frontend for providing REST support. Ease of use: CXF is designed to be ...

    apache-cxf-3.2.8.zip

    Celtix 和 XFire 两大开源项目的精华,提供了对 JAX-WS 全面的支持,并且提供了多种 Binding 、DataBinding、Transport 以及各种 Format 的支持,并且可以根据实际项目的需要,采用代码优先(Code First)或者 WSDL ...

    Spring WebService (E)

    When using a contract-last approach, you start with the Java code, and let the Web service contract (WSDL, see sidebar) be generated from that. When using contract-first, you start with the WSDL ...

    Spring jar包

    This tutorial shows you how to write contract-first Web services, that is, developing web services that start with the XML Schema/WSDL contract first followed by the Java code second. Spring-WS ...

    Professional C# 3rd Edition

    Our First C# Program 30 The Code 30 Compiling and Running the Program 31 Contents A Closer Look 31 Variables 34 Initialization of Variables 34 Variable Scope 35 Constants 38 Predefined Data Types 39 ...

    Beginning Python (2005).pdf

    Try It Out: Writing a Test Suite First 201 Try It Out: A General-Purpose Search Framework 203 A More Powerful Python Search 205 Try It Out: Extending the Search Framework 206 Formal Testing in the...

    php.ini-development

    This directive determines whether or not PHP will recognize code between ; <? and ?> tags as PHP source which should be processed as such. It is ; generally recommended that <?php and ?> should be ...

    EurekaLog_7.5.0.0_Enterprise

    13)..Added: "User" and "Session" columns to processes list, processes list is also sorted by session first 14)..Added: Support for showing current user processes only 15)..Added: Expanding environment...

    【。net 专业】 面试题

    13.什么是code-behind技术 aspx and cs 14.概述三层结构体系 web/business/dataaccess 15.asp.net如何实现MVC模式,举例说明! web/business/dataaccess 2.什么是ASP.net中的用户控件 答:用户控件就是.ascx扩展名的...

    ZendFramework中文文档

    1. Introduction to Zend Framework 1.1. 概述 1.2. 安装 2. Zend_Acl 2.1. 简介 2.1.1. 关于资源(Resource) 2.1.2. 关于角色(Role) 2.1.3. 创建访问控制列表(ACL) ...2.1.5. 定义访问控制 ...

Global site tag (gtag.js) - Google Analytics