History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: LPP-5481
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: P0 P0
Assignee: Henry Minsky
Reporter: Wietze Brandsma
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
OpenLaszlo

XML-RPC does not work in openlaszlo-4.0.9.1

Created: 27/Feb/08 01:48 PM   Updated: 15/Apr/08 03:51 PM
Component/s: RPC - XML-RPC
Affects Version/s: Snowcone (4.0.9)
Fix Version/s: Cronus, Yodel

Time Tracking:
Not Specified

File Attachments: 1. File LPP-5481.lzx (0.9 kb)

Environment:
Openlaszlo-4.0.9.1, Apache xmlrpc-3.1

Severity: Blocker
Fixed in Change#: 8,678
Runtime: N/A, SWF7, SWF8
Flags: Regression
Fix in hand: False


 Description  « Hide
XML-RPC does not work openlaszlo-4.0.9.1 and 4.0.10, it did work in openlaszlo-4.0.8 and before.
The error message is: "HTTP Status code: 505:Http Version Not Supported".

Reproducing the error:
The error can be reproduced by calling the xml-rpc procedure with the calculator.lzx source.

Setting up the xml-rpc server:
Configure the apache xmlrc-3.1 (or 3.0) server with the calculator demo from the apache xmlrpc website.
Copy the server, common and client modules to the lps-4.0.9.1/WEB-INF/classes.
Copy the ws-commons-util-1.0.1.jar (or 1.0.2) to the lps-4.0.9.1/WEB-INF/lib.

The xmlrpc client module can be used to test the correct setup of the xmlrpc server with the calculator.jsp source.
This calculator.jsp make use of the XmlRpcCalculator.class.

Links:
http://ws.apache.org/xmlrpc/
http://ws.apache.org/xmlrpc/server.html
http://ws.apache.org/xmlrpc/client.html

--

calculator.lzx
==============
<?xml version="1.0" encoding="UTF-8" ?>
<canvas debug="true">
  <simplelayout></simplelayout>
  <text>Openlaszlo Calculator!</text>
  <edittext id="n1">33</edittext>
  <edittext id="n2">9</edittext>
  <button onclick="result.calcAdd(n1.text,n2.text)">Add (local)</button>
  <button onclick="result.calcSub(n1.text,n2.text)">Subtract (local)</button>
  <text>The Result is:</text>
  <text id="result" text="0">
    <method name="calcAdd" args="n1, n2">
       var sum = (n1 - 0) + (n2 - 0);
       this.setText(sum);
    </method>
    <method name="calcSub" args="n1, n2">
       var sum = (n1 - 0) - (n2 - 0);
       this.setText(sum);
    </method>
  </text>
    <button text="Add (xml-rpc)">
        <handler name="onclick">
            Debug.write('calling xml-rpc Calculator.add...');
            calc.add.i1.value = n1.getValue() - 0;
            calc.add.i2.value = n2.getValue() - 0;
            calc.add.invoke();
        </handler>
    </button>

<xmlrpc service="http://localhost:8080/lps-4.0.9.1/xmlrpc" name="calc">
<handler name="onload">
            Debug.write('calc XML-RPC service loaded');
            Debug.write('proxy:');
            Debug.inspect(this.proxy);
        </handler>

        <handler name="ondata" args="data">
            Debug.write('got data:', data);
            result.setText(data);
        </handler>

        <handler name="onerror" args="error">
            Debug.write('onerror:', error);
        </handler>

        <remotecall name="add" funcname="Calculator.add">
         <param value="0" name="i1"></param>
         <param value="0" name="i2"></param>
        </remotecall>

</xmlrpc>
</canvas>



calculator.jsp
==============
<%@page contentType="text/html" import="org.example.xmlrpc.XmlRpcCalculator" %>

<%
  int n1 = 33;
  int n2 = 9;
  int result = 0;
  String formAction=request.getParameter("formAction");
  String str1=request.getParameter("number1");
  String str2=request.getParameter("number2");
  if ("Add".equals(formAction)) {
    n1 = Integer.parseInt(str1);
    n2 = Integer.parseInt(str2);
    result = XmlRpcCalculator.calcAdd(n1, n2);
  }
  if ("Sub".equals(formAction)) {
    n1 = Integer.parseInt(str1);
    n2 = Integer.parseInt(str2);
    result = XmlRpcCalculator.calcSub(n1, n2);
  }
%>

<html>
  <head>
    <title>Calculator</title>
    <h1>XML-RPC Server Test</h1>
  </head>
  <body>
    <form method="post">
      <input name="src" type="hidden" value="src">
      <input type="submit" name="formAction" value="Add">
      <input type="submit" name="formAction" value="Sub">
      <input type="text" name="number1" value="<%=n1%>">
      <input type="text" name="number2" value="<%=n2%>">
      <input type="text" name="result" value="<%=result%>">
    </form>
    <p>This xmlrpc calculator is based on the calculator example of <a href="http://ws.apache.org/xmlrpc/">Apache XML-RPC</a></p>
  </body>
</html>



XmlRpcCalculator.java
=====================
package org.example.xmlrpc;

import java.net.MalformedURLException;
import java.net.URL;

import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;

public class XmlRpcCalculator {
  private static int calc(String operator, int n1, int n2) {
    XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
    try {
      config.setServerURL(new URL("http://localhost:8080/lps-4.0.9.1/xmlrpc"));
    } catch (MalformedURLException e) {
      //e.printStackTrace();
    }
    XmlRpcClient client = new XmlRpcClient();
    client.setConfig(config);
    Object[] params = new Object[] { new Integer(n1), new Integer(n2) };
    try {
      Integer result = (Integer) client.execute("Calculator."+operator, params);
      if (result != null)
        return result.intValue();
    } catch (XmlRpcException e) {
      //e.printStackTrace();
    }
    return 0;
  }
  public static int calcAdd(int n1, int n2) {
    return calc( "add", n1, n2 );
  }
  public static int calcSub(int n1, int n2) {
    return calc( "subtract", n1, n2 );
  }
}


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
André Bargull - 11/Mar/08 12:45 AM
BTW, if you're too lazy to set this up, you can also use the xml-rpc demo from the dev-guide (attached as "LPP-5481.lzx").
And I've confirmed that xml-rpc doesn't work anymore in trunk.

André Bargull - 11/Mar/08 12:40 PM
Update:
When using the 4.0.7 data-classes (org.openlaszlo.data.**) in trunk, xml-rpc did work again.

André Bargull - 11/Mar/08 04:24 PM
Culprit: Rev. #7880, org.openlaszlo.data.HTTPDataSource

All rpc-classes (java-rpc, xml-rpc, soap) use "lzpostbody" to post the arguments to the server, but they don't use LzHTTPLoader, but the normal LzLoader. So, either change HTTPDataSource or update the rpc-components? Right now, I'm one testing the first alternative.

Henry Minsky - 11/Mar/08 05:56 PM
Ah, we moved to the newer LzHTTPDataProvider API, and I never deleted the DataSource class. But HTTPDataSource definitely won't work anymore, need to update to
HTTPDataProvider.

Henry Minsky - 03/Apr/08 09:41 AM
The binary search tool tells me that r7880 caused this regression

r7880 is the revision with the problem:
------------------------------------------------------------------------
r7880 | hqm | 2008-01-23 20:57:05 -0500 (Wed, 23 Jan 2008) | 59 lines

Merged revisions 7872 via svnmerge from
http://svn.openlaszlo.org/openlaszlo/branches/wafflecone

........
  r7872 | hqm | 2008-01-23 13:50:26 -0500 (Wed, 23 Jan 2008) | 53 lines
  
  Change 20080123-hqm-4 by hqm@DADDY_THNKPAD67 on 2008-01-23 09:36:16 EST
      in /cygdrive/c/users/hqm/openlaszlo/wafflecone
      for http://svn.openlaszlo.org/openlaszlo/branches/wafflecone
  
  
  Summary: updated: preserve url query string with post data requests
  
  New Features:
  
  Bugs Fixed: LPP-5368
  
  Technical Reviewer: pkang
  QA Reviewer: ptw
  Doc Reviewer:
  
  Documentation:
  
  The URL which is specified as the 'src' attribute of a dataset, such as
  
  <dataset src="http://foo.bar.com/baz.php?myarg=1" />
  
  will be preserved in POST operations, both SOLO and proxied.
  
  All data which is set via the
  
  setQueryString
  setQueryParam
  setQueryParams
  
  will be stored in a distinct table, and will only be merged with the src url
  in the case of a GET request.
  
  For POST requests, the src full URL with its original query string will be sent,
  and all other param data will be sent www-form-encoded in the POST body.
  
  
  Note: raw post data via the "lzpostbody" arg turns out not to work in SOLO mode,
  and has never actually fully worked.
  
  
  Release Notes:
  
  Details:
  
  
  Tests:
  
  test/lfc/data/alldata.lzx DHTML/SWF
  
  amazon
  calendar proxied/solo DHTML/SWF
........

Amy Muntz - 03/Apr/08 11:37 AM
Henry - back to you.

Henry Minsky - 09/Apr/08 07:44 PM
The XMLRPC client uses lzpostbody to send the XML RPC body, and lzpostbody behavior changed in r7880.
XMLRPC only works in proxied mode, so should only be affected lzpostbody
behavior change in proxied mode.


Amy Muntz - 10/Apr/08 08:37 AM
Henry- please fix in trunk and merge to pagan-deities. Thanks.

Henry Minsky - 11/Apr/08 12:24 PM
r8635 | hqm | 2008-04-11 15:23:04 -0400 (Fri, 11 Apr 2008) | 54 lines
Changed paths:
   M /openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataset.lzs
   M /openlaszlo/trunk/WEB-INF/lps/lfc/data/LzHTTPDataProvider.lzs
   M /openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzHTTPLoader.as
   M /openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoadQueue.as
   M /openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs
   M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/data/HTTPDataSource.java
   M /openlaszlo/trunk/demos/vacation-survey/vacation-survey.lzx
   M /openlaszlo/trunk/test/data/data-url.lzx
   M /openlaszlo/trunk/test/lfc/data/alldata.lzx
   A /openlaszlo/trunk/test/lfc/data/testgetmethod.lzx
   A /openlaszlo/trunk/test/lfc/data/testgetmethodsolo.lzx
   A /openlaszlo/trunk/test/lfc/data/testpostmethod.lzx
   A /openlaszlo/trunk/test/lfc/data/testpostmethodsolo.lzx

Change 20080411-hqm-4 by hqm@badtzmaru.home on 2008-04-11 15:22:41 EDT
    in /Users/hqm/openlaszlo/trunk5
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: fix for XML RPC, and some other brain damage in data loader

New Features:

Bugs Fixed: LPP-5481

Technical Reviewer: max
QA Reviewer: pbr
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:

+ A while back we discovered that that data loading API would not let
you POST data to a url while also supporting an independent query
string in the URL.

So I had made some fixes for that, both in SOLO and proxied mode. In
proxied mode I moved the place where the POST payload was stored out
of the "url" arg.

That caused some trouble because there is older code in
XMLRPCDataSource.java which expects to be able to stick
"lzpostbody=DATA" into the url and call the
HTTPDataSource.getHTTPData() method, which no longer expects to see
that data there.

I fixed this by putting back the code to look for the "lzpostbody" arg
inside the URL as well as in the proxy request parameters.

Sorry this is so baroque. The main idea going forward is that we have
the LzHTTPLoader API which looks like the javascript XMLHTTPRequest.
Everything in LzHTTPDataProvider is geared to talk to that API; a URL
with query args, and an optional POST content string.

The SWF kernel loader code has to then unpack that and make it work
with the brain-dead Flash LoadVars HTTP API as much as possible, in
solo and proxied mode.


Tests:

test/lfc/data/alldata.lzx, in dhtml and swf
demos/amazon
XMLRPC test case in bug report



Amy Muntz - 15/Apr/08 06:56 AM
NOT merged to pagan-deities. Needs to be merged before it can be truly resolved.

Henry Minsky - 15/Apr/08 07:17 AM
merged in r8678 to pagan

Henry Minsky - 15/Apr/08 03:51 PM
------------------------------------------------------------------------
r8678 | hqm | 2008-04-15 09:26:10 -0400 (Tue, 15 Apr 2008) | 1 line
Changed paths:
   M /openlaszlo/branches/pagan-deities
   M /openlaszlo/branches/pagan-deities/WEB-INF/lps/lfc/data/LzDataset.lzs
   M /openlaszlo/branches/pagan-deities/WEB-INF/lps/lfc/data/LzHTTPDataProvider.lzs
   M /openlaszlo/branches/pagan-deities/WEB-INF/lps/lfc/kernel/swf/LzHTTPLoader.as
   M /openlaszlo/branches/pagan-deities/WEB-INF/lps/lfc/kernel/swf/LzLoadQueue.as
   M /openlaszlo/branches/pagan-deities/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs
   M /openlaszlo/branches/pagan-deities/WEB-INF/lps/server/src/org/openlaszlo/data/HTTPDataSource.java
   M /openlaszlo/branches/pagan-deities/demos/vacation-survey/vacation-survey.lzx
   M /openlaszlo/branches/pagan-deities/test/data/data-url.lzx
   M /openlaszlo/branches/pagan-deities/test/lfc/data/alldata.lzx

integrate r8635 xmlrpc patch from trunk
------------------------------------------------------------------------