Petals Getting started - day 3 - Expose a FTP Service in SOAP

Hi again Petals Padawan. Glad to see you're still on board !
For your 3rd day, you will connect Petals to an FTP server, and expose the created FTP service as a SOAP web-service, outside Petals ESB.

Last tested with

This Tutorial uses:

  • Petals Studio
  • Petals ESB
  • Petals SE RMI
  • Petals BC SOAP
  • Petals Web console
  • Tomcat
  • Petals BC FTP (new)
  • soapUI (new)

Deploy a FTP Service Unit

Install and Deploy BC-FTP:

  1. Download Petals-BC-FTP .
  2. Deploy BC-FTP in Petals ESB.

Configure and deploy a FTP Service-Unit for [ftp.petalslink.com]:

  1. Start Petals ESB.
  2. Launch Petals Studio.
  3. Go to File > New > Service Unit Project.
  4. Select Provide > FTP > Your_Current_Version
  5. Click Next. It displays the window "FTP Service-Unit - Defines the JBI properties of the service to import."
    1. Service Name: FtpTutorial
  6. Click Next > Next: It displays the window "FTP Service-Unit - Define the specific properties for this version of the component."
    <folder> attribute is written as optionnal in Studio, but it is not. It will be optional in BC-FTP v3, so as soon as it is published, you will not need to specify the folder attribute for the tutorial.
    1. Server: ftp.petalslink.com
    2. Port: 21
    3. User: petals
    4. Password: demo
    5. Folder: /
    6. Transfer Type: auto
    7. Connection Mode: active
  7. Click Finish.
  8. Look the generated jbi.xml component configuration. It should look like:
    jbi.xml
    <jbi:provides
    interface-name="generatedNs:FtpInterface"
    service-name="generatedNs:FtpTutorial"
    endpoint-name="FtpTutorialEndpoint">
    
    <\!-\- CDK specific elements -->
    <petalsCDK:timeout>30000</petalsCDK:timeout>
    <petalsCDK:validate-wsdl>true</petalsCDK:validate-wsdl>
    <petalsCDK:forward-security-subject>false</petalsCDK:forward-security-subject>
    <petalsCDK:forward-message-properties>false</petalsCDK:forward-message-properties>
    <petalsCDK:forward-attachments>false</petalsCDK:forward-attachments>
    <petalsCDK:wsdl>FtpService.wsdl</petalsCDK:wsdl>
    
    <\!-\- Component specific elements -->
    <ftp:server>ftp.petalslink.com</ftp:server>
    <ftp:port>21</ftp:port>
    <ftp:user>petals</ftp:user>
    <ftp:password>demo</ftp:password>
    <ftp:folder>/</ftp:folder>
    <ftp:transfer-type>auto</ftp:transfer-type>
    <ftp:connection-mode>active</ftp:connection-mode>
    </jbi:provides>
  1. Look the generated FtpService.wsdl sources. Operations available on service are described here.
  2. Go in Service-Unit Project on the left Petals projects tree.
  3. Right click on "su-FtpTutorial-provide".
  4. Select Petals > Fast Export for Petals.
    Known bug for Studio v1.1.0 !
    Please check jbi.xml and FtpService. There is a bug sometimes (on Windows 7).
    "interface-name" attribute in jbi.xml and "portType name" in the WSDL should have the same value. If not, please correct FtpService.wsdl :
    1. SELECT:
      <wsdl:portType name="Ftp">
    2. REPLACE BY:
      <wsdl:portType name="FtpInterface">

    This is a known bug in Petals Studio 1.1.0. It might be corrected in version 1.1.1.

  5. Drop the generated sa-FTP-FtpTutorial-provide.zip to ./petals-platform-xxx/install/ folder to deploy it.
  6. Check Petals ESB traces to be sure the SA was deployed successfully.

Test and monitor in Webconsole

Send test DIR Operation on root folder:

  1. Start the Webconsole
  2. Go to Webconsole > Server:0 > Test > Send
  3. Select:
    1. Endpoint: FtpTutorialEndpoint
    2. Operation: dir
    3. MEP: InOut
  4. Click Submit.
    You should get a response message, listing files on the Ftp.

Monitor services:

  1. Go to Webconsole > Server: 0 > Monitoring > Server Monitoring.
  2. Check Filter endpoint.
  3. Select Endpoint "FtpTutorialEndpoint"
    You can also create filters based on Interface name, Service Name or Operation Name. This is useful for example if one service is duplicated on multiple endpoints.
  4. Click Submit. "FtpTutorial" is now visible in exchange filters list.
  5. Click the small icon in "Monitoring" column in the list, to activate monitoring for "FtpTutorialEndpoint".
  6. Send a few test messages from the test panel.
  7. Go to: Monitoring > Filter Monitoring.

    Screenshot: Message exchange monitoring

Change destination folder:

  1. Got to ftp://ftp.petalslink.com in your web browser or ftp client, using previous login. You see there is an "Integration" folder. Let's go there.
  2. Go to Petals Studio.
  3. Edit FtpTutorial's jbi.xml.
  4. Replace "<folder>/</folder>" by "<folder>Integration</folder>"
  5. Save

Redeploy the component:

  1. Go to Webconsole > Server: 0 > Administration > Service-Assemblies.
  2. Uninstall the previous FtpTutorial SA: Click Stop then Shutdown then Uninstall).
    As for installing, you can use three methods:
    • from Webconsole: Click alternatively Stop, Shutdown and Uninstall (Alternatives: "force undeploy" or "clear all")
    • from Autoloader: Remove the corresponding .ZIP package from ./petals-platform-xxx/installed/
    • from Command Line: Type hu or hotundeploy. Ex: "hu sa-FTP-FtpTutorial-provide.zip".
  3. Go to: Petals Studio.
  4. Fast-export the FTP Service-Unit.
  5. Drag&Drop the newly generated sa-FTP-FtpTutorial-provide.zip from Eclipse to ./petals-platform-xxx/install/
  6. Check in Petals ESB traces that the new SA was deployed sucessfully.
  7. Test FTP Service-Unit by calling DIR operation on Webconsole.
    Want to go further?
    Try reading the files you listed. Look at the BC-FTP Documentation and go on your own. (note that your ftp session is read-only, if you want to call writing operations, create your own ftp server).

Expose the FTP service over SOAP

Before, SOAP was used to import WSDL to create services inside Petals ESB. Meaning Provide a SOAP service inside the bus.
This time you will do the contrary : A service (FTP) exists inside the bus. You will create a SOAP Service-Unit to Consume the existing "FtpTutorial" Service. This will expose "FtpTutorial", and make it accessible over SOAP protocol.

Expose a SOAP-Consume of FtpTutorial:

  1. Go to Petals Studio.
  2. Click File > New > Service-Unit Project.
  3. Select Consume > SOAP > Your_BC-SOAP_Version.
  4. Click Next. It displays the window "SOAP Service-Unit - You have to provide the namespace".
  5. Click Select a service.
  6. Select FtpTutorial implements FtpInterface @ FtpTutorialEndpoint.
  7. Click OK. Fields are automatically completed.
  8. Click Next > Next. It displays the window "Define the specific properties for this version of the component".
    1. Service Name: SoapFtpTutorial
  9. Click Next > Finish.
  10. Export and deploy in Petals ESB.

Test with SOAP UI

Install SOAP UI:
Download SOAPUI and install it. SOAP UI is a client to send and receive messages with SOAP protocol.

Find the WSDL URL:

  1. You just deployed sa-SOAP-FtpTutorial-consume. Look at Petals ESB traces. Among the last messages, find one similar to the one following. And find the root URL, here "http://127.0.0.1:8084".
    [Petals.Container.Components.petals-bc-soap]-INFO 2010-10-06 15:26:22,032 The Axis2 service 'SoapFtpTutorial' has been registered and is available at 'http://127.0.0.1:8084/petals/services/SoapFtpTutorial'
  2. Go to http://127.0.0.1:8084 in your web browser.
  3. Go to Service List.
  4. Copy the SoapFtpTutorial WSDL URL.

Create a SOAP UI Project:

  1. Launch SOAP UI.
  2. Click File > New soapUI Project.
    1. Project Name: PetalsFtpTutorial (or whatever name).
    2. Initial WSDL/WADL: Paste the WSDL URL previously copied. Might be: http://127.0.0.1:8084/petals/services/SoapFtpTutorial?wsdl
  3. Click OK.

Test the proxified FTP DIR operation:

  1. Click PetalsFtpTutorial > FtpServiceSoapBinding > dir.
  2. Right click on Request1.
  3. Select Show Request Editor: It displays a window with a pre-generated message.
  4. Delete what is under  <!-Optionnal->. This means deleting <connection> node and its children.
Ftp parameters are already configured in the Service-Unit, so you do not need to configure them again.
Your message looks like this
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ver="http://petals.ow2.org/components/ftp/version-3">
   <soapenv:Header/>
   <soapenv:Body>
      <ver:dir>
      </ver:dir>
   </soapenv:Body>
</soapenv:Envelope>
  1. Clic the green arrow to send the message. The response should list several files.
    Want to go further?
    Try reading "HelloWorld.txt" into "Integration" folder, using optional elements instead of deleting them.
    You need to redefine ALL properties in this case.

Technical monitoring with Webconsole:

  1. Go to Webconsole > Server: 0 > Monitoring > Server Monitoring
    1. Check Filter Endpoint.
    2. Select FtpTutorialEndpoint.
  2. Click Submit.
  3. Click the small image in the "Monitoring" column to activate FtpTutorialEndpoint monitoring.
  4. Send a few test message with SOAP UI.
  5. Go to Webconsole > Server: 0 > Monitoring > Filter Monitoring.
  6. Click on the magnifier image on the right of any message exchange to get details. You should get a screen like this:

    Screen: Message exchange status
You can see the message was sent by BC-SOAP to BC-FTP

DONE. Bravo!
Now you know how to:

  • Connect Petals ESB to an FTP Server and call operations.
  • Monitor service exchanges in Webconsole.
  • Expose a Petals Service as external SOAP Web-service.
  • Test a web-service with soapUI.

This was more "real" usecase, hum ? Difficulty goes increasing, your knowledge as well.

Tomorrow you will create a Petals service based on a custom Java class (annotated JSR 181)

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.