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

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

问题描述

更新:我已将我的问题提交给CXF用户的邮件列表, here

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)

我没有签署我的网络启动应用程序,并且不愿意因为我是不从客户端的计算机访问任何资源。提到的 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.jar wsdl4j.jar 实际上在您的类路径中。我以为我已经验证了这一点,但是因为我是通过webstart从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启动使用CXF Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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