我们已经使用 JAX-WS 和 ProSyst OSGi 创建了一个 Web 服务。使用以下代码访问服务在独立的 Java 应用程序以及 ProSyst 框架中都可以正常工作。
this.service = new MyServicePortService(
new URL("http://" + host + ":" + port + "/MyService?wsdl"),
new QName("http://myservice.example.com/", "MyServicePortService"));
this.client = this.service.getMyServicePort();
AS JAX-WS 需要一些包,javax.*
而其他包我必须让它们由框架包导出。这是通过告诉 ProSyst 框架通过其配置导出它们来完成的,但也可以通过使用以下导出语句编写扩展包来完成:(我们为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)
有人知道如何解决这个问题吗?或者是否有其他/更好的可能性从春分访问服务?(不使用 DOSGI,因为其他本地应用程序也应该可以访问该服务)。
谢谢是提前