Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Publish ECF Remote Service As WebService"
Line 1: | Line 1: | ||
With ECF, the remote services can be published "automatically" as web service. | With ECF, the remote services can be published "automatically" as web service. | ||
− | Below is an example of doing this for an existing remote service example available | + | Below is an example of doing this for an existing remote service example available [http://wiki.eclipse.org/Getting_Started_with_ECF's_OSGi_Remote_Services_Implementation here]. |
The code is currently located on the [http://ecf1.osuosl.org ECF OSUOSL] site. Here's the CVS information for this site: | The code is currently located on the [http://ecf1.osuosl.org ECF OSUOSL] site. Here's the CVS information for this site: | ||
Line 12: | Line 12: | ||
plugins/org.eclipse.ecf.remoteservice.soap.host | plugins/org.eclipse.ecf.remoteservice.soap.host | ||
</pre> | </pre> | ||
+ | |||
+ | ==Publishing the remote service as WS== | ||
+ | Below is a short description of how to publish as a web service the remote Hello Example Service defined [http://wiki.eclipse.org/Getting_the_Hello_Example_Service here]. | ||
+ | |||
+ | <source lang="java"> | ||
+ | |||
+ | // Lookup IRemoteServiceReference | ||
+ | IRemoteServiceReference[] serviceReferences = container.getContainerAdapter().getRemoteServiceReferences(targetID, IHello.class.getName(), null); | ||
+ | |||
+ | // Get remote service for reference | ||
+ | if(serviceReferences == null ||serviceReferences.length == 0) | ||
+ | throw new ECFException("The remote reference is not available : "+IHello.class.getName()); | ||
+ | |||
+ | IRemoteServiceReference reference = serviceReferences[0]; | ||
+ | IRemoteService remoteService = container.getContainerAdapter().getRemoteService(reference); | ||
+ | |||
+ | ISoapServerContainerAdapter soapContainerAdapter = (ISoapServerContainerAdapter) ContainerFactory.getDefault().createContainer().getAdapter(ISoapServerContainerAdapter.class); | ||
+ | //"hello" It will be the web service name and "*" the allowedMethod | ||
+ | soapContainerAdapter.deployRemoteServiceAsWebService("hello", "*", remoteService); | ||
+ | |||
+ | |||
+ | </source> | ||
+ | |||
+ | After it the web service can be consumed through the endpoint "http://localhost:8080/services/hello"; |
Revision as of 05:12, 20 June 2010
With ECF, the remote services can be published "automatically" as web service.
Below is an example of doing this for an existing remote service example available here.
The code is currently located on the ECF OSUOSL site. Here's the CVS information for this site:
anonymous: :pserver:anonymous@ecf1.osuosl.org:/ecf extssh: :extssh:ecf1.osuosl.org:/home/cvs/ecf module: plugins/org.eclipse.ecf.remoteservice.soap.host
Publishing the remote service as WS
Below is a short description of how to publish as a web service the remote Hello Example Service defined here.
// Lookup IRemoteServiceReference IRemoteServiceReference[] serviceReferences = container.getContainerAdapter().getRemoteServiceReferences(targetID, IHello.class.getName(), null); // Get remote service for reference if(serviceReferences == null ||serviceReferences.length == 0) throw new ECFException("The remote reference is not available : "+IHello.class.getName()); IRemoteServiceReference reference = serviceReferences[0]; IRemoteService remoteService = container.getContainerAdapter().getRemoteService(reference); ISoapServerContainerAdapter soapContainerAdapter = (ISoapServerContainerAdapter) ContainerFactory.getDefault().createContainer().getAdapter(ISoapServerContainerAdapter.class); //"hello" It will be the web service name and "*" the allowedMethod soapContainerAdapter.deployRemoteServiceAsWebService("hello", "*", remoteService);
After it the web service can be consumed through the endpoint "http://localhost:8080/services/hello";