简体   繁体   中英

Using CXF web service from java web start

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

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.

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)

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;

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/") 

Do I also need to change this?

You are going to need to change that wsdlLocation to a classpath: reference.

use -wsdlLocation as shown here .

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM