从 java web start 使用 CXF web 服务 [英] Using CXF web service from java web start

查看:27
本文介绍了从 java web start 使用 CXF web 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:我已将我的问题提交到 CXF 用户的邮件列表,此处.

UPDATE: I have submitted my question to the CXF User's mailing list, here.

更新:我目前已经签署了我所有的罐子.我似乎仍然无法以可以找到 WSDL 的方式设置 CXF.我的最后一次尝试是将 WSDL 放在我的 WAr 文件中,以便我可以通过 Web 浏览器访问它.我将客户端内部的 wsdllocation 设置为 URL (http://www.example.com/应用程序/example.wsdl).我现在收到以下异常:

UPDATE: I have currently signed all of my jars. I still can't seem to get CXF setup in a way that it can find the WSDL. My last attempt was to place the WSDL inside of my WAr file so I can access it through a web browser. I set the wsdllocation inside of the client to the URL (http://www.example.com/app/example.wsdl). I am now getting the following exception:

Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError
at com.sun.xml.internal.ws.util.xml.XmlUtil.createDefaultCatalogResolver(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(Unknown Source)
at javax.xml.ws.Service.<init>(Unknown Source)

谷歌搜索几乎没有发现这一点.

Googling has turned up pretty much nothing on this.

我正在使用 Apache CXF 从给定的 WSDL 创建 Web 服务客户端.我遇到了问题,但是在尝试访问该服务时,出现此异常:

I am creating a web service client from a given WSDL using Apache CXF. I am running into problems however when trying to access the service, I get this exception:

Can not initialize the default wsdl from ../resource/example.wsdl
Exception in thread "AWT-EventQueue-0" java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)

我没有签署我的 web start 应用程序,也不想签署,因为我没有从客户端的机器访问任何资源.提到的 WSDL 打包在我的 jar 中.问题是由 CXF 生成的客户端代码引起的:

I am not signing my web start application, and would prefer not to since I am not accessing any resources from the client's machine. The WSDL mentioned is packaged within my jar. The problem is caused by this from the CXF generated client code:

    URL url = null;
    try {
        url = new URL("../resource/example.wsdl");
    } catch (MalformedURLException e) {
        System.err.println("Can not initialize the default wsdl from ../resource/example.wsdl");
        // e.printStackTrace();
    }
    WSDL_LOCATION = url;

我怎样才能正确地将 CXF 指向这个 WSDL?我也担心类上的WebService注解:

How can I correctly point CXF to this WSDL? I am also worried about the WebService annotation on the class:

@WebServiceClient(name = "Example", 
              wsdlLocation = "../resource/example.wsdl",
              targetNamespace = "http://services.example.com/") 

我还需要更改吗?

推荐答案

经过几次错误和实验后,我设法让一切正常工作.首先,确保 cxf.jarwsdl4j.jar 实际上在您的类路径上.我以为我已经验证了这一点,但是因为我通过 webstart 从一个 jar 中实例化客户端,该 jar 本身打包在 WAR 中,所以我在构建过程中弄乱了 cxf 运行时的位置.此外,在指定 wsdl 位置时,我必须使用 "classpath:my.wsdl".我让自己很轻松,只是将 wsdl 放在与我的源相同的位置.

After a few mistakes and experimentation, I have managed to get everything to work properly. First, MAKE SURE that cxf.jar and wsdl4j.jar are actually on your classpath. I thought I had verified this, but because I was instantiating the client from inside a jar via webstart that was in itself packed in a WAR, I messed up the placement of the cxf runtime in my build process. Also, when specifying the wsdl location, I had to use "classpath:my.wsdl". I made it easy on myself and just put the wsdl in the same location as my source.

希望这能帮助那些可能在某个时候做同样事情的人!

Hope this helps someone who might do the same thing at somepoint!

这篇关于从 java web start 使用 CXF web 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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