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

RE: [soaplite] soap headers

Expand Messages
  • Paul Kulchenko
    Mike, use SOAP::Lite maptype = {}; my $messageHeader = SOAP::Header- name(MessageHeader = { Username = SOAP::Data- type( = USERNAME ), Password =
    Message 1 of 7 , Jun 27 10:02 AM
    • 0 Attachment
      Mike,

      use SOAP::Lite maptype => {};

      my $messageHeader = SOAP::Header->name(MessageHeader => {
      Username => SOAP::Data->type('' => 'USERNAME'),
      Password => SOAP::Data->type('' => 'PASSWORD'),
      Account => SOAP::Data->type('' => 'ACCOUNT'),
      })->uri("com.esendex.ems.soapinterface")->prefix('');

      Will give you exactly the code you want to see. prefix('') will
      generate "xmlns=" instead of "xmlns:ns1=".

      This example is included in "Programming Web Services with Perl"
      (p284). The documentation will be updated to include that too.

      Best wishes, Paul.

      --- Mike Solomon <mike_solomon@...> wrote:
      > Thanks for your help
      >
      > I read the article but I don't think it helped me
      >
      > It probably would if I understood it better
      >
      > I am trying to get the following
      >
      > <soap:Header>
      > <MessengerHeader xmlns="com.esendex.ems.soapinterface">
      > <Username>USERNAME</Username>
      > <Password>PASSWORD</Password>
      > <Account>ACCOUNT</Account>
      > </MessengerHeader>
      > </soap:Header>
      >
      > I have managed to get most of it but can't achieve
      > xmlns="com.esendex.ems.soapinterface
      >
      > I am wondering if I would be better off abandoning soap:lite and
      > finding
      > another way of sending the xml
      >
      >
      > Regards
      >
      > Mike Solomon
      >
      > -----Original Message-----
      > From: Randy J. Ray [mailto:rjray@...]
      > Sent: 26 June 2003 05:15
      > To: Mike
      > Subject: Re: [soaplite] soap headers
      >
      > You are close, but as you noted, the result is three separate
      > elements
      > within
      > the Header block, each named for your elements below:
      >
      > > # send the request w/ header
      > > my $response = $soap->SendMessageFull(
      > >
      > > # HEADER
      > > SOAP::Header->name(Username => $username),
      > > SOAP::Header->name(Password => $password),
      > > SOAP::Header->name(Account => $account),
      > >
      > > # PARAMETERS FOR BODY
      > > SOAP::Data->name(originator =>$originator),
      > > SOAP::Data->name(recipient => $recipient),
      > > SOAP::Data->name(body => $body),
      > > SOAP::Data->name(type =>$type),
      > > SOAP::Data->name(validityperiod => 99)
      > >
      > > );
      >
      > What your service is expecting is a single header entity called
      > "MessengerHeader" that itself contains those three elements.
      > Something
      > more
      > like:
      >
      > SOAP::Header->name(MessengerHeader => { Username => $username,
      > Password => $password,
      > Account => $account
      > })
      >
      > However, I think that the above will serialize strangely because of
      > the
      > defaults applied to non-blessed hash references. See my article on
      > .Net
      > programming in Perl:
      >
      > http://www.perl.com/pub/a/2003/03/26/perlanddotnet.html
      >
      > This is very similar to the biggest headache in .Net-- getting
      > serialized
      > structures to match what .Net is expecting. There's a recipe for a
      > generalized
      > structure-encoding approach that should be adaptable to what you're
      > doing.
      >
      > Randy
      > --
      >
      >
      >
      > ------------------------ Yahoo! Groups Sponsor
      >
      > To unsubscribe from this group, send an email to:
      > soaplite-unsubscribe@yahoogroups.com
      >
      >
      >
      > Your use of Yahoo! Groups is subject to
      > http://docs.yahoo.com/info/terms/
      >
      >


      __________________________________
      Do you Yahoo!?
      SBC Yahoo! DSL - Now only $29.95 per month!
      http://sbc.yahoo.com
    Your message has been successfully submitted and would be delivered to recipients shortly.