Professional Web Applications Themes

Coldfusion bot passing "long" value correctly - Coldfusion - Advanced Techniques

Hi All, I tried to search through forums here but could not come across anyone having same problem as me. I am trying to consume java webservices from coldfusion. My webservice method expects a Java long number. Below is the code that I am using. Now the problem is that when colfusion passes this to the webservice its some how changing last 4 digits of the long number. When I pass 7594510353030614869 long number its actually passing 7594510353030615040(I can see this by dumping the raw soap request.) so my question is "Is this a bug in Coldfusion ?" or I ...

  1. #1

    Default Coldfusion bot passing "long" value correctly

    Hi All,

    I tried to search through forums here but could not come across anyone having
    same problem as me.

    I am trying to consume java webservices from coldfusion. My webservice method
    expects a Java long number. Below is the code that I am using. Now the problem
    is that when colfusion passes this to the webservice its some how changing last
    4 digits of the long number. When I pass 7594510353030614869 long number its
    actually passing 7594510353030615040(I can see this by dumping the raw soap
    request.) so my question is "Is this a bug in Coldfusion ?" or I am doing
    something wrong in passing the long value.



    <cfscript>
    sID = createObject("java",
    "java.lang.Long").init("7594510353030614869").long Value() ;

    writeOutput(sID);
    ws =
    CreateObject("webservice","https://my.sensorlogic.com/webservices/services/SLSes
    sionService?wsdl");

    theVal = ws.isValidSession( sID );

    resp = getSOAPResponse(ws);
    req = getSOAPRequest(ws) ;
    </cfscript>
    <cfdump var="#req#" />
    <cfdump var="#resp#" />

    gumnam Guest

  2. #2

    Default Re: Coldfusion not passing "long" value correctly

    The reason that CF is getting the number wrong is because you are passing a
    quoted string to the constructor of the long. ColdFusion treats all numbers as
    doubles, which introduces a rounding error when it converts it to the proper
    type (in this case a long) for the constructor.

    The fix is to remote the quotes:
    sID = createObject("java",
    "java.lang.Long").init(7594510353030614869).longVa lue() ;

    And the code behaves correctly.



    tomj Guest

  3. #3

    Default Re: Coldfusion not passing "long" value correctly

    Thanks for you reply. I tried changing it from string to number(i.e removed the
    quotes). But still when I dump the SOAP request , its passing the wrong value
    7594510353030615040. Do I need to do anything else..or Am I missing something.


    gumnam Guest

  4. #4

    Default Re: Coldfusion not passing "long" value correctly

    NOTE: I think the sID value which is result of createObject is fine. To Me it looks like when its passing through SOAP for webservice invocation , its introducing some error.
    gumnam Guest

  5. #5

    Default Re: Coldfusion not passing "long" value correctly

    I apologize, you are correct the SOAP request does contain the rounded value. I
    was looking at the sID value output in the test case.

    This is an artifact of the same problem that affected the creation of the Long
    java object. The number gets converted in to a double before being put in to
    the long argument to the web service stub.

    This is a bug. I have filed it as bug #61459. Unfortunately I don't have a
    work around to provide to you at this time. I will see if we can fix this in a
    CFMX 7.0.1 hotfix, but I can't promise that.



    tomj Guest

Similar Threads

  1. Replies: 3
    Last Post: August 20th, 12:52 AM
  2. Replies: 4
    Last Post: April 2nd, 12:26 PM
  3. Replies: 0
    Last Post: October 16th, 10:00 PM
  4. Replies: 1
    Last Post: October 16th, 09:41 PM
  5. Replies: 0
    Last Post: October 15th, 02:21 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139