`
zsjg13
  • 浏览: 142392 次
  • 性别: Icon_minigender_1
  • 来自: 安徽
社区版块
存档分类
最新评论

如何开发一个Service

    博客分类:
  • CXF
 
阅读更多

CXF provides you with many options to build services. This guide is meant to give you a quick overview of those options and help you orient yourself quickly with CXF.

Different Types Of Services

CXF support three major types of services:

  • SOAP - this page summarizes the options for creating SOAP services.
  • REST-ful - REST support is described here.
  • CORBA

JAX-WS Annotated Services from Java

The JAX-WS APIs include a set of annotations which allow you to build services using annotated classes. These services are based on a single class which contains a set of operations.

Here's a simple example:

@WebService
public class Hello {
  public String sayHi(String name) {
    return "Hello " + name;
  }
}

JAX-WS includes many more annotations as well such as:

  • @WebMethod - allows you to customize the operation name, exclude the operation from inclusion in the service, etc
  • @WebParam - allows you to customize a parameter's name, namespace, direction (IN or OUT), etc
  • @WebResult - allows you to customize the return value of the web service call

Data is marshalled from XML to Java and vice versa via the JAXB data-binding.

Services are publish via one of two means:

  • The JAX-WS standard Endpoint APIs
  • CXF's XML configuration format - i.e. <jaxws:endpoint ... />

More Information: A simple JAX-WS service, Developing a JAX-WS Service (goes into much more depth), Writing a service with Spring

JAX-WS Annotated Services from WSDL

If you have existing WSDLs for your service or wish to write your WSDL first and then generate classes, CXF has many tools to help you do this.

The WSDL2Java tool will generate a JAX-WS annotated service and server stub from your WSDL. You can run it one of three ways:

Note that CXF generally restricts WSDL support to WSI-BP, not the full WSDL 1.1 specification.

There is also a Simple Frontend that allows you to create services without usage of Java annotations, using XML configuration files instead.

JAX-WS Providers

JAX-WS Providers allow you to create services which work at the message level - as opposed to the operation level as with annotated classes. The have a single operation "invoke" which receives either the message payload (i.e. the SOAP Body) or the whole message itself (i.e. the SOAP Envelope).

Here's a simple example:

@WebServiceProvider
public class HelloProvider {
  public Source invoke(Source request) {
    return ....;
  }
}

Services are publish via one of two means:

  • The JAX-WS standard Endpoint APIs
  • CXF's XML configuration format - i.e. <jaxws:endpoint ... />

More Information: Developing a JAX-WS Service

Javascript

CXF provides a Javascript module which allows you to build services in Javascript with the Java Rhino library. One advantage of this is that you can use E4X to interact more easily with the XML. For more information see the JavaScript page.

 

 

分享到:
评论

相关推荐

    android多个activity和一个service通信

    在实际项目中,常常需要多个Activity与一个Service进行通信,比如本例中提到的“service在后台下载”场景。这种通信机制对于实现应用的流畅性和功能完整性至关重要。 首先,我们来看如何创建和启动一个Service。...

    XML Web Service开发

    本教程旨在为初学者提供一个深入理解XML Web Service开发的基础,帮助他们掌握这一核心技术。 一、XML Web Service基础 XML Web Service的核心在于XML,它是一种通用的数据表示语言,具有自我描述性和平台无关性。...

    Oracle Service Bus实例开发详解

    1. **创建 Oracle Service Bus Project**:在Oracle Workshop中,选择`File &gt; New &gt; Oracle Service Bus Project`来创建一个新的项目。 2. **配置 Configuration**:为项目创建一个Configuration,即配置文件。在这...

    Android 多个service的action 相同冲突 验证demo

    默认情况下,Android只会启动一个Service,即使有多个Service声明了相同的ACTION。这可能导致某些Service无法正常启动,或者开发者期望的行为没有得到满足。 为了解决这个问题,Android提供了几种策略来处理这种...

    PB11开发Web Service应用介绍

    1、创建PB11项目:使用PB11创建一个新的项目,选择Web Service应用模板。 2、设计Web Service接口:使用PB11的数据窗口设计器设计Web Service的接口,定义服务的输入和输出参数。 3、实现Web Service逻辑:使用PB...

    Axis开发Web Service实例

    1. **编写服务端接口类**:创建一个简单的Java类,例如`HelloClient`,该类包含一个名为`getName`的方法。 ```java public class HelloClient { public String getName(String name) { return "hello " + name; ...

    wps二次开发moffice-service,moffice-service-base

    比如,可以构建一个在线文档编辑平台,让用户无需安装WPS即可在线编辑和预览文档;也可以用于企业内部的文档管理系统,实现文档的统一格式转换和版本控制;或者在教育领域,开发出适应教学场景的特殊功能,如自动...

    T100 Web Service 接口开发v1.5版.rar

    综上所述,T100 Web Service接口开发v1.5版是一个全面的解决方案,涵盖了接口设计、开发、测试和应用等多个环节。通过深入学习提供的文档、示例和库文件,开发者能够有效地利用这个接口实现T100PDA与其他系统的数据...

    PB11开发Web Service应用

    "PB11 開發Web Service 應用.pdf"文档很可能会包含具体的实例,指导开发者如何从头开始创建一个简单的Web Service,包括定义服务接口、实现业务逻辑、发布服务以及在PB11中创建客户端进行调用等步骤。 五、学习资源...

    Android 的 Remote Service 开发实例RemoteService

    3. 实现服务:创建一个继承自`Service`的类,如`RemoteServiceImpl`,并实现AIDL接口: ```java public class RemoteServiceImpl extends Service { private final IRemoteService.Stub binder = new ...

    安卓开发观察者模式应用-一个service通知多个activity更新ui的实现

    在安卓开发中,观察者模式(Observer Pattern)是一种设计模式,它定义了对象之间的一对多依赖关系,当一个对象的状态发生改变时,所有依赖于它的对象都会得到通知并自动更新。这种模式常用于实现事件驱动编程,尤其...

    一个最简单的Service DEMO

    本"一个最简单的Service DEMO"旨在提供基础的Service使用教程,帮助开发者了解如何在Android应用中创建和使用Service。我们可以通过参看链接(已失效)获取更详细的信息。 首先,Service的创建通常涉及以下步骤: ...

    安卓开发远程service通信

    1. **定义AIDL(Android Interface Definition Language)文件**:首先,我们需要创建一个.AIDL文件,这个文件定义了Service公开给客户端调用的接口。在.AIDL文件中,我们可以声明方法和参数类型,Android编译器会...

    Service与多个Activity交互

    1. **启动Service:** Activity可以通过startService()方法启动一个Service,Service会在后台持续运行,直到stopSelf()或stopService()被调用。 2. **绑定Service:** 使用bindService()方法,Activity可以与Service...

    一个Activity 调用Service接口的DEMO

    本DEMO将详细解释如何在一个Activity中调用Service接口,以便在后台执行特定任务。 首先,我们需要创建一个Service类。在AndroidManifest.xml文件中,必须声明这个Service,这样系统才能知道它的存在。声明Service...

    Web Service开发指南

    AXIS是Apache软件基金会的一个项目,主要用于简化Web Service的开发、部署和调用。AXIS提供了一个强大的SOAP客户端和服务器端实现,使得开发者可以轻松地创建和使用Web Service。以下是使用AXIS开发Web Service的...

    WindowsService开发实例加说明

    在.NET框架中,Windows服务...综上所述,Windows Service在.NET中是一个强大且灵活的工具,可用于实现后台自动化任务和系统级功能。理解其基本架构和开发流程,能够帮助开发者高效地构建和维护这样的系统服务。

    xfire开发Web Service接口详解

    在"xfire开发Web Service接口第一个程序"这个文件中,你可能会找到一个简单的示例,展示如何创建一个计算两个数相加的Web Service。这个例子可能包括定义服务接口、实现接口、配置服务以及启动服务的步骤。通过分析...

    Android开发之Service用法实例

    Service是一个生命周期较长而且没有界面的程序。 下面通过一个播放mp3的例子来学习。 先看MainActivity.java package com.example.servicetest; import android.app.Activity; import android.content.Intent; ...

    Android 的 Remote Service 开发实例RemoteServiceClient

    本教程将深入探讨如何开发一个Android的Remote Service,并创建一个名为`RemoteServiceClient`的客户端来与其进行通信。 首先,我们需要理解Remote Service的基本概念。Remote Service是Android中跨进程通信(IPC,...

Global site tag (gtag.js) - Google Analytics