Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Publish ECF Remote Service As WebService"

 
(2 intermediate revisions by one other user not shown)
Line 3: Line 3:
 
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].
 
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 [https://github.com/ECF/SOAP https://github.com/ECF/SOAP].
  
 
<pre>
 
<pre>
anonymous:  :pserver:anonymous@ecf1.osuosl.org:/ecf
+
https://github.com/ECF/SOAP
extssh:  :extssh:ecf1.osuosl.org:/home/cvs/ecf
+
  
 
modules:  
 
modules:  
Line 40: Line 39:
 
After it the web service can be consumed through the endpoint "http://localhost:8080/services/hello";
 
After it the web service can be consumed through the endpoint "http://localhost:8080/services/hello";
  
Or can be used this approach, which send more specific info:
+
To consume this web service as a ECF remote service, can be used the ECF soap client provider. See the instructions [http://wiki.eclipse.org/SOAP-based_Providers here].
 +
 
 +
Another approach can be used to publish the web service, which sends more specific info for the Axis(running behind the scenes):
  
 
<source lang="java">
 
<source lang="java">
Line 73: Line 74:
  
 
After it the web service can be consumed through the endpoint "http://localhost:8080/services/hello";
 
After it the web service can be consumed through the endpoint "http://localhost:8080/services/hello";
 +
 +
Suggestions/Comments are welcome [https://bugs.eclipse.org/bugs/show_bug.cgi?id=290748 here]

Latest revision as of 05:18, 20 November 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 https://github.com/ECF/SOAP.

https://github.com/ECF/SOAP

modules: 
plugins/org.eclipse.ecf.remoteservice.soap.host
tests/org.eclipse.ecf.examples.tests.remoteservice.soap.host.hello

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);
 
//Publish the ECF remote service as WS
//Get the Soap Server container adapter
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";

To consume this web service as a ECF remote service, can be used the ECF soap client provider. See the instructions here.

Another approach can be used to publish the web service, which sends more specific info for the Axis(running behind the scenes):

// 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);
 
//Publish the ECF remote service as WS
//Get the Soap Server container adapter
ISoapServerContainerAdapter soapContainerAdapter =  (ISoapServerContainerAdapter) ContainerFactory.getDefault().createContainer().getAdapter(ISoapServerContainerAdapter.class);
 
//Create properties to send to Axis which runs behind the scenes
Map properties = new Properties();
properties.put(ISoapServerConstants.SERVICE_NAME, "hello");
//just allow the method hello
properties.put(ISoapServerConstants.ALLOWED_METHODS, "hello");
properties.put(ISoapServerConstants.PROVIDER, "java:RPC");
properties.put(ISoapServerConstants.SCOPE, "Application");
 
//Create the service description
IServiceDescription description = new ServiceDescription(properties);
 
soapContainerAdapter.deployRemoteServiceAsWebService(description, remoteService);

After it the web service can be consumed through the endpoint "http://localhost:8080/services/hello";

Suggestions/Comments are welcome here

Back to the top