Thursday, November 21, 2013

Download WSDL with import Schema files as a zip or gar file from WSO2 Governance Registry.

This sample demonstrate that how to download the WSDL file with  import Schema files as a zip or gar archive.

1. Download the latest WSO2 Governance Registry (version 4.6.0) from here. http://wso2.com/products/governance-registry/

2. You can find the installation instructions in the documentation. http://docs.wso2.org/display/Governance460/Installation

3. Go to the <GREG_HOME>/bin and execute the "ant" command. (This will copy client dependency jars to <GREG_HOME>/repository/lib  directory).

4.  Add the sample WSDL[i] (That WSDL contain import Schema) to  WSO2 Governance Registry Server.

Adding WSDL Doc http://docs.wso2.org/display/Governance460/Managing+WSDLs#ManagingWSDLs-AddingaWSDL

[i]https://svn.wso2.org/repos/wso2/people/ajith/blog/wsdl/WeatherForecastService.wsdl


5. After few second you should see the added WSDL file and Schema  files.



6. Open the WSDLDownload.java class from your IDE and add the following jars to class path (You can find the jars inside <GREG_HOME/repository/lib>)

axiom_1.2.11.wso2v4.jar
axis2_1.6.1.wso2v10.jar
commons-codec_1.4.0.wso2v1.jar
commons-httpclient_3.1.0.wso2v2.jar
httpcore_4.3.0.wso2v1.jar
neethi_2.0.4.wso2v4.jar
org.wso2.carbon.authenticator.stub_4.2.0.jar
org.wso2.carbon.base_4.2.0.jar
org.wso2.carbon.core.common_4.2.0.jar
org.wso2.carbon.governance.api_4.2.1.jar
org.wso2.carbon.governance.client-4.2.0.jar
org.wso2.carbon.logging_4.2.0.jar
org.wso2.carbon.registry.admin.api_4.2.0.jar
org.wso2.carbon.registry.api_4.2.0.jar
org.wso2.carbon.registry.common_4.2.1.jar
org.wso2.carbon.registry.core_4.2.0.jar
org.wso2.carbon.registry.indexing.stub-4.2.0.jar
org.wso2.carbon.registry.ws.client_4.2.0.jar
org.wso2.carbon.registry.ws.stub_4.2.0.jar
org.wso2.carbon.user.api_4.2.0.jar
org.wso2.carbon.user.core_4.2.0.jar
org.wso2.carbon.utils_4.2.0.jar
org.wso2.securevault_1.0.0.wso2v2.jar
woden_1.0.0.M8-wso2v1.jar
wsdl4j_1.6.2.wso2v4.jar
XmlSchema_1.4.7.wso2v2.jar


You can find the source code here https://github.com/ajithnv/blog_resources/blob/master/WSDL-Download/src/org/wso2/registry/wsdl/test/WSDLDownload.java


7.  Change the value of CARBON_HOME,serverURL and zipFilesLocation in WSDLDownload.java according to your test environment.

8.  Execute the WSDLDownload.java. If it is success, you should see the following type log.

WSDL archive created at : /home/ajith/WeatherForecastService.zip

9.  If you extract the WeatherForecastService.zip file you should see the Schema files are located against the Namespace paths.



9. You can consider the created zip file as a "Governance Archive". Read more here. http://docs.wso2.org/display/Governance460/Creating+a+Governance+Archive

10. Delete the WSDL file and Schema files from Governance Registry admin UI.



11.  Upload the WeatherForecastService.zip to Governance Registry.


12. Check the back end logs and  you should see the following log messages.

INFO {org.wso2.carbon.registry.extensions.handlers.ZipWSDLMediaTypeHandler} -  Total Number of Files Uploaded: 6
INFO {org.wso2.carbon.registry.extensions.handlers.ZipWSDLMediaTypeHandler} -  Total Number of Files Failed to Upload: 0
INFO {org.wso2.carbon.registry.extensions.handlers.ZipWSDLMediaTypeHandler} -  Completed uploading files from archive file



13. After few seconds you should see the uploaded WSDL and Schema files from Governance Registry Admin UI as well.


14. If you want to download the archive file as a .gar file, change the value of the "compressMethod" to ".gar" in WSDLDownload.java.