yuhang91 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'm new to Perl and I'm having difficulty accessing a SOAP webservice using SOAP::Lite because one of the parameters has to be a 64 bit integer (it gives error if I provide a 32 bit integer). The integer that I'm trying to use can be sufficiently represented as 32 bit and I just can't get Perl to assign those extra 32 bits of zeros to make it 64 bits! My line of code for setting up the SOAP call parameters is as follows: @params = SOAP::Data -> name(identifier => $identifier); where $identifier is the integer. I would later use: $return = $service -> call($method => @params); to make the call, where $method is the name of the webservice method. Is there any way I can make this work? Thanks in advance! Hans

Replies are listed 'Best First'.
Re: Force integer to occupy 64 bits (bytes)
by Anonymous Monk on Jul 29, 2013 at 08:44 UTC

    has to be a 64 bit integer (it gives error if I provide a 32 bit integer)

    What is that? You see SOAP sends bytes, so what kind of bytes does it want you to send for the 64-bit integer?

    Does it like this string? sprintf '%09x', 12;

      I was mistakenly blaming Perl for my problem. It seems that the real cause lies within the XML generated by the SOAP call:
      <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" x +mlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="h +ttp://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.x +mlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soa +p/envelope/"><soap:Body><loadPathwayForId><identifier xsi:type="xsd:i +nt">68886</identifier></loadPathwayForId></soap:Body></soap:Envelope>

      I just have to somehow get xsi:type to say "xsd:long" instead of "xsd:int".
      It wants bytes as long (int64) type. Giving it sprintf '%09x', 12; gives me the error org.xml.sax.SAXException: Bad types (class java.lang.String -> long). Similarly, when I give it a number that can be represented as int32 (not big enough for int64), it gives org.xml.sax.SAXException: Bad types (int -> long).

        It wants bytes as long (int64) type.

        But that isn't bytes, it doesn't say byte order (little or big endian). Have you see pack?
        pack'q<', $d64
        pack 'q>', $d64