UNO Web Service Proxy | |||||
| |||||
1. Introduction | |||||
Web services are more and more emerging. Some examples are Google and Amazon which are providing a Web service interface for their traditional services, like searching the Web or querying the online bookstore. These interfaces could now be reached by UNO and StarBasic over the UNO Web service proxy. The access with StarBasic is very convenient because of special features of the StarBasic-UNO language binding, as you can see in the given examples. The component is developed in Java and uses the JavaTM Web Services Developer Pack (JWSDP) 1.0_01 [JWSDP]. It adds more functionality in terms of dynamically invoking Web services. Thus one could provide at any time a Web service description defined with the Web Service Description Language (WSDL) and one could access its interfaces. | |||||
2. Architecture | |||||
The main entry point is the ProxyFactory, which is a realization of the UNO interface com.sun.star.webservices.proxy.XProxyFactory . A WSDL [CHRI01] must be provided for instantiating the ProxyFactory, thus the ProxyFactory could consume the WSDL for getting extended reflection and type information. Each Web service -based on WSDL- consists of a number of services. In turn each service holds ports. Thus a caller receives an object from the class InvocationProxy, which is a mapping of the requested port inside a service. After this step the caller could call the methods of the Web service through the InvocationProxy. The following examples are given in StarBasic code. The examples are working with the GoogleTM Web APIs service [GOOG02]. You need to register at http://www.google.com/apis in order to be able to get access. |
|||||
'Getting
the UNO service |
|||||
Basic example for the initializing of the ProxyFactory and the InvocationProxy |
|||||
Because the InvocationProxy implements the XInvocation interface, in Basic the call of a Web service is looking like an ordinary call of a function: |
|||||
' The Web service returns an
XPropertySet. |
|||||
Example for calling the Web service and receiving the return value |
|||||
If the Web service is returning a complex data type, it is returned by the component as an XPropertySet. Thus one could easily access the members of the complex type, by referring to the names of the members. |
|||||
'This shows all the properties of this
XPropertySet |
|||||
Example of processing the received XPropertySet |
|||||
If the user of the component needs to provide a complex type, one could first create the complex type by calling the method createComplex on the ProxyFactory. One must provide the full qualified name, by including the XML namespace and the localname [BRAY99] for this complex data type. Both , the namepace and the localname are part of the WSDL. The method returns again an XPropertySet, where the user could access the member of the PropertySet. The names of the members are the corresponding names of the complex data type given in the WSDL. |
|||||
<complexType name="MyBean"> |
|||||
XML example for a complex data type |
|||||
3. Type Mapping |
|||||
|
|||||
The illustration above shows all the involved components. Because there exists no equal types in every component (UNO, JWSDP or SOAP) for the simple and complex types of a Web service, a type mapping is needed. The following table describes the type mapping between the XML types, transfered with SOAP, the JWSDP and the UNO/StarBasic types. |
|||||
XML schema data types* |
JWSDP |
UNO |
|||
xsd:string |
java.lang.String |
string |
|||
xsd:integer |
java.math.BigInteger |
-not supported- |
|||
xsd:int |
int |
long |
|||
xsd:long |
long |
hypher |
|||
xsd:shor |
short |
short |
|||
xsd:decimal |
java.math.BigDecimal |
-not supported- |
|||
xsd:float |
float |
float |
|||
xsd:double |
double |
double |
|||
xsd:boolean |
boolean |
boolean |
|||
xsd:byte |
byte |
byte |
|||
xsd:QName |
javax.xml.namespace.QName |
-not supported- |
|||
xsd:dateTime |
java.util.Calendar |
-not supported- |
|||
xsd:base64Binary |
byte[] |
sequence<byte> |
|||
xsd:hexBinary |
byte[] |
sequence<byte> |
|||
soapenc:string |
java.lang.String |
string |
|||
soapenc:boolean |
java.lang.Boolean |
boolean |
|||
soapenc:float |
java.lang.Float |
float |
|||
soapenc:double |
java.lang.Double |
double |
|||
soapenc:decimal |
java.math.BigDecimal |
-not supported- |
|||
soapenc:int |
java.lang.Integer |
long |
|||
soapenc:short |
java.lang.Short |
short |
|||
soapenc:byte |
java.lang.Byte |
byte |
|||
soapenc:base64 |
byte[] |
sequence<byte> |
|||
* XML schema data types as specified in the XML Schema specifications, Part 1 [SCHEMA1] and Part 2 [SCHEMA2], and SOAP 1.1 encoding specification [SOAP1.1]. |
|||||
4. To Do | |||||
|
|||||
<xsd:element name="GetFedACHCities"> |
|||||
Example of an anonymous complex type inside element tags |
|||||
|
|||||
5. Download/ Installing Instructions |
|||||
You need -at least- the developer build 643C of OpenOffice.org and the requirements defined by the JWSDP.
|
|||||
<your-jwsdp-installation-path>/common/lib/jaxp-api.jar: <your-jwsdp-installation-path>/common/endorsed/dom.jar: <your-jwsdp-installation-path>/common/endorsed/sax.jar: <your-jwsdp-installation-path>/common/endorsed/xalan.jar: <your-jwsdp-installation-path>/common/endorsed/xercesImpl.jar: <your-jwsdp-installation-path>/common/endorsed/xsltc.jar: <your-jwsdp-installation-path>/common/lib/saaj-api.jar: <your-jwsdp-installation-path>/common/lib/saaj-ri.jar: <your-jwsdp-installation-path>/common/lib/activation.jar: <your-jwsdp-installation-path>/common/lib/commons-logging.jar: <your-jwsdp-installation-path>/common/lib/dom4j.jar: <your-jwsdp-installation-path>/common/lib/mail.jar: <your-jwsdp-installation-path>/common/lib/jaxrpc-api.jar: <your-jwsdp-installation-path>/common/lib/jaxrpc-ri.jar |
|||||
Please replace <your-jwsdp-installation-path> with the installation path of the JWSDP and be sure that there are no spaces after the colons! |
|||||
For Windows users: Add the following path to your SystemClasspath property inside java.ini (<office_dir>\user\config\java.ini) : |
|||||
<your-jwsdp-installation-path>\common\lib\jaxp-api.jar; <your-jwsdp-installation-path>\common\endorsed\dom.jar; <your-jwsdp-installation-path>\common\endorsed\sax.jar; <your-jwsdp-installation-path>\common\endorsed\xalan.jar; <your-jwsdp-installation-path>\common\endorsed\xercesImpl.jar; <your-jwsdp-installation-path>\common\endorsed\xsltc.jar; <your-jwsdp-installation-path>\common\lib\saaj-api.jar; <your-jwsdp-installation-path>\common\lib\saaj-ri.jar; <your-jwsdp-installation-path>\common\lib\activation.jar; <your-jwsdp-installation-path>\common\lib\commons-logging.jar; <your-jwsdp-installation-path>\common\lib\dom4j.jar; <your-jwsdp-installation-path>\common\lib\mail.jar; <your-jwsdp-installation-path>\common\lib\jaxrpc-api.jar; <your-jwsdp-installation-path>\common\lib\jaxrpc-ri.jar |
|||||
|
|||||
-Xbootclasspath/p: <your-jwsdp-installation-path>/common/endorsed/xercesImpl.jar: <your-jwsdp-installation-path>/common/endorsed/dom.jar: <your-jwsdp-installation-path>/common/endorsed/sax.jar: <your-jwsdp-installation-path>/common/endorsed/xalan.jar: <your-jwsdp-installation-path>/common/endorsed/xsltc.jar |
|||||
For Windows users: Please add the following line at the end of your java.ini file: |
|||||
-Xbootclasspath/p: <your-jwsdp-installation-path>\common\endorsed\xercesImpl.jar; <your-jwsdp-installation-path>\common\endorsed\dom.jar; <your-jwsdp-installation-path>\common\endorsed\sax.jar; <your-jwsdp-installation-path>\common\endorsed\xalan.jar; <your-jwsdp-installation-path>\common\endorsed\xsltc.jar |
|||||
|
|||||
<office_dir>/program/pkgchk WebServiceProxy.zip |
|||||
Windows users please type: |
|||||
<office_dir>\program\pkgchk WebServiceProxy.zip |
|||||
Now you could test the installation of the component by typing the following lines of code inside a StarBasic module: |
|||||
proxyFac = createUNOService("com.sun.star.webservices.proxy.ProxyFactory") msgbox proxyFac.dbg_supportedinterfaces |
|||||
If there appears a message box with all the supported interfaces of the ProxyFactory you have successfully installed the component. Congratulations! |
|||||
6. Source Code |
|||||
If you are interested in the source of this project, please refer to: http://udk.openoffice.org/source/browse/udk/soap/proxy/src/ |
|||||
7. References |
|||||
[BRAY99] [CHRI01] [GOOG02] [JAXRP02] [JWSDP] [SCHEMA1] [SCHEMA2] [SOAP1.1] |
|||||
| |||||
Author: Jan Tietjens ($Date:
2002/12/27$) |
|||||
|
Thank's to WebCounter for counting the visitors of the page.