`
kakaluyi
  • 浏览: 438306 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

Xfire and JSR 181 Annotations

阅读更多
JSR 181 Annotations

We are working on adding JSR 181 2.0 support for annotations in XFire via Java 5 and commons-attributes. The Java 5 implementation will follow the JSR 181 spec and the commons-attributes implementation will mimic the spec in a pre-Java 5 way.

Currently we have not passed the TCK and this is available only in early access form only. However, what we have is fairly stable and we are working on passing the TCK as soon as it is out. (Yes we know the JSR 181 1.0 TCK is out, be we are intent on passing the 2.0 version as we are implementing JAX-WS as well).

As covered before, ServiceFactories are used to create services from classes. The default ServiceFactory is ObjectServiceFactory. To use annotations you must use the AnnotationsServiceFactory. You must pass it an annotation reader in the constructor which will read the particular type of annotation you are using.

Using Commons-Attributes Annotations

To use the commons-attributes annotations, you will need to follow these instructions on how to install the commons-attributes ant or maven plugin.

XFire xfire = XFireFactory.getInstance().getXFire();
TypeMappingRegistry registry = new DefaultTypeMappingRegistry();

AnnotationServiceFactory factory = new AnnotationServiceFactory(xfire.getTransportManager());
Service service = factory.create(YourService.class)
xfire.getServiceRegistry().register(service);

In your services.xml, it would look like this:

<service>

  <name>ServiceName</name>
  <namespace>urn:your:namespace</namespace>
  <serviceClass>your.service.Class</serviceClass>
  <serviceFactory>org.codehaus.xfire.annotations.AnnotationServiceFactory</serviceFactory>

</service>

Writing Services with Annotations

Javadocs (See the javax.jws packages only).

Example:

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

@WebService(name = "EchoService", targetNamespace = "http://www.openuri.org/2004/04/HelloWorld")
        public class Jsr181EchoService
{
    @WebMethod(operationName = "echoString", action = "urn:EchoString")
    @WebResult(name = "echoResult")
    public String echo(@WebParam(name = "echoParam", header = true) String input)
    {
        return input;
    }
}

Alternatively you can place your annotations in your interface and have your implementation refer to it as shown below.

The interface:

package com.example;

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

@WebService(name = "EchoService",  targetNamespace = "http://www.openuri.org/2004/04/HelloWorld")
public interface Jsr181EchoService
{
    @WebMethod(operationName = "echoString", action = "urn:EchoString")
    @WebResult(name = "echoResult")
    public String echo(@WebParam(name = "echoParam", header = true) String input);
}

and the implementation:

package com.example;

import javax.jws.WebService;

@WebService(endpointInterface = "com.example.Jsr181EchoService")
public class Jsr181EchoServiceImpl
{
    public String echo(String input)
    {
        return input;
    }
}

To do this with commons-attributes instead, you will need to import the attributes from a different location and use the commons-attributes syntax:

import org.codehaus.xfire.annotations.commons.WebMethod;
import org.codehaus.xfire.annotations.commons.WebParam;
import org.codehaus.xfire.annotations.commons.WebResult;
import org.codehaus.xfire.annotations.commons.WebService;

/**
 * @@WebService(name = "EchoService", targetNamespace = "http://www.openuri.org/2004/04/HelloWorld")
 * @@org.codehaus.xfire.annotations.commons.soap.SOAPBinding(style = 1)
 */
public class CommonsEchoService
{

    /**
     * Returns the input.
     *
     * @param input the input.
     * @return the input.
     * @@WebMethod(operationName = "echoString", action="urn:EchoString")
     * @@.echoParam WebParam("echoParam")
     * @@.return WebResult("echoResult")
     */
    public String echo(String inputString)
    {
        return inputString;
    }
}
评论

相关推荐

    xfire所有jar包

    activation.jar commons-logging.jar jdom-1.0.jar spring.jar spring-mock.jar stax-api-1.0.1.jar stax-utils-snapshot-20040917....xfire-jsr181-api-1.0-M1.jar xfire-spring-1.2.2.jar xfire-xmlbeans-1.2.2.jar

    xfire-1.2.6

    activation.jar commons-logging.jar jdom-1.0.jar spring-mock.jar spring.jar stax-api-1.0.1.jar ...xfire-jsr181-api-1.0-M1.jar xfire-spring-1.2.6.jar xfire-xmlbeans-1.2.6.jar xstream-1.3.1.jar

    xfire相关jar包

    进行WebService开发中所用到的xfire所有相关包如:xfire-jsr181-api-1.0-M1.jar、xfire-jaxws-1.2.6.jar、xfire-java5-1.2.6.jar、xfire-core-1.2.6.jar、xfire-annotations-1.2.6.jar、xfire-aegis-1.2.6.jar、...

    Xfire整合webservice jar包

    xfire-jsr181-api-1.0-M1.jar xfire-spring-1.2.2.jar xfire-xmlbeans-1.2.2.jar 支持将Web服务绑定到POJO、XMLBeans、JAXB1.1、JAXB2.0和Castor; 支持基于HTTP、JMS、XMPP等多种协议访问Web服务; 支持多种Web服务...

    xfirejar开发全部包

    xfirejar开发全部包 activation.jar commons-logging.jar jdom-1.0.jar spring.jar spring-mock.jar stax-api-1.0.1.jar ...xfire-jsr181-api-1.0-M1.jar xfire-spring-1.2.2.jar xfire-xmlbeans-1.2.2.jar

    xfire的jar

    xfire-aegis-1.2.6.jar,xfire-annotations-1.2.6.jar,xfire-core-1.2.6.jar,xfire-java5-1.2.6.jar,xfire-jaxb2-1.2.6.jar,xfire-jaxws-1.2.6.jar,xfire-jsr181-api-1.0-M1.jar,xfire-spring-1.2.6.jar

    xfire开发webservices相关全部jar包

    xfire开发webservices相关jar包: xfire-aegis-1.2.6.jar xfire-annotations-1.2.6.jar xfire-core-1.2.6.jar xfire-java5-1.2.6.jar xfire-jsr181-api-1.0-M1.jar xfire-spring-1.2.6.jar xfire-xmlbeans-1.2.6.jar

    Spring 2.0 开发参考手册

    使用XFire来暴露Web服务 17.6. 对远程接口不提供自动探测 17.7. 在选择这些技术时的一些考虑 18. Enterprise Java Bean(EJB)集成 18.1. 简介 18.2. 访问EJB 18.2.1. 概念 18.2.2. 访问本地的无状态Session ...

    Spring中文帮助文档

    12.4.2. TopLinkTemplate and TopLinkDaoSupport 12.4.3. 基于原生的TopLink API的DAO实现 12.4.4. 事务管理 12.5. iBATIS SQL Maps 12.5.1. 创建SqlMapClient 12.5.2. 使用 SqlMapClientTemplate 和 ...

    Spring API

    12.4.2. TopLinkTemplate and TopLinkDaoSupport 12.4.3. 基于原生的TopLink API的DAO实现 12.4.4. 事务管理 12.5. iBATIS SQL Maps 12.5.1. 创建SqlMapClient 12.5.2. 使用 SqlMapClientTemplate 和 ...

    spring chm文档

    Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright...

    Spring-Reference_zh_CN(Spring中文参考手册)

    1. 简介 1.1. 概览 1.2. 使用场景 2. Spring 2.0 的新特性 2.1. 简介 2.2. 控制反转(IoC)容器 2.2.1. 更简单的XML配置 2.2.2. 新的bean作用域 2.2.3. 可扩展的XML编写 2.3. 面向切面编程(AOP) 2.3.1. 更加简单的AOP ...

Global site tag (gtag.js) - Google Analytics