java web service cxf,从java web启动使用CXF Web服务

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.(Unknown Source)

at com.sun.xml.internal.ws.client.WSServiceDelegate.(Unknown Source)

at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(Unknown Source)

at javax.xml.ws.Service.(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?

解决方案

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!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值