我们使用JAX-WS和ProSystem OSGi创建了一个Web服务。
在一个独立的Java应用程序中,使用以下代码访问服务是很好的
以及在ProSystem框架中。
this.service = new MyServicePortService(
new URL("http://" + host + ":" + port + "/MyService?wsdl"),
new QName("http://myservice.example.com/", "MyServicePortService"));
this.client = this.service.getMyServicePort();
因为JAX-WS需要一些来自
javax.*
还有一些我必须通过框架包导出它们。这可以通过告诉ProSystem框架通过其配置导出它们来完成,但也可以通过使用以下导出语句编写扩展包来完成:(我们为Equinox所做的工作)。
Export-Package
com.sun.net.ssl.internal.ssl
com.sun.xml
com.sun.xml.internal.bind.api
javax.crypto
javax.crypto.spec
javax.jw
javax.naming
javax.naming.directory
javax.naming.event
javax.naming.ldap
javax.naming.spi
javax.net
javax.net.ssl
javax.security.cert
javax.transaction.xa
javax.xml.bind.util
javax.xml.stream
javax.xml.transform.stax
javax.xml.ws
org.apache.log4j
sun.security.action
我的理解是,这也应该在Equinox中工作,因为它们使用相同的JVM。因此,如果这些包是可访问的,那么JAX-WS应该在这两个包中都工作。
但是,打电话
this.service.getMyServicePort()
将导致以下异常:
java.lang.IllegalArgumentException: interface com.sun.xml.internal.ws.developer.WSBindingProvider is not visible from class loader
at java.lang.reflect.Proxy.getProxyClass(Proxy.java:353)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
at com.sun.xml.internal.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSServiceDelegate.java:546)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:292)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:274)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:267)
at javax.xml.ws.Service.getPort(Service.java:92)
at com.example.myservice.MyServicePortService.MyServicePort(MyServicePortService.java:56)
at com.example.myservice.MyServicePort.<init>(MyServicePort.java:36)
at com.example.myservice.ClientActivator.activate(ClientActivator.java:78)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:230)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:140)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:330)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:560)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:182)
at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:393)
at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:176)
at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:791)
at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:758)
at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:90)
at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)
有人知道怎么解决这个问题吗?或者是否有其他/更好的可能性从Equinox访问服务?(不使用dosgi,因为其他本地应用程序也应该可以访问该服务)。
谢谢你的好意