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

3712Simple SOAP::Lite Perl script

Expand Messages
  • Kelvin Wu
    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 ...
    • Show all 3 messages in this topic