简体   繁体   中英

Can't access the wsdl using ApacheCXF dosgi

I'm using Apache CXF D-OSgi and Eclipse Equinox as my development environment, I register the service, but I can't open the wsdl page in IE. The service register codes are below:

 `      Dictionary<String, String> props = new Hashtable<String, String>();
    props.put("osgi.remote.interfaces", "*");       
    props.put("osgi.remote.configuration.type","pojo");
    props.put("osgi.remote.configuration.pojo.address", "http://localhost:9000/1");

        sr = bundleContext.registerService
    (service1.class.getName(), new impl1(), props);`

When I try to run client program, it shows the error below:

Caused by: java.net.SocketException: SocketException invoking http://localhost:9000/1: Network is unreachable: connect
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:2058)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:2043)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:639)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
... 43 more

Caused by: java.net.SocketException: Network is unreachable: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1955)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1907)
at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:42)
at org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1974)
... 46 more

2011-5-10 23:22:04 org.apache.cxf.dosgi.topologymanager.RemoteServiceAdminListenerImpl remoteAdminEvent

信息: Unhandled event type received: 1 2011-5-10 23:22:04 org.apache.cxf.dosgi.topologymanager.TopologyManager$1 modifiedService 信息: TopologyManager: EndpointListener changed ... 2011-5-10 23:22:04 org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminCore importService 信息: importService() Endpoint: {endpoint.id=http://localhost:9000/1, objectClass=[Ljava.lang.String;@988707, osgi.remote.configuration.pojo.address=http://localhost:9000/1, osgi.remote.configuration.type=pojo, osgi.remote.interfaces= , service.imported=true, service.imported.configs=org.apache.cxf.ws} 2011-5-10 23:22:04 org.apache.cxf.dosgi.topologymanager.RemoteServiceAdminListenerImpl remoteAdminEvent 信息: Unhandled event type received: 1 2011-5-10 23:22:04 org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminCore importService 信息: importService() Endpoint: {endpoint.id=http://localhost:9000/1, objectClass=[Ljava.lang.String;@988707, osgi.remote.configuration.pojo.address=http://localhost:9000/1, osgi.remot e.configuration.type=pojo, osgi.remote.interfaces= , service.imported=true, service.imported.configs=org.apache.cxf.ws} 2011-5-10 23:22:04 org.apache.cxf.dosgi.topologymanager.RemoteServiceAdminListenerImpl remoteAdminEvent 信息: Unhandled event type received: 1

I think those are inaccurate properties to register a service for remoting.

I faced the same problem (of not getting WSDL shown up when accessed from a browser, though the OSGi console says my service registered successfully), but could get this working by using the following properties to remote a service in CXF OSGi

props.put("service.exported.interfaces", "*");
    props.put("service.exported.configs", "org.apache.cxf.ws");
    props.put("org.apache.cxf.ws.address", "http://localhost:8080/TDMSAPIService");

Hope that helps.

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