3 Replies Latest reply on Oct 7, 2014 2:47 PM by jorgemoralespou_2

    File Transfer

    ptjcarlo

      Hi guys,

      Would you recommend to use switchyard on creating a file transfer service?

      I want to create a simple switchyard project that can transfer a file from my local directory and pass it on a FTP server?

      Any best practice that you can suggest?

       

      Many Thanks,

        • 1. Re: File Transfer
          jorgemoralespou_2

          Hi,

          I would probably use a:

          • File service
          • Camel component
          • FTP reference

          With this should be straight forward to implement.

          1 of 1 people found this helpful
          • 2. Re: File Transfer
            ptjcarlo

            Thanks Jorge

             

            I tried to create java class that implements getting a file in a local directory and put it in ftp server. However, got an error message while enabling the service in EAP,

            "Internal Server Error

            {

                "outcome" => "failed",

                "failure-description" => {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"FileToFTP_proj-0.0.1-SNAPSHOT.jar\".SwitchYardService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"FileToFTP_proj-0.0.1-SNAPSHOT.jar\".SwitchYardService: org.switchyard.SwitchYardException: SWITCHYARD030412: Unknown Service name '{urn:com.example.switchyard:FileToFTP_proj:1.0}FTPUploaderService'.

                Caused by: org.switchyard.SwitchYardException: SWITCHYARD030412: Unknown Service name '{urn:com.example.switchyard:FileToFTP_proj:1.0}FTPUploaderService'."}},

                "rolled-back" => true

            }

            "

            Capture.PNG

            File/FTP binding and Java Interface (FTPUploaderService') -> Java Bean component (FTPUploaderServiceBean_new)

            • 3. Re: Re: File Transfer
              jorgemoralespou_2

              Hi Carlo,

              I don't know how you are progressing with this, but it should be easier than that.

              Just to get you started:

               

              ftp-service.png

               

              <?xml version="1.0" encoding="UTF-8"?>
              <sy:switchyard xmlns:camel="urn:switchyard-component-camel:config:1.1" xmlns:file="urn:switchyard-component-camel-file:config:1.1" xmlns:ftp="urn:switchyard-component-camel-ftp:config:1.1" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:sy="urn:switchyard-config:switchyard:1.1" name="file2ftp-example" targetNamespace="urn:com.example.switchyard:file2ftp-example:1.0">
                <sca:composite name="file2ftp-example" targetNamespace="urn:com.example.switchyard:file2ftp-example:1.0">
                  <sca:component name="File2FTPRoute">
                    <camel:implementation.camel>
                      <camel:java class="com.example.switchyard.file2ftp_example.File2FTPRoute"/>
                    </camel:implementation.camel>
                    <sca:service name="FileService">
                      <sy:interface.esb inputType="java:java.lang.String"/>
                    </sca:service>
                    <sca:reference name="FTPService">
                      <sy:interface.esb inputType="java:java.lang.String"/>
                    </sca:reference>
                  </sca:component>
                  <sca:service name="FileService" promote="File2FTPRoute/FileService">
                    <sy:interface.esb inputType="java:java.lang.String"/>
                    <file:binding.file name="file1">
                      <file:directory>/tmp</file:directory>
                      <file:fileName>input.txt</file:fileName>
                      <file:consume/>
                    </file:binding.file>
                  </sca:service>
                  <sca:reference name="FTPService" multiplicity="0..1" promote="File2FTPRoute/FTPService">
                    <sy:interface.esb inputType="java:java.lang.String"/>
                    <ftp:binding.ftp name="ftp1">
                      <ftp:directory>/tmp</ftp:directory>
                      <ftp:fileName>output.txt</ftp:fileName>
                      <ftp:host>localhost</ftp:host>
                      <ftp:port>21</ftp:port>
                      <ftp:username>user</ftp:username>
                      <ftp:password>password</ftp:password>
                      <ftp:produce/>
                    </ftp:binding.ftp>
                  </sca:reference>
                </sca:composite>
              </sy:switchyard>