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

putting attributes to xml element using SOAP::Lite

Expand Messages
  • pokharel_ashish
    Hi everyone, This might be a repeat of questions in earlier post but cant find one. I would appreciate if anyone can help me figure out one small thing here. I
    Message 1 of 2 , Aug 28, 2007
    • 0 Attachment
      Hi everyone,

      This might be a repeat of questions in earlier post but cant find one.
      I would appreciate if anyone can help me figure out one small thing
      here. I wanted to create a SOAP call as follows:

      <soap:Body>
      <myFlow version="1.0">
      <flow name="myName" action="start">
      <auth>
      <user>user</user>
      <password>pass</password>
      </auth>
      </flow>
      </myFlow>
      </soap:Body>

      It seems most of it is pretty simple.

      my $mySoap = SOAP::Lite ->uri("myUri")
      ->proxy("myProxy");

      my $method = SOAP::Data->name('myFlow');
      my @params = ( SOAP::Data->name("flow"=>
      \SOAP::Data->name("auth" =>
      \SOAP::Data->value(SOAP::Data->name("user"=>"user"),

      SOAP::Data->name("password"=>"pass"))));
      my $soap = $mySoap->call($method => @params);

      But by no means I can put the attributes to the elements for myFlow
      and flow. Does anyone know a simple solution to this?

      Thanks
    • Eric Bridger
      You can use the SOAP::Data- attr method to set attributes. Note: attr takes a hash reference as it s argument. E.g. SOAP::Data- attr( { name = myName }
      Message 2 of 2 , Aug 30, 2007
      • 0 Attachment
        You can use the SOAP::Data->attr method to set attributes. Note: attr
        takes a hash reference as it's argument.
        E.g.

        \SOAP::Data->attr( { 'name' => 'myName' } )->name( 'flow');
        Actually you need two attributes:

        \SOAP::Data->attr( { 'name' => 'myName' , 'action' => 'start' } )-
        >name( 'flow');

        On Aug 28, 2007, at 2:48 PM, pokharel_ashish wrote:

        > Hi everyone,
        >
        > This might be a repeat of questions in earlier post but cant find one.
        > I would appreciate if anyone can help me figure out one small thing
        > here. I wanted to create a SOAP call as follows:
        >
        > <soap:Body>
        > <myFlow version="1.0">
        > <flow name="myName" action="start">
        > <auth>
        > <user>user</user>
        > <password>pass</password>
        > </auth>
        > </flow>
        > </myFlow>
        > </soap:Body>
        >
        > It seems most of it is pretty simple.
        >
        > my $mySoap = SOAP::Lite ->uri("myUri")
        > ->proxy("myProxy");
        >
        > my $method = SOAP::Data->name('myFlow');
        > my @params = ( SOAP::Data->name("flow"=>
        > \SOAP::Data->name("auth" =>
        > \SOAP::Data->value(SOAP::Data->name("user"=>"user"),
        >
        > SOAP::Data->name("password"=>"pass"))));
        > my $soap = $mySoap->call($method => @params);
        >
        > But by no means I can put the attributes to the elements for myFlow
        > and flow. Does anyone know a simple solution to this?
        >
        > Thanks
        >
        >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.