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

Re: How do I add a namespace to the deserializer?

Expand Messages
  • gnawed
    ... Should be: $client- setCar( SOAP::Data- name(aCar = Toyota )- type( tns:cars )- attr ({ xmlns:tns = urn:/My/NameSpace }) );
    Message 1 of 2 , Sep 22, 2003
    • 0 Attachment
      Whoops, some typos. See below:

      --- In soaplite@yahoogroups.com, "gnawed" <gnawed@y...> wrote:
      > If I have my own datatype like this:
      >
      > <xsd:simpleType name="cars">
      > <xsd:restriction base="xsd:string">
      > <xsd:enumeration value="Toyota"/>
      > <xsd:enumeration value="Ford"/>
      > </xsd:restriction>
      > </xsd:simpleType>
      >
      > The client makes a call like:
      >
      > $client->setCar(
      > SOAP::Data->name(aCar => 'Toyota')->type(tns:cars)->attr
      > ({'xmlns:cars' => 'urn:/My/NameSpace'})
      > );
      >

      Should be:
      $client->setCar(
      SOAP::Data->name(aCar => 'Toyota')->type('tns:cars')->attr
      ({'xmlns:tns' => 'urn:/My/NameSpace'})
      );


      >
      > How do I set up my SOAP::Server to deserialize this?
      >
      > I tried this:
      >
      > my $d = new SOAP::Deserializer();
      > $d->xmlschemas->{'urn:/My/NameSpace'} = 'My::Deserializer';
      > SOAP::Server->deserializer($d);
      >
      >
      > and the deserializer looks like:
      >
      > package My::Deserializer;
      >
      > sub as_cars {
      > my $self = shift;
      > my ($value, $name, $attr, $chil, $type) = @_;
      > return $value;
      > }
      >
      >
      > This doesn't work. I get a message like:
      >
      > Application failed during request deserialization: Unrecognized
      > type '{urn:/My/NameSpace}cars'
      >
      >
      >
      > I can get it to work if I change the client like this:
      >
      > $client->setCar(
      > SOAP::Data->name(aCar => 'Toyota')->type(tns:cars)->attr
      > ({'xmlns:cars' => 'http://schemas.xmlsoap.org/soap/encoding/'})
      > );
      >
      >
      > and add a function to the server like:
      >
      >
      > package SOAP::XMLSchemaSOAP1_1::Deserializer;
      > sub SOAP::XMLSchemaSOAP1_1::Deserializer::as_cars {
      > my $self = shift;
      > my ($value, $name, $attr, $chil, $type) = @_;
      > return $value;
      > }
      >
      >
      > What am I doing wrong?
    Your message has been successfully submitted and would be delivered to recipients shortly.