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

Problems reading an xml with soap::lite

Expand Messages
  • Juan Manuel Alonso
    Hello, I m using SOAP::lite to implement a web service and all is going fine until I must read a complex xml that the client is sending to my service. The
    Message 1 of 2 , Apr 19, 2005
    • 0 Attachment
      Hello,

      I'm using SOAP::lite to implement a web service and all is going fine until I must read a complex xml that the client is sending to my service.

      The client is sending to the server something like this in the SOAP Body:
      <SOAP-ENV:Body>
      <namesp1:PetOperacion xmlns:namesp1="urn:SCMESrvIntService" >
      <idCliente xsi:type="xsd:string">elem1</idCliente>
      <idOperacion xsi:type="xsd:string">elem2</idOperacion>
      <argsIn>
      <name xsi:type="xsd:string">idPlace</name>
      <value xsi:type="xsd:int">¡COMPLEX XML!</value></Par>
      </argsIn>
      </namesp1:PetOperacion>
      </SOAP-ENV:Body>

      where ¡COMPLEX XML! is like it says an xml that I want to get into a varible in the server to save it to a file in the server.

      The perl code in my server is something like this:

      my $self= shift;
      my $envelope= pop;

      # Getting the xml received
      $xml= $envelope->dataof("//argsIn/value")->value;

      #Saving to a file
      open (OUTPUT,">file.xml");
      print OUTPUT $xml;
      close (OUTPUT);

      But I get a hash in the server file that I'm saving and not the xml.

      I'm using a perl client to simulate the real cliente and seeing what's happening with my server and when I send data like this:

      SOAP::Data->type('xml')->name("value"=>"¡COMPLEX XML!")

      it happens the same problem (saves "hash" in the server file). But if I send from the client:

      SOAP::Data->type('string')->name("value"=>"¡COMPLEX XML!")

      the server saves my xml ok except that it changes the "<" with ";lt". However, I think in this case the client is sending wrong the "<" symbol and this is not the real case.

      I have tried to modify the code in the server so I can have the xml in the "$xml" variable indicating the type of data received:

      # Getting the xml received
      $xml= $envelope->dataof("//argsIn/value")->tye('xml')->value;

      but it doesn't function.

      How can I obtain the xml sent in the server and trobleshoot all this??

      Thank you for your help,

      Juan Manuel A.
    • Graham Irvine
      Im sure there are loads of solutions to this one . On Face value mine would be .. Take the $xml (HASH as you found out ) and pass it through XML::Writer (or
      Message 2 of 2 , Apr 19, 2005
      • 0 Attachment
        Im sure there are loads of solutions to this one .

        On Face value mine would be ..

        Take the $xml (HASH as you found out ) and pass it through XML::Writer
        (or similar) which will write out the XML to file from the hash

        Regards
        Graham

        --- In soaplite@yahoogroups.com, Juan Manuel Alonso <jmar@t...> wrote:
        > Hello,
        >
        > I'm using SOAP::lite to implement a web service and all is going
        fine until I must read a complex xml that the client is sending to my
        service.
        >
        > The client is sending to the server something like this in the SOAP
        Body:
        > <SOAP-ENV:Body>
        > <namesp1:PetOperacion xmlns:namesp1="urn:SCMESrvIntService" >
        > <idCliente xsi:type="xsd:string">elem1</idCliente>
        > <idOperacion xsi:type="xsd:string">elem2</idOperacion>
        > <argsIn>
        > <name xsi:type="xsd:string">idPlace</name>
        > <value xsi:type="xsd:int">¡COMPLEX XML!</value></Par>
        > </argsIn>
        > </namesp1:PetOperacion>
        > </SOAP-ENV:Body>
        >
        > where ¡COMPLEX XML! is like it says an xml that I want to get into a
        varible in the server to save it to a file in the server.
        >
        > The perl code in my server is something like this:
        >
        > my $self= shift;
        > my $envelope= pop;
        >
        > # Getting the xml received
        > $xml= $envelope->dataof("//argsIn/value")->value;
        >
        > #Saving to a file
        > open (OUTPUT,">file.xml");
        > print OUTPUT $xml;
        > close (OUTPUT);
        >
        > But I get a hash in the server file that I'm saving and not the xml.
        >
        > I'm using a perl client to simulate the real cliente and seeing
        what's happening with my server and when I send data like this:
        >
        > SOAP::Data->type('xml')->name("value"=>"¡COMPLEX XML!")
        >
        > it happens the same problem (saves "hash" in the server file). But
        if I send from the client:
        >
        > SOAP::Data->type('string')->name("value"=>"¡COMPLEX XML!")
        >
        > the server saves my xml ok except that it changes the "<" with
        ";lt". However, I think in this case the client is sending wrong the
        "<" symbol and this is not the real case.
        >
        > I have tried to modify the code in the server so I can have the xml
        in the "$xml" variable indicating the type of data received:
        >
        > # Getting the xml received
        > $xml= $envelope->dataof("//argsIn/value")->tye('xml')->value;
        >
        > but it doesn't function.
        >
        > How can I obtain the xml sent in the server and trobleshoot all this??
        >
        > Thank you for your help,
        >
        > Juan Manuel A.
      Your message has been successfully submitted and would be delivered to recipients shortly.