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

translating soap call to perl::lite

Expand Messages
  • psaleh2000
    I have the XML format of a soap call that I need to include in a perl script. But reverse engineering doesn t seem to lead me to the same format message. Are
    Message 1 of 2 , Feb 9 7:07 AM
    • 0 Attachment
      I have the XML format of a soap call that I need to include in a
      perl script. But reverse engineering doesn't seem to lead me to the
      same format message. Are there any tools that could do this??

      In case anyone is feeling helpful, I'll include the XML that I'm
      trying to recreate, and the perl script I'm atempting to write to do
      it. The tags with **<>** around them shouldn't be there and I can't
      figure out why they are!! (very frustrating)

      <?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>
      - <ImportDocument
      xmlns="http://www.proactis.com/proactis/webservice">
      - <DocumentXML>
      - <pro:Import
      xmlns:pro="http://www.proactis.com/proactis/webservice">
      <pro:Control UserName="blah" Version="1.0.0" Password="blah"
      Database="PROACTIS_TEST" Company="KBCFP"
      xmlns:pro="http://www.proactis.com/xml/xml-ns" />
      **</pro:Import>**
      - **<pro:Import
      xmlns:pro="http://www.proactis.com/proactis/webservice">**
      - <pro:Items xmlns:pro="http://www.proactis.com/xml/xml-ns">
      - <pro:Item UnitOfMeasure="EACH" ItemCurrency="USD"
      CanChangePrice="YES" CanChangeDescription="YES" ACTION="STORE"
      DefaultPrice="20.00" Active="YES" SingleSupplierItem="NO"
      PROACTISCode="SALEHABC" Description="Some Stuff" RowNumber="4">
      - <pro:ItemCompanyGroups>
      <pro:ItemCompanyGroup ItemGroup="HW\HPST" SequenceNo="4" />
      </pro:ItemCompanyGroups>
      </pro:Item>
      - <pro:ItemNominals>
      <pro:ItemNominal AccountingElement2="3600"
      AccountingElement1="ABC" DefaultNominal="YES" IsExpenseAccount="YES"
      ACTION="STORE" Description="Local" />
      </pro:ItemNominals>
      </pro:Items>
      </pro:Import>
      </DocumentXML>
      </ImportDocument>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

      and here's the script:

      use SOAP::Lite +trace => all;

      my $soap = SOAP::Lite
      -> uri('http://www.proactis.com/proactis/webservice')
      -> on_action( sub {
      join '/', 'http://www.proactis.com/proactis/webservice', $_[1] } )
      -> proxy('http://blah/PROACTIS/XMLGateway.asmx');

      #Create the item

      my @params = (
      SOAP::Data->name('DocumentXML' =>
      \SOAP::Data->name('pro:Import' =>
      \SOAP::Data->name('pro:Control')
      ->attr({'xmlns:pro' => 'http://www.proactis.com/xml/xml-
      ns','Database' => 'PROACTIS_TEST','Password' => 'blah','UserName'
      => 'blah','Version' => '1.0.0','Company' => 'KBCFP'}),
      \SOAP::Data->name('pro:Items' =>
      \SOAP::Data->name('pro:Item' =>
      \SOAP::Data->name('pro:ItemCompanyGroups' =>
      \SOAP::Data->name('pro:ItemCompanyGroup')
      ->attr({SequenceNo => '4',ItemGroup
      => 'HW\HPST'})),
      SOAP::Data->name('pro:ItemNominals' =>
      \SOAP::Data->name('pro:ItemNominal')
      ->attr({IsExpenseAccount
      => 'YES',DefaultNominal => 'YES',Description
      => 'Local',AccountingElement1 => 'ABC',AccountingElement2
      => '3600',ACTION => 'STORE'})))
      ->attr({RowNumber => '4',Active
      => 'YES',CanChangeDescription => 'YES',SingleSupplierItem
      => 'NO',CanChangePrice => 'YES',ItemCurrency => 'USD',ACTION
      => 'STORE',PROACTISCode => 'SALEHABC',Description => 'Some
      Stuff',UnitOfMeasure => 'EACH',DefaultPrice => '20.00'}))
      ->attr({'xmlns:pro' => 'http://www.proactis.com/xml/xml-
      ns'})
      )
      ->attr({'xmlns:pro'
      => 'http://www.proactis.com/proactis/webservice'})));

      my $method = SOAP::Data->name('ImportDocument')
      ->attr({xmlns => 'http://www.proactis.com/proactis/webservice'});

      print $soap->call($method => @params)->result;


      cheers

      Paul.
    • Duncan Cameron
      ... If you have a complex XML structure to create it may be easier to create the XML outside of S::L and pass that as literal XML. Something like my $xml = ...
      Message 2 of 2 , Feb 9 7:40 AM
      • 0 Attachment
        --- psaleh2000 <paul_saleh@...> wrote:
        >
        >
        > I have the XML format of a soap call that I need to include in a
        > perl script. But reverse engineering doesn't seem to lead me to the
        > same format message. Are there any tools that could do this??
        >
        > In case anyone is feeling helpful, I'll include the XML that I'm
        > trying to recreate, and the perl script I'm atempting to write to do
        > it. The tags with **<>** around them shouldn't be there and I can't
        > figure out why they are!! (very frustrating)
        >
        > <?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>
        > - <ImportDocument
        > xmlns="http://www.proactis.com/proactis/webservice">
        > - <DocumentXML>
        > - <pro:Import
        > xmlns:pro="http://www.proactis.com/proactis/webservice">
        > <pro:Control UserName="blah" Version="1.0.0" Password="blah"
        > Database="PROACTIS_TEST" Company="KBCFP"
        > xmlns:pro="http://www.proactis.com/xml/xml-ns" />
        > **</pro:Import>**
        > - **<pro:Import
        > xmlns:pro="http://www.proactis.com/proactis/webservice">**
        > - <pro:Items xmlns:pro="http://www.proactis.com/xml/xml-ns">
        > - <pro:Item UnitOfMeasure="EACH" ItemCurrency="USD"
        > CanChangePrice="YES" CanChangeDescription="YES" ACTION="STORE"
        > DefaultPrice="20.00" Active="YES" SingleSupplierItem="NO"
        > PROACTISCode="SALEHABC" Description="Some Stuff" RowNumber="4">
        > - <pro:ItemCompanyGroups>
        > <pro:ItemCompanyGroup ItemGroup="HW\HPST" SequenceNo="4" />
        > </pro:ItemCompanyGroups>
        > </pro:Item>
        > - <pro:ItemNominals>
        > <pro:ItemNominal AccountingElement2="3600"
        > AccountingElement1="ABC" DefaultNominal="YES" IsExpenseAccount="YES"
        > ACTION="STORE" Description="Local" />
        > </pro:ItemNominals>
        > </pro:Items>
        > </pro:Import>
        > </DocumentXML>
        > </ImportDocument>
        > </SOAP-ENV:Body>
        > </SOAP-ENV:Envelope>
        >
        > and here's the script:
        >
        > use SOAP::Lite +trace => all;
        >
        > my $soap = SOAP::Lite
        > -> uri('http://www.proactis.com/proactis/webservice')
        > -> on_action( sub {
        > join '/', 'http://www.proactis.com/proactis/webservice', $_[1] } )
        > -> proxy('http://blah/PROACTIS/XMLGateway.asmx');
        >
        > #Create the item
        >
        > my @params = (
        > SOAP::Data->name('DocumentXML' =>
        > \SOAP::Data->name('pro:Import' =>
        > \SOAP::Data->name('pro:Control')
        > ->attr({'xmlns:pro' => 'http://www.proactis.com/xml/xml-
        > ns','Database' => 'PROACTIS_TEST','Password' => 'blah','UserName'
        > => 'blah','Version' => '1.0.0','Company' => 'KBCFP'}),
        > \SOAP::Data->name('pro:Items' =>
        > \SOAP::Data->name('pro:Item' =>
        > \SOAP::Data->name('pro:ItemCompanyGroups' =>
        > \SOAP::Data->name('pro:ItemCompanyGroup')
        > ->attr({SequenceNo => '4',ItemGroup
        > => 'HW\HPST'})),
        > SOAP::Data->name('pro:ItemNominals' =>
        > \SOAP::Data->name('pro:ItemNominal')
        > ->attr({IsExpenseAccount
        > => 'YES',DefaultNominal => 'YES',Description
        > => 'Local',AccountingElement1 => 'ABC',AccountingElement2
        > => '3600',ACTION => 'STORE'})))
        > ->attr({RowNumber => '4',Active
        > => 'YES',CanChangeDescription => 'YES',SingleSupplierItem
        > => 'NO',CanChangePrice => 'YES',ItemCurrency => 'USD',ACTION
        > => 'STORE',PROACTISCode => 'SALEHABC',Description => 'Some
        > Stuff',UnitOfMeasure => 'EACH',DefaultPrice => '20.00'}))
        > ->attr({'xmlns:pro' => 'http://www.proactis.com/xml/xml-
        > ns'})
        > )
        > ->attr({'xmlns:pro'
        > => 'http://www.proactis.com/proactis/webservice'})));
        >
        > my $method = SOAP::Data->name('ImportDocument')
        > ->attr({xmlns => 'http://www.proactis.com/proactis/webservice'});
        >
        > print $soap->call($method => @params)->result;
        >
        >
        > cheers
        >
        > Paul

        If you have a complex XML structure to create it may be easier to
        create the XML outside of S::L and pass that as literal XML. Something
        like

        my $xml = ... # some code to build the XML manually

        $soap->call($method => SOAP::Data->type(xml => $xml)->name('somename'))

        Duncan




        ___________________________________________________________
        Too much spam in your inbox? Yahoo! Mail gives you the best
        spam protection for FREE! http://uk.mail.yahoo.com
      Your message has been successfully submitted and would be delivered to recipients shortly.