有什么区别Javax.jws和javax.xml.ws [英] What is difference Javax.jws and javax.xml.ws

查看:487
本文介绍了有什么区别Javax.jws和javax.xml.ws的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Java新手并试图跳转到WebServices。我在某处发现了两个例子,并与可用选项混淆。

I am new to Java and trying to jump into WebServices. I found two examples somewhere and a confused with the available options.

首先,带注释的javax.jws.WebService似乎工作正常,但javax.xml.ws上有大量材料。这两种方法有什么区别。似乎Javax.jws更新,并且没有太多可用的材料。请稍微说清楚。

Firstly, javax.jws.WebService with annotation seem to work fine but there is loads of material on javax.xml.ws. What is the difference between these two approaches. It seems Javax.jws is newer and there is not much material available on the same. Please throw some light.

谢谢和问候

推荐答案

网络服务元数据注释(JSR 181)



使用JSR 181规范中的注释( java.jws。 xxx ),您可以注释Web服务实现类或Web服务接口。

Web Services Metadata Annotations (JSR 181)

Using annotations from the JSR 181 specification (java.jws.xxx), you can annotate a Web service implementation class or a Web service interface.

例如来自 部署JAX-WS Tomcat上的Web服务

package com.mkyong.ws;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;

//Service Endpoint Interface
@WebService
@SOAPBinding(style = Style.RPC)
public interface HelloWorld{

    @WebMethod String getHelloWorldAsString();

}



JAX-WS 2.0注释(JSR 224)



JSR 224规范定义了JAX-WS 2.0的注释( javax.xml.ws。 xxx )。

例如来自 在Java JAX-WS中使用SOAP错误和异常

@WebFault(name="CheckVerifyFault",
    targetNamespace="http://www.example.com")
public class CheckVerifyFault extends Exception {

    /**
     * Java type that goes as soapenv:Fault detail element.
     */
    private CheckFaultBean faultInfo;

    public CheckVerifyFault(String message, CheckFaultBean faultInfo) {
        super(message);
        this.faultInfo = faultInfo;
    }

    public CheckVerifyFault(String message, CheckFaultBean faultInfo, 
                               Throwable cause) {
        super(message, cause);
        this.faultInfo = faultInfo;
    }

    public CheckFaultBean getFaultInfo() {
        return faultInfo;
    }
}






Peer Reynders 说:


我的猜测是,BEA想要在Weblogic中投入一些东西来与.NET中的等效功能竞争。 (请参阅,在WebLogic中开发Web服务非常简单)。此外,JAX-WS 2.0(JSR-224)中指定的注释似乎可为您提供更多控制。但是,JSR-224明确支持/包含JSR-181(由JSR-181定义的JSR-224:7.10注释)。

My guess would be that BEA wanted something NOW to put into Weblogic to compete with the equivalent feature in .NET. (see, developing Web services in WebLogic is just "as easy"). Also the annotations specified in JAX-WS 2.0 (JSR-224) seem to provide you with more control. However JSR-224 does explicitly support/include JSR-181 (JSR-224: 7.10 Annotations Defined by JSR-181).

For有关更完整的讨论,请参阅 JSR 181:Java简化请求

For a more complete discussion about, see JSR 181: a Java Simplification Request

参见:

  • Annotations references
  • JAX-WS annotations reference
  • JSR 181
  • JSR 224

这篇关于有什么区别Javax.jws和javax.xml.ws的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆