Wednesday, June 21, 2017

Deploying connectors on ESB using admin services

Apart from deploying connectors through WSO2 ESB UI, you can use the AdminServices to deploy the connector. By default, the WSDLs of admin services are hidden from consumers. 

Follow the steps mentioned below to discover them.
  1. Set the <HideAdminServiceWSDLs> element to false in the <PRODUCT_HOME>/repository/conf/carbon.xml file.
  2. Restart the server.
  3. Start the WSO2 product with the -DosgiConsole option, such as sh <PRODUCT_HOME>/bin/wso2server.sh -DosgiConsole in Linux.
  4. When the server is started, hit the enter/return key several times to get the OSGI shell in the console.
  5. In the OSGI shell, type: osgi> listAdminServices

Step 1

Use “uploadLibrary” operation from https://localhost:9443/services/MediationLibraryUploader AdminService to upload the connector. The following sample curl request shows how to upload the connector zip file.


curl -k -v -H "Content-Type: application/soap+xml;charset=UTF-8;"  -H "SOAPAction:urn:getImport" --basic -u "admin:admin" --data @uploadLibrary.xml https://localhost:9443/services/MediationLibraryUploader
uploadLibrary.xml

uploadLibrary.xml

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:upl="http://upload.service.library.mediation.carbon.wso2.org" xmlns:xsd="http://upload.service.library.mediation.carbon.wso2.org/xsd">
   <soap:Header/>
   <soap:Body>
      <upl:uploadLibrary>
         <upl:fileItems>
            <xsd:dataHandler>{BASE64_ENCODED_ZIP_CONTENT}</xsd:dataHandler>
            <xsd:fileName>fileconnector-connector-2.0.7.zip</xsd:fileName>
            <xsd:fileType>zip</xsd:fileType>
         </upl:fileItems>
      </upl:uploadLibrary>
   </soap:Body>
</soap:Envelope>

Step 2

Once you upload the connector, use the following command to add the import file into repository/deployment/server/synapse-configs/default/imports.


curl -k -v -H "Content-Type: application/soap+xml;charset=UTF-8;"  -H "SOAPAction:urn:addImport" --basic -u "admin:admin" --data @addImport.xml https://localhost:9443/services/MediationLibraryAdminService
addImport.xml


addImport.xml





<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://org.apache.synapse/xsd">
   <soap:Header/>
   <soap:Body>
      <xsd:addImport>
         <xsd:libName>fileconnector</xsd:libName>
         <xsd:packageName>org.wso2.carbon.connector</xsd:packageName>
      </xsd:addImport>
   </soap:Body>
</soap:Envelope>


Step 3

Then, enable the connector using the following command:


curl -k -v -H "Content-Type: application/soap+xml;charset=UTF-8;"  -H "SOAPAction:urn:updateStatus" --basic -u "admin:admin" --data @updateStatus.xml https://localhost:9443/services/MediationLibraryAdminService
updateStatus.xml


updateStatus.xml




<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://org.apache.synapse/xsd">
   <soap:Header/>
   <soap:Body>
      <xsd:updateStatus>
         <xsd:libQName>{org.wso2.carbon.connector}fileconnector</xsd:libQName>
         <xsd:libName>fileconnector</xsd:libName>
         <xsd:packageName>org.wso2.carbon.connector</xsd:packageName>
         <xsd:status>enabled</xsd:status>
      </xsd:updateStatus>
   </soap:Body>
</soap:Envelope>

That's all. Now you can call operations which supports from the connector inside your proxy.

Thanks.

No comments:

Post a Comment

Blogger Widgets