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

problem creating an object to match the WSDL

Expand Messages
  • sylvainstg <sylvainstg@hotmail.com>
    Hi, I am trying to create objects that will give me the following XML:
    Message 1 of 3 , Dec 9, 2002
    • 0 Attachment
      Hi,

      I am trying to create objects that will give me the following XML:

      <formFieldVars SOAP-ENC:arrayType="namesp2:formFieldVar[3]" ...>
      <item xsi:type="namesp2:formFieldVar">
      <name xsi:type="xsd:string">CAMNamespace</name>
      <value xsi:type="xsd:string">LDAP</value>
      ---
      <format xsi:type="namesp2:formatEnum">not_encrypted</format>
      ---
      </item>

      When writting perl like:

      my $header = SOAP::Header->name(
      'biBusHeader' => new biBusHeader(
      new CAM(undef,'logon'),
      new hdrSession([
      new formFieldVar('CAMNamespace',
      $namespace, new formatEnum('not_encrypted')),
      [...]


      The problem is that the above code gives me this XML:

      <formFieldVars SOAP-ENC:arrayType="namesp2:formFieldVar[3]" ...>
      <item xsi:type="namesp2:formFieldVar">
      <name xsi:type="xsd:string">CAMNamespace</name>
      <value xsi:type="xsd:string">LDAP</value>
      ---
      <format xsi:type="namesp2:formatEnum">
      <c-gensym17 xsi:type="xsd:string">not_encrypted</c-gensym17>
      </format>
      ---
      </item>


      It feels like the formFieldVar object is the culprit.

      package formatEnum;
      sub new {
      shift;
      my ( $value ) = @_;
      my $data = \SOAP::Data($value);

      bless $data;
      return $data;
      }

      I tried all I could think about, I cannot find a way to have the
      provided string to formatEnum object to appear as the element text
      while keeping the type of the format element (namesp2:formatEnum),
      anything I do either turn the type to string or put the data in a
      children node (c-gensym17)

      Any help much appreciated.

      Sylvain.
    • sylvainstgermain <sylvain.stgermain@cogn
      Hi, I am trying to create objects that will give me the following XML:
      Message 2 of 3 , Dec 9, 2002
      • 0 Attachment
        Hi,

        I am trying to create objects that will give me the following XML:

        <formFieldVars SOAP-ENC:arrayType="namesp2:formFieldVar[3]" ...>
        <item xsi:type="namesp2:formFieldVar">
        <name xsi:type="xsd:string">CAMNamespace</name>
        <value xsi:type="xsd:string">LDAP</value>
        ---
        <format xsi:type="namesp2:formatEnum">not_encrypted</format>
        ---
        </item>

        When writting perl like:

        my $header = SOAP::Header->name(
        'biBusHeader' => new biBusHeader(
        new CAM(undef,'logon'),
        new hdrSession([
        new formFieldVar('CAMNamespace',
        $namespace, new formatEnum('not_encrypted')),
        [...]


        The problem is that the above code gives me this XML:

        <formFieldVars SOAP-ENC:arrayType="namesp2:formFieldVar[3]" ...>
        <item xsi:type="namesp2:formFieldVar">
        <name xsi:type="xsd:string">CAMNamespace</name>
        <value xsi:type="xsd:string">LDAP</value>
        ---
        <format xsi:type="namesp2:formatEnum">
        <c-gensym17 xsi:type="xsd:string">not_encrypted</c-gensym17>
        </format>
        ---
        </item>


        It feels like the formFieldVar object is the culprit.

        package formatEnum;
        sub new {
        shift;
        my ( $value ) = @_;
        my $data = \SOAP::Data($value);

        bless $data;
        return $data;
        }

        I tried all I could think about, I cannot find a way to have the
        provided string to formatEnum object to appear as the element text
        while keeping the type of the format element (namesp2:formatEnum),
        anything I do either turn the type to string or put the data in a
        children node (c-gensym17)

        Any help much appreciated.

        Sylvain.
      • Duncan Cameron
        ... You want to override the default serialisation of a scalar ref. Create a serialiser for your formatEnum type: sub SOAP::Serializer::as_formatEnum { my
        Message 3 of 3 , Dec 9, 2002
        • 0 Attachment
          On 2002-12-09 sylvainstg <sylvainstg wrote:
          >Hi,
          >
          >I am trying to create objects that will give me the following XML:
          >
          ><formFieldVars SOAP-ENC:arrayType="namesp2:formFieldVar[3]" ...>
          > <item xsi:type="namesp2:formFieldVar">
          > <name xsi:type="xsd:string">CAMNamespace</name>
          > <value xsi:type="xsd:string">LDAP</value>
          >---
          > <format xsi:type="namesp2:formatEnum">not_encrypted</format>
          >---
          > </item>
          >
          >When writting perl like:
          >
          >my $header = SOAP::Header->name(
          > 'biBusHeader' => new biBusHeader(
          > new CAM(undef,'logon'),
          > new hdrSession([
          > new formFieldVar('CAMNamespace',
          >$namespace, new formatEnum('not_encrypted')),
          >[...]
          >
          >
          >The problem is that the above code gives me this XML:
          >
          ><formFieldVars SOAP-ENC:arrayType="namesp2:formFieldVar[3]" ...>
          > <item xsi:type="namesp2:formFieldVar">
          > <name xsi:type="xsd:string">CAMNamespace</name>
          > <value xsi:type="xsd:string">LDAP</value>
          >---
          > <format xsi:type="namesp2:formatEnum">
          > <c-gensym17 xsi:type="xsd:string">not_encrypted</c-gensym17>
          > </format>
          >---
          > </item>
          >
          >
          >It feels like the formFieldVar object is the culprit.
          >
          >package formatEnum;
          >sub new {
          > shift;
          > my ( $value ) = @_;
          > my $data = \SOAP::Data($value);
          >
          > bless $data;
          > return $data;
          >}
          >
          >I tried all I could think about, I cannot find a way to have the
          >provided string to formatEnum object to appear as the element text
          >while keeping the type of the format element (namesp2:formatEnum),
          >anything I do either turn the type to string or put the data in a
          >children node (c-gensym17)
          >
          >Any help much appreciated.

          You want to override the default serialisation of a scalar ref.

          Create a serialiser for your formatEnum type:

          sub SOAP::Serializer::as_formatEnum {
          my $self = shift;
          my($value, $name, $type, $attr) = @_;
          return [
          $name,
          {'xsi:type' => $self->maptypetouri($type), %$attr},
          $$value, # <= deref the scalar ref
          ];
          }

          Change your constructor to be simply:

          sub new {
          shift;
          my ( $value ) = @_;
          my $data = \$value;
          bless $data;
          return $data;
          }

          then refer to it as
          SOAP::Data->name(format => formatEnum->new('test'));

          Regards,
          Duncan Cameron
        Your message has been successfully submitted and would be delivered to recipients shortly.