Difference between revisions of "SMILA/Documentation/PublishingJAXWSWebservices"

From Eclipsepedia

Jump to: navigation, search
(New page: == Creating Webservices in SMILA from OSGi services using JAX-WS == '''''This is currently only available in the Galileo-Migration branch ''''' SMILA includes a simple tool now that make...)
 
Line 1: Line 1:
== Creating Webservices in SMILA from OSGi services using JAX-WS ==
+
== Creating Webservices in SMILA from OSGi services using JAX-WS ==
  
'''''This is currently only available in the Galileo-Migration branch '''''
 
  
 
SMILA includes a simple tool now that make it possible to publish OSGi services which are implemented as JAX-WS webservices so that they can be accessed externally using HTTP/SOAP. The short story is:
 
SMILA includes a simple tool now that make it possible to publish OSGi services which are implemented as JAX-WS webservices so that they can be accessed externally using HTTP/SOAP. The short story is:
 +
  
* activate bundle <tt>org.eclipse.smila.webservice</tt>
+
*activate bundle <tt>org.eclipse.smila.webservice</tt>
* register you JAX-WS class as an OSGI service and add a property <tt>org.eclipse.smila.ws</tt> that specifies the service name in the HTTP-URL. You can use either Declarative Services to do this or do the registration manually in code.
+
* access the webservice under <tt>http://<your-hostname>:8081/<service-name>?wsdl</tt>
+
*register you JAX-WS class as an OSGI service and add a property <tt>org.eclipse.smila.ws</tt> that specifies the service name in the HTTP-URL. You can use either Declarative Services to do this or do the registration manually in code.
 +
 +
*access the webservice under <tt>http://&lt;your-hostname&gt;:8081/&lt;service-name&gt;?wsdl</tt>
  
=== Configuration of the Webservice Publisher ===
+
=== Configuration of the Webservice Publisher ===
  
 
The Webservice Publisher in bundle <tt>org.eclipse.smila.webservice</tt> is basically a Service Tracker that looks for all services with a property <tt>org.eclipse.smila.ws</tt> and publishs them using the standard JAX-WS integration in Java 6 JDKs. The only thing that can be configured currently is how the webservice's URL is constructed. This is done in a simple configuration property file named <tt>webservice.properties</tt> that is located in <tt>configuration/org.eclipse.smila.webservice</tt>. If no such file exists, the default settings are used. Also, all properties in the file are optional.
 
The Webservice Publisher in bundle <tt>org.eclipse.smila.webservice</tt> is basically a Service Tracker that looks for all services with a property <tt>org.eclipse.smila.ws</tt> and publishs them using the standard JAX-WS integration in Java 6 JDKs. The only thing that can be configured currently is how the webservice's URL is constructed. This is done in a simple configuration property file named <tt>webservice.properties</tt> that is located in <tt>configuration/org.eclipse.smila.webservice</tt>. If no such file exists, the default settings are used. Also, all properties in the file are optional.
 +
  
; webservice.hostname  
+
;webservice.hostname  
: The host name part of the webservice URL. If not set, the publisher tries to determine the hostname using <tt>java.net.InetAddress</tt>, if this does not work, <tt>localhost</tt> is used. Note that if you need to access your webservice using <tt>http://localhost:...</tt>, you must specify <tt>webservice.hostname=localhost</tt> here. Else you must use the correct hostname to connect to the webservice.
+
; webservice.port  
+
:The host name part of the webservice URL. If not set, the publisher tries to determine the hostname using <tt>java.net.InetAddress</tt>, if this does not work, <tt>localhost</tt> is used. Note that if you need to access your webservice using <tt>http://localhost:...</tt>, you must specify <tt>webservice.hostname=localhost</tt> here. Else you must use the correct hostname to connect to the webservice.
: The TCP/IP port of the webservice server. Default is 8081, as 8080 is already used by the HTTP server in SMILA.
+
; webservice.webroot  
+
;webservice.port  
: A common root part for the webservice URLs. Default is empty.
+
 +
:The TCP/IP port of the webservice server. Default is 8081, as 8080 is already used by the HTTP server in SMILA.
 +
 +
;webservice.webroot  
 +
 +
:A common root part for the webservice URLs. Default is empty.
  
The webservice URL is constructed like this: <tt>http://<webservice.hostname>:<webservice.port>/<webservice.webroot>/<service-name></tt>
+
The webservice URL is constructed like this: <tt>http://&lt;webservice.hostname&gt;:&lt;webservice.port&gt;/&lt;webservice.webroot&gt;/&lt;service-name&gt;</tt>
 +
  
=== Examples ===
+
=== Examples ===
  
 
A simple HelloWorld service is contained in bundle <tt>org.eclipse.smila.webservice.test</tt>. It also includes WSDL/XSD files generated from the service class, client stubs generated from the WSDL file and the batch files to generate this stuff (though the WSDL and service client class have been manipulated a bit afterwards). The service is started using OSGi Declarative Services, so <tt>OSGI-INF/component.xml</tt> is an example of how to define the service property the publisher looks for in DS. If you copy the publisher configuration in this bundle to your configuration area and activate the bundle (and the publisher bundle, of course), the service should be accessible under <tt>http://localhost:8081/smila-ws/helloworld</tt>.
 
A simple HelloWorld service is contained in bundle <tt>org.eclipse.smila.webservice.test</tt>. It also includes WSDL/XSD files generated from the service class, client stubs generated from the WSDL file and the batch files to generate this stuff (though the WSDL and service client class have been manipulated a bit afterwards). The service is started using OSGi Declarative Services, so <tt>OSGI-INF/component.xml</tt> is an example of how to define the service property the publisher looks for in DS. If you copy the publisher configuration in this bundle to your configuration area and activate the bundle (and the publisher bundle, of course), the service should be accessible under <tt>http://localhost:8081/smila-ws/helloworld</tt>.
 +
  
 
The test bundle <tt>org.eclipse.smila.processing.bpel.test</tt> also contains a BPEL file <tt>helloworldpipeline.bpel</tt> that invokes this service with an attribute value from the processed record and writes the result back to the same attribute in this record.
 
The test bundle <tt>org.eclipse.smila.processing.bpel.test</tt> also contains a BPEL file <tt>helloworldpipeline.bpel</tt> that invokes this service with an attribute value from the processed record and writes the result back to the same attribute in this record.
 +
  
 
These are only very simple examples, and admittedly we did not do more complex tests yet. If something in JAX-WS does not work with the SMILA webservice publisher please let us know. Also any other suggestions for improvement are highly appreciated. Thank you very much.
 
These are only very simple examples, and admittedly we did not do more complex tests yet. If something in JAX-WS does not work with the SMILA webservice publisher please let us know. Also any other suggestions for improvement are highly appreciated. Thank you very much.
 +
  
 
[[Category:SMILA]]
 
[[Category:SMILA]]

Revision as of 03:42, 20 July 2009

Creating Webservices in SMILA from OSGi services using JAX-WS

SMILA includes a simple tool now that make it possible to publish OSGi services which are implemented as JAX-WS webservices so that they can be accessed externally using HTTP/SOAP. The short story is:


  • activate bundle org.eclipse.smila.webservice
  • register you JAX-WS class as an OSGI service and add a property org.eclipse.smila.ws that specifies the service name in the HTTP-URL. You can use either Declarative Services to do this or do the registration manually in code.
  • access the webservice under http://<your-hostname>:8081/<service-name>?wsdl

Configuration of the Webservice Publisher

The Webservice Publisher in bundle org.eclipse.smila.webservice is basically a Service Tracker that looks for all services with a property org.eclipse.smila.ws and publishs them using the standard JAX-WS integration in Java 6 JDKs. The only thing that can be configured currently is how the webservice's URL is constructed. This is done in a simple configuration property file named webservice.properties that is located in configuration/org.eclipse.smila.webservice. If no such file exists, the default settings are used. Also, all properties in the file are optional.


webservice.hostname
The host name part of the webservice URL. If not set, the publisher tries to determine the hostname using java.net.InetAddress, if this does not work, localhost is used. Note that if you need to access your webservice using http://localhost:..., you must specify webservice.hostname=localhost here. Else you must use the correct hostname to connect to the webservice.
webservice.port
The TCP/IP port of the webservice server. Default is 8081, as 8080 is already used by the HTTP server in SMILA.
webservice.webroot
A common root part for the webservice URLs. Default is empty.

The webservice URL is constructed like this: http://<webservice.hostname>:<webservice.port>/<webservice.webroot>/<service-name>


Examples

A simple HelloWorld service is contained in bundle org.eclipse.smila.webservice.test. It also includes WSDL/XSD files generated from the service class, client stubs generated from the WSDL file and the batch files to generate this stuff (though the WSDL and service client class have been manipulated a bit afterwards). The service is started using OSGi Declarative Services, so OSGI-INF/component.xml is an example of how to define the service property the publisher looks for in DS. If you copy the publisher configuration in this bundle to your configuration area and activate the bundle (and the publisher bundle, of course), the service should be accessible under http://localhost:8081/smila-ws/helloworld.


The test bundle org.eclipse.smila.processing.bpel.test also contains a BPEL file helloworldpipeline.bpel that invokes this service with an attribute value from the processed record and writes the result back to the same attribute in this record.


These are only very simple examples, and admittedly we did not do more complex tests yet. If something in JAX-WS does not work with the SMILA webservice publisher please let us know. Also any other suggestions for improvement are highly appreciated. Thank you very much.