Loading ...
Sorry, an error occurred while loading the content.

Simple SOAP::Lite Perl script

Expand Messages
  • Kelvin Wu
    Hi, I am new to SOAP::Lite. I am looking for a simple Perl script to do the follow thing. I am writting a client script to connect to the service which uses
    Message 1 of 3 , Jul 4, 2004
    • 0 Attachment
      Hi, I am new to SOAP::Lite. I am looking for a simple Perl script to
      do the follow thing.

      I am writting a client script to connect to the service which uses
      SOAP over HTTPS, the request is:

      <?xml version="1.0" encoding="UTF-8"?>
      <SOAP-ENV:Envelope
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema">
      <SOAP-ENV:Body>
      <namesp1:mynamesp xmlns:namesp1="urn:MyNamesp">
      <userid xsi:type="xsd:string">
      user1000
      </userid>
      <password xsi:type="xsd:string">
      password
      </password>
      <fileToQuery xsi:type="xsd:string">
      abc.txt.gz
      </fileToQuery>
      </namesp1:mynamesp>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

      The output of the web service is a SOAP message with a MIME
      attachment. The SOAP message body will have an empty response
      attribute mynamespResponse. The attachment will contain the requested
      batch file in gzip format.

      SOAP with MIME Attachment Response:

      Content-Type: Multipart/Related; boundary="----------=_1087362634-16100-0"
      Content-Transfer-Encoding: binary
      MIME-Version: 1.0
      X-Mailer: MIME-tools 5.411 (Entity 5.404)

      This is a multi-part message in MIME format...

      ------------=_1087362634-16100-0
      Content-Type: text/xml
      Content-Disposition: inline
      Content-Transfer-Encoding: 8bit
      Content-Location: /main_envelope
      Content-Id: <main_envelope>

      <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema"
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <SOAP-ENV:Body>
      <namesp1:mynamespResponse xmlns:namesp1="urn:MyNamesp">
      <fileSize xsi:type="xsd:int">
      114
      </fileSize>
      </namesp1:mynamespResponse>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>
      ------------=_1087362634-16100-0
      Content-Type: application/x-gzip; name="abc.txt.gz"
      Content-Disposition: attachment; filename="abc.txt.gz"
      Content-Transfer-Encoding: base64
      Content-Id: <1234>
      MIME-Version: 1.0
      X-Mailer: MIME-tools 5.411 (Entity 5.404)

      H4sICPCjc0AAA3ByZWZpeF93azAyLnR4dAAzMDE0MDK2MLc0VAhJzSkuKUrk
      MjAxNAILGSELmYCFjBX8C0pKi0ECZmABE4SABVjAVCEsPyUxLT8vFWGQGYqYMVjMHEXMzMDUzMDAAiEGAB9WFH+YAAAA
      ------------=_1087362634-16100-0—

      This is my script:
      #!/usr/bin/perl -w

      use strict;
      use SOAP::Lite;

      print SOAP::Lite
      -> uri("urn:MyNamesp")
      -> proxy("https://url.to.web.service/soap.cgi")
      -> mynamesp(SOAP::Data->name("userid" => "user1000"),
      SOAP::Data->name("password" => "password"),
      SOAP::Data->name("fileToQuery" => "abc.txt.gz"))
      ->result;

      My question is,
      1, Is this the right way to send request?
      2, How can I parse the response content to decode the attachment?
      3, How can I run this script on Win32(ActivePerl)? I am always got
      error message
      Can't locate object method "new" via package
      "LWP::Protocol::https::Socket" blah blah, but have no problem running
      it on Linux.

      Thanks very much, learning SOAP ...
    • Duncan Cameron
      ... Looks OK, but I would break in into three steps, creating the SOAP::Lite object, calling the method, and accessing the result in order to test success of
      Message 2 of 3 , Jul 5, 2004
      • 0 Attachment
        At 2004-07-05, 07:26:19 Kelvin Wu <kelvin.wu@...> wrote:

        >Hi, I am new to SOAP::Lite. I am looking for a simple Perl script to
        >do the follow thing.
        >
        >I am writting a client script to connect to the service which uses
        >SOAP over HTTPS, the request is:
        >
        ><?xml version="1.0" encoding="UTF-8"?>
        ><SOAP-ENV:Envelope
        >xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
        >SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        >xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        >xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
        >xmlns:xsd="http://www.w3.org/1999/XMLSchema">
        > <SOAP-ENV:Body>
        > <namesp1:mynamesp xmlns:namesp1="urn:MyNamesp">
        > <userid xsi:type="xsd:string">
        > user1000
        > </userid>
        > <password xsi:type="xsd:string">
        > password
        > </password>
        > <fileToQuery xsi:type="xsd:string">
        > abc.txt.gz
        > </fileToQuery>
        > </namesp1:mynamesp>
        > </SOAP-ENV:Body>
        ></SOAP-ENV:Envelope>
        >
        >The output of the web service is a SOAP message with a MIME
        >attachment. The SOAP message body will have an empty response
        >attribute mynamespResponse. The attachment will contain the requested
        >batch file in gzip format.
        >
        >SOAP with MIME Attachment Response:
        >
        >Content-Type: Multipart/Related; boundary="----------=_1087362634-16100-0"
        >Content-Transfer-Encoding: binary
        >MIME-Version: 1.0
        >X-Mailer: MIME-tools 5.411 (Entity 5.404)
        >
        >This is a multi-part message in MIME format...
        >
        >------------=_1087362634-16100-0
        >Content-Type: text/xml
        >Content-Disposition: inline
        >Content-Transfer-Encoding: 8bit
        >Content-Location: /main_envelope
        >Content-Id: <main_envelope>
        >
        ><?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
        >xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
        >xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
        >xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        >xmlns:xsd="http://www.w3.org/1999/XMLSchema"
        >SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        > <SOAP-ENV:Body>
        > <namesp1:mynamespResponse xmlns:namesp1="urn:MyNamesp">
        > <fileSize xsi:type="xsd:int">
        > 114
        > </fileSize>
        > </namesp1:mynamespResponse>
        > </SOAP-ENV:Body>
        ></SOAP-ENV:Envelope>
        >------------=_1087362634-16100-0
        >Content-Type: application/x-gzip; name="abc.txt.gz"
        >Content-Disposition: attachment; filename="abc.txt.gz"
        >Content-Transfer-Encoding: base64
        >Content-Id: <1234>
        >MIME-Version: 1.0
        >X-Mailer: MIME-tools 5.411 (Entity 5.404)
        >
        >H4sICPCjc0AAA3ByZWZpeF93azAyLnR4dAAzMDE0MDK2MLc0VAhJzSkuKUrk
        >MjAxNAILGSELmYCFjBX8C0pKi0ECZmABE4SABVjAVCEsPyUxLT8vFWGQGYqYMVjMHEXMzMDUzMDAAiEGAB9WFH+YAAAA
        > ------------=_1087362634-16100-0—
        >
        >This is my script:
        >#!/usr/bin/perl -w
        >
        >use strict;
        >use SOAP::Lite;
        >
        >print SOAP::Lite
        > -> uri("urn:MyNamesp")
        > -> proxy("https://url.to.web.service/soap.cgi")
        > -> mynamesp(SOAP::Data->name("userid" => "user1000"),
        > SOAP::Data->name("password" => "password"),
        > SOAP::Data->name("fileToQuery" => "abc.txt.gz"))
        > ->result;
        >
        >My question is,
        >1, Is this the right way to send request?

        Looks OK, but I would break in into three steps, creating the SOAP::Lite object, calling the method, and accessing the result in order to test success of the method.

        >2, How can I parse the response content to decode the attachment?

        You need to use the SOAP::Mime functionality that has now been incorporated into SOAP::Lite. See http://www.majordojo.com/SOAP-MIME/ for a starter.

        >3, How can I run this script on Win32(ActivePerl)? I am always got
        >error message
        >Can't locate object method "new" via package
        >"LWP::Protocol::https::Socket" blah blah, but have no problem running
        >it on Linux.

        ActivePerl doesn't include the SSL stuff that you need for https. I think that you will need to download and install such a package. Try the ActiveState repository or Randy Kobes repository, http://theoryx5.uwinnipeg.ca

        Sorry, I don't know exactly which packages you need to install, try Googling for "https perl ssl".

        Regards
        Duncan
      • Issac Goldstand
        You indeed want to use Randy s repository. There are instructions for setting it ass a PPM repository at
        Message 3 of 3 , Jul 5, 2004
        • 0 Attachment
          You indeed want to use Randy's repository. There are instructions for
          setting it ass a PPM repository at
          http://perl.apache.org/docs/2.0/os/win32/install.html#PPM_Packages

          You'll then want to ppm install IO-Socket-SSL and ppm install Net_SSLeay.pm

          Issac

          ----- Original Message -----
          From: "Duncan Cameron" <duncan_cameron2002@...>
          To: "Kelvin Wu" <kelvin.wu@...>; <soaplite@yahoogroups.com>
          Sent: Monday, July 05, 2004 10:30 AM
          Subject: Re: [soaplite] Simple SOAP::Lite Perl script


          > At 2004-07-05, 07:26:19 Kelvin Wu <kelvin.wu@...> wrote:
          >
          > >Hi, I am new to SOAP::Lite. I am looking for a simple Perl script to
          > >do the follow thing.
          > >
          > >I am writting a client script to connect to the service which uses
          > >SOAP over HTTPS, the request is:
          > >
          > ><?xml version="1.0" encoding="UTF-8"?>
          > ><SOAP-ENV:Envelope
          > >xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
          > >SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
          > >xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
          > >xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
          > >xmlns:xsd="http://www.w3.org/1999/XMLSchema">
          > > <SOAP-ENV:Body>
          > > <namesp1:mynamesp xmlns:namesp1="urn:MyNamesp">
          > > <userid xsi:type="xsd:string">
          > > user1000
          > > </userid>
          > > <password xsi:type="xsd:string">
          > > password
          > > </password>
          > > <fileToQuery xsi:type="xsd:string">
          > > abc.txt.gz
          > > </fileToQuery>
          > > </namesp1:mynamesp>
          > > </SOAP-ENV:Body>
          > ></SOAP-ENV:Envelope>
          > >
          > >The output of the web service is a SOAP message with a MIME
          > >attachment. The SOAP message body will have an empty response
          > >attribute mynamespResponse. The attachment will contain the requested
          > >batch file in gzip format.
          > >
          > >SOAP with MIME Attachment Response:
          > >
          > >Content-Type: Multipart/Related;
          boundary="----------=_1087362634-16100-0"
          > >Content-Transfer-Encoding: binary
          > >MIME-Version: 1.0
          > >X-Mailer: MIME-tools 5.411 (Entity 5.404)
          > >
          > >This is a multi-part message in MIME format...
          > >
          > >------------=_1087362634-16100-0
          > >Content-Type: text/xml
          > >Content-Disposition: inline
          > >Content-Transfer-Encoding: 8bit
          > >Content-Location: /main_envelope
          > >Content-Id: <main_envelope>
          > >
          > ><?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
          > >xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
          > >xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
          > >xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
          > >xmlns:xsd="http://www.w3.org/1999/XMLSchema"
          > >SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
          > > <SOAP-ENV:Body>
          > > <namesp1:mynamespResponse xmlns:namesp1="urn:MyNamesp">
          > > <fileSize xsi:type="xsd:int">
          > > 114
          > > </fileSize>
          > > </namesp1:mynamespResponse>
          > > </SOAP-ENV:Body>
          > ></SOAP-ENV:Envelope>
          > >------------=_1087362634-16100-0
          > >Content-Type: application/x-gzip; name="abc.txt.gz"
          > >Content-Disposition: attachment; filename="abc.txt.gz"
          > >Content-Transfer-Encoding: base64
          > >Content-Id: <1234>
          > >MIME-Version: 1.0
          > >X-Mailer: MIME-tools 5.411 (Entity 5.404)
          > >
          > >H4sICPCjc0AAA3ByZWZpeF93azAyLnR4dAAzMDE0MDK2MLc0VAhJzSkuKUrk
          >
          >MjAxNAILGSELmYCFjBX8C0pKi0ECZmABE4SABVjAVCEsPyUxLT8vFWGQGYqYMVjMHEXMzMDUzMD
          AAiEGAB9WFH+YAAAA
          > > ------------=_1087362634-16100-0-
          > >
          > >This is my script:
          > >#!/usr/bin/perl -w
          > >
          > >use strict;
          > >use SOAP::Lite;
          > >
          > >print SOAP::Lite
          > > -> uri("urn:MyNamesp")
          > > -> proxy("https://url.to.web.service/soap.cgi")
          > > -> mynamesp(SOAP::Data->name("userid" => "user1000"),
          > > SOAP::Data->name("password" => "password"),
          > > SOAP::Data->name("fileToQuery" => "abc.txt.gz"))
          > > ->result;
          > >
          > >My question is,
          > >1, Is this the right way to send request?
          >
          > Looks OK, but I would break in into three steps, creating the SOAP::Lite
          object, calling the method, and accessing the result in order to test
          success of the method.
          >
          > >2, How can I parse the response content to decode the attachment?
          >
          > You need to use the SOAP::Mime functionality that has now been
          incorporated into SOAP::Lite. See http://www.majordojo.com/SOAP-MIME/ for a
          starter.
          >
          > >3, How can I run this script on Win32(ActivePerl)? I am always got
          > >error message
          > >Can't locate object method "new" via package
          > >"LWP::Protocol::https::Socket" blah blah, but have no problem running
          > >it on Linux.
          >
          > ActivePerl doesn't include the SSL stuff that you need for https. I think
          that you will need to download and install such a package. Try the
          ActiveState repository or Randy Kobes repository,
          http://theoryx5.uwinnipeg.ca
          >
          > Sorry, I don't know exactly which packages you need to install, try
          Googling for "https perl ssl".
          >
          > Regards
          > Duncan
          >
          >
          >
          >
          >
          >
          > Yahoo! Groups Links
          >
          >
          >
          >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.