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

Serialization problems:

Expand Messages
  • ErikTheRed
    Hello, I m new to SOAP::Lite and I m having what s probably a silly error on my part, but I haven t been able to find anything related in the archives here or
    Message 1 of 5 , Aug 20, 2008
    • 0 Attachment
      Hello, I'm new to SOAP::Lite and I'm having what's probably a silly error on my part, but I haven't been able to find anything related in the archives here or through Google. I'm trying to communicate with an interface that looks like this (with example data):

      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
      <List xmlns="http://www.test.com/">
      <credentials>
      <Username>string</Username>
      <Password>string</Password>
      <ErrorDescription>string</ErrorDescription>
      </credentials>
      <request>
      <StatusPoint>
      <Id>string</Id>
      <Note>string</Note>
      <DateSince>dateTime</DateSince>
      <DateCreated>dateTime</DateCreated>
      <ErrorDescription>string</ErrorDescription>
      <Response>string</Response>
      </StatusPoint>
      <StatusPoint>
      <Id>string</Id>
      <Note>string</Note>
      <DateSince>dateTime</DateSince>
      <DateCreated>dateTime</DateCreated>
      <ErrorDescription>string</ErrorDescription>
      <Response>string</Response>
      </StatusPoint>
      </request>
      </List>
      </soap:Body>
      </soap:Envelope>

      Essentially, it's sending two serialized objects: Credentials and Request, which itself is an array of StatusPoint objects. I've tried creating these objects a two different ways (just showing Credentials; Results is similar):

      my $CallCredentials = SOAP::Data->name("credentials" =>
      SOAP::Data->value(
      SOAP::Data->name("Username")->value($UserName)->type('string'),
      SOAP::Data->name("Password")->value($Password)->type('string'))
      );

      and

      my $CallCredentials = SOAP::Data->name("credentials" =>
      "Username" => $UserName,
      "Password" => $Password);

      Either way, when I try to call the function in question like this:

      my $results = $client->List($CallCredentials, $CallRequest)->result;

      the CallCredentials and CallRequest variables are serialized as 'nil' values:

      <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:tns="http://www.test.com/">
      <soap:Body>
      <tns:List>
      <credentials xsi:nil="true" xsi:type="tns:Credentials" />
      <request xsi:nil="true" xsi:type="tns:ArrayOfStatusPoint" />
      </tns:List>
      </soap:Body>
      </soap:Envelope>

      Any feedback as to where I've gone horribly wrong would be greatly appreciated.

      Thanks!
    • rahed
      ... Do it this way: $CallCredentials = SOAP::Data - name(credentials = SOAP::Data- value( SOAP::Data- name(Username = $UserName)- type( string ),
      Message 2 of 5 , Aug 20, 2008
      • 0 Attachment
        > my $CallCredentials = SOAP::Data->name("credentials" =>
        > SOAP::Data->value(
        > SOAP::Data->name("Username")->value($UserName)->type('string'),
        > SOAP::Data->name("Password")->value($Password)->type('string'))
        > );

        Do it this way:

        $CallCredentials = SOAP::Data
        ->name(credentials => \SOAP::Data->value(

        SOAP::Data->name(Username => $UserName)->type('string'),

        SOAP::Data->name(Password => $Password) ->type('string'),
        )
        );

        --
        Radek
      • ErikTheRed
        ... From: rahed Subject: Re: [soaplite] Serialization problems: To: Date: Wednesday, August 20, 2008, 12:58 PM ... Do it this way:
        Message 3 of 5 , Aug 20, 2008
        • 0 Attachment


          --- On Wed, 8/20/08, rahed <raherh@...> wrote:
          From: rahed <raherh@...>
          Subject: Re: [soaplite] Serialization problems:
          To:
          Date: Wednesday, August 20, 2008, 12:58 PM

          > my $CallCredentials = SOAP::Data-> name("credential s" =>
          > SOAP::Data-> value(
          > SOAP::Data-> name("Username" )->value( $UserName) ->type('string' ),
          > SOAP::Data-> name("Password" )->value( $Password) ->type('string' ))
          > );

          Do it this way:

          $CallCredentials = SOAP::Data
          ->name(credentials => \SOAP::Data- >value(

          SOAP::Data-> name(Username => $UserName)-> type('string' ),

          SOAP::Data-> name(Password => $Password) ->type('string' ),
          )
          );

          --
          Radek




          Radek,

          Thank you for your suggestion; I had missed the backslash creating a reference. I also made the other changes as you suggested (even tried a copy / paste).

          However, this syntax still gives the same result: a xsi:nil="true" value in the output XML.

          Any other suggestions would be appreciated.

          Thanks again,

          Erik



        • rahed
          ... Will you send the whole request/response? -- Radek
          Message 4 of 5 , Aug 22, 2008
          • 0 Attachment
            > Thank you for your suggestion; I had missed the backslash creating a reference.
            >
            > However, this syntax still gives the same result: a xsi:nil="true" value in the output XML.
            >
            > Any other suggestions would be appreciated.
            >

            Will you send the whole request/response?

            --
            Radek
          • rahed
            ... Fault string says you send a wrong envelope namespace. It should be xmlns:soap= http://schemas.xmlsoap.org/soap/envelope/ If there are problems I wouldn t
            Message 5 of 5 , Aug 24, 2008
            • 0 Attachment
              > <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header><soap12:Upgrade xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"><soap12:SupportedEnvelope qname="soap:Envelope" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" /><soap12:SupportedEnvelope qname="soap12:Envelope" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" /></soap12:Upgrade></soap:Header><soap:Body><soap:Fault><faultcode>soap:VersionMismatch</faultcode><faultstring>Possible SOAP version mismatch: Envelope namespace http://schemas.xmlsoap.org/wsdl/soap/ was unexpected. Expecting http://schemas.xmlsoap.org/soap/envelope/.</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>

              Fault string says you send a wrong envelope namespace.
              It should be xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"

              If there are problems I wouldn't create the message from wsdl using a
              service method and start like this:

              $client = SOAP::Lite->new(uri => 'namespace',
              proxy => 'endpoint',);
              $client->List('soapdata');
              Default namespaces are generated implicitly.

              --
              Radek
            Your message has been successfully submitted and would be delivered to recipients shortly.