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

SOAP::Lite service - Trouble accepting "enumeration" types

Expand Messages
  • pfconrey
    I have a SOAP::Lite service method that takes two parameters: a string and a custom-defined Address type. The address type has a member that is of type
    Message 1 of 2 , Oct 10, 2005
      I have a SOAP::Lite service method that takes two parameters: a string
      and a custom-defined "Address" type. The address type has a member
      that is of type "ContactLocation", which is defined in the WSDL schema as:

      <xsd:simpleType name="ContactLocation">
      <xsd:restriction base="xsd:string">
      <xsd:enumeration value="NA" />
      <xsd:enumeration value="Home" />
      <xsd:enumeration value="Business" />
      <xsd:enumeration value="Travel" />
      </xsd:restriction>
      </xsd:simpleType>

      When the client calls the service and passes in a valid address
      (namespace declarations and additional info removed for clarity):

      <soap:Envelope>
      <soap:Body>
      <tns:AddOptOut>
      <Address xsi:type="tns:Address">
      <Type xsi:type="tns:ContactLocation">NA</Type>
      blah, blah, blah...
      </Address>
      </tns:AddOptOut>
      </soap:Body>
      </soap:Envelope>


      I get the following error (again, namespace attributes removed to make
      it easier to read):

      <SOAP-ENV:Envelope>
      <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
      <faultcode>SOAP-ENV:Client</faultcode>
      <faultstring>
      Application failed during request deserialization:
      Unrecognized type 'ContactLocation'
      </faultstring>
      </SOAP-ENV:Fault>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

      Where in the process can I look at the incoming soap request and
      customize the deserialization?
    • Cédric BOUFFLERS
      Hello, To deal with enum I had to overload the deserializer to support the enum ... * In the main service file : #!/usr/bin/perl use strict; use warnings; use
      Message 2 of 2 , Oct 10, 2005
        Hello,

        To deal with enum I had to overload the deserializer to support the enum
        types. For example :

        --------------------------------------
        * In the main service file :

        #!/usr/bin/perl

        use strict;
        use warnings;
        use locale;

        use MyDeserializer;

        use SOAP::Transport::HTTP;

        SOAP::Transport::HTTP::CGI->deserializer(MyDeserializer->new)

        ->dispatch_to('MyService')->handle();

        --------------------------------------
        * In the WSDL :

        <xsd:simpleType name="MyEnumType ">
        <xsd:restriction base="xsd:string">
        <xsd:enumeration value="ONE" />
        <xsd:enumeration value="TWO" />
        <xsd:enumeration value="THREE" />
        </xsd:restriction>
        </xsd:simpleType>

        --------------------------------------
        * In the file MyDeserializer.pm :

        package MyDeserializer;

        use SOAP::Lite;
        @MyDeserializer::ISA = 'SOAP::Deserializer';

        sub as_MyEnumType {
        my($self, $value, $name, $type, $attr) = @_;
        return $value;
        }

        --------------------------------------


        I am not sure if it is the best way to deal with it, but it works quite fine
        here. Although I never dealt with Enum type included in complex type. Tell
        me if it worked.

        You can create any "as_[TYPE_TO_OVERLOAD]" methods you need for your enums
        types.

        Best Regards,
        Cédric



        -----Message d'origine-----
        De : soaplite@yahoogroups.com [mailto:soaplite@yahoogroups.com] De la part
        de pfconrey
        Envoyé : lundi 10 octobre 2005 18:02
        À : soaplite@yahoogroups.com
        Objet : [soaplite] SOAP::Lite service - Trouble accepting "enumeration"
        types

        I have a SOAP::Lite service method that takes two parameters: a string
        and a custom-defined "Address" type. The address type has a member
        that is of type "ContactLocation", which is defined in the WSDL schema as:

        <xsd:simpleType name="ContactLocation">
        <xsd:restriction base="xsd:string">
        <xsd:enumeration value="NA" />
        <xsd:enumeration value="Home" />
        <xsd:enumeration value="Business" />
        <xsd:enumeration value="Travel" />
        </xsd:restriction>
        </xsd:simpleType>

        When the client calls the service and passes in a valid address
        (namespace declarations and additional info removed for clarity):

        <soap:Envelope>
        <soap:Body>
        <tns:AddOptOut>
        <Address xsi:type="tns:Address">
        <Type xsi:type="tns:ContactLocation">NA</Type>
        blah, blah, blah...
        </Address>
        </tns:AddOptOut>
        </soap:Body>
        </soap:Envelope>


        I get the following error (again, namespace attributes removed to make
        it easier to read):

        <SOAP-ENV:Envelope>
        <SOAP-ENV:Body>
        <SOAP-ENV:Fault>
        <faultcode>SOAP-ENV:Client</faultcode>
        <faultstring>
        Application failed during request deserialization:
        Unrecognized type 'ContactLocation'
        </faultstring>
        </SOAP-ENV:Fault>
        </SOAP-ENV:Body>
        </SOAP-ENV:Envelope>

        Where in the process can I look at the incoming soap request and
        customize the deserialization?







        Yahoo! Groups Links
      Your message has been successfully submitted and would be delivered to recipients shortly.