You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlrpc-dev@ws.apache.org by Jimisola Laursen <li...@jimisola.com> on 2006/09/14 00:18:41 UTC

Exception thrown when setting content length optional to true

Hi!

I am trying to send a file over XMLRPC using an byte array (byte[]), but an
exception is thrown when content length optional is set to true.
At first I thought it had to do with the byte array, but I this exception
with a simple ping/echo method as well.

I am using PropertyHandlerMapping on the server-side and a Proxy solution on
the Agent side.
I've used this same setup before, but I had to recreate the test from
scratch so I am thinking that  I might have missed out on something.
But since it works when content length optional is set to false I have my
doubts.

Regards,
Jimisola

These are the outputs that I get:
 
Client:
 
 [Fatal Error] :2:6: The processing instruction target matching
"[xX][mM][lL]" is not allowed.
Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
	at $Proxy0.echo(Unknown Source)
	at xmlrpctest.Client.main(Client.java:33)
Caused by: org.apache.xmlrpc.client.XmlRpcClientException: Failed to parse
servers response: The processing instruction target matching "[xX][mM][lL]"
is not allowed.
	at
org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:177)
	at
org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:145)
	at
org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:94)
	at
org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:53)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:166)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:136)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:125)
	at
org.apache.xmlrpc.client.util.ClientFactory$1.invoke(ClientFactory.java:104)
	... 2 more
	
Server:
lFatal Error] :1:1: Content is not allowed in prolog.

The code:

package xmlrpctest;

import java.io.IOException;
import java.net.InetAddress;

import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.server.PropertyHandlerMapping;
import org.apache.xmlrpc.server.XmlRpcServer;
import org.apache.xmlrpc.server.XmlRpcServerConfigImpl;
import org.apache.xmlrpc.webserver.WebServer;

public class Server
{
    public static void main(String[] args) throws XmlRpcException,
IOException
    {
        WebServer webServer = new WebServer(8080,
InetAddress.getByName("localhost"));
        
        XmlRpcServer xmlRpcServer = webServer.getXmlRpcServer();

        // use reflection for (dynamic) mapping
        PropertyHandlerMapping phm = new PropertyHandlerMapping();

        // add handler - using full name for use by dynamic proxy
        phm.addHandler(TestRPC.class.getName(), TestRPCImpl.class);        
        xmlRpcServer.setHandlerMapping(phm);
        
        XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl)
xmlRpcServer.getConfig();
        serverConfig.setEnabledForExtensions(true);
        serverConfig.setContentLengthOptional(true);

        webServer.start();
    }
}

package xmlrpctest;

import java.io.FileInputStream;
import java.net.URL;

import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
import org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory;
import org.apache.xmlrpc.client.util.ClientFactory;

public class Client
{
    public static void main(String[] args) throws Exception
    {
        URL url = new URL("http://localhost:8080/RPC2");

        XmlRpcClientConfigImpl clientConfig = new XmlRpcClientConfigImpl();

        clientConfig.setServerURL(url);
        clientConfig.setEnabledForExtensions(true);
        clientConfig.setContentLengthOptional(true);
        XmlRpcClient client = new XmlRpcClient();

        // use Commons HttpClient as transport
        client.setTransportFactory(new
XmlRpcCommonsTransportFactory(client));
        // set configuration
        client.setConfig(clientConfig);

        // make a call using dynamic proxy
        ClientFactory factory = new ClientFactory(client);
        TestRPC testRPC = (TestRPC) factory.newInstance(TestRPC.class);

        System.out.println(testRPC.echo("ping"));

        /*
        FileInputStream fis = new FileInputStream("/tmp/java.txt");
        byte[] ba = new byte[fis.available()];
        
        fis.read(ba);
        fis.close();
        int length = testRPC.upload(ba);
        
        System.out.println(length);
        */
    }
}

package xmlrpctest;

import org.apache.xmlrpc.XmlRpcException;

public interface TestRPC
{
    int upload(byte[] data) throws XmlRpcException, Exception;

    String echo(String s);

}

package xmlrpctest;

import java.io.FileOutputStream;

import org.apache.xmlrpc.XmlRpcException;

public class TestRPCImpl implements TestRPC
{

    public int upload(byte[] data) throws XmlRpcException, Exception
    {
        FileOutputStream fos = new FileOutputStream("/tmp/java.txt.out");
        fos.write(data);
        fos.close();
        
        return data.length;
    }

    public String echo(String s)
    {
        System.out.println("Returning: " + s);
        return s;
    }
}

pom.xml:
<?xml version="1.0" encoding="UTF-8"?><project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>test</groupId>
  <artifactId>test</artifactId>
  <version>0.0.1</version>
  <description></description>
  <dependencies>
    <dependency>
      <groupId>org.apache.xmlrpc</groupId>
      <artifactId>xmlrpc-common</artifactId>
      <version>3.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.xmlrpc</groupId>
      <artifactId>xmlrpc-client</artifactId>
      <version>3.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.xmlrpc</groupId>
      <artifactId>xmlrpc-server</artifactId>
      <version>3.0</version>
    </dependency>
            <dependency>
                <artifactId>commons-codec</artifactId>
                <groupId>commons-codec</groupId>
                <version>1.3</version>
            </dependency>

            <dependency>
                <artifactId>commons-httpclient</artifactId>
                <groupId>commons-httpclient</groupId>
                <version>3.0.1</version>
            </dependency>

            <dependency>
                <artifactId>commons-lang</artifactId>
                <groupId>commons-lang</groupId>
                <version>2.1</version>
            </dependency>
  </dependencies>
</project>
-- 
View this message in context: http://www.nabble.com/Exception-thrown-when-setting-content-length-optional-to-true-tf2268435.html#a6295922
Sent from the Apache Xml-RPC - Dev forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org


[Fatal Error] messages in catalina.out

Posted by Sreenath Nampally <sr...@tigr.ORG>.
I am getting following messages in my catalina.out file . I am using
Tomcat 5.0.28
with xmlrpc3.0 . 

[Fatal Error] :1:15: The ' = ' character must follow "version0" in the
XML declaration.
[Fatal Error] :1:1: Content is not allowed in prolog.
[Fatal Error] :1:20: XML document structures must start and end within
the same entity.
[Fatal Error] :1:1: Content is not allowed in prolog.
[Fatal Error] :1:27: XML version "1. coding=" is not supported, only XML
1.0 is supported.

I am setting setContentLengthOptional(true) and
setEnabledForExtensions(true)
for both client and server config objects.

    xmlRpcClinetconfig = new XmlRpcClientConfigImpl();
   xmlRpcClinetconfig.setContentLengthOptional(true);
   xmlRpcClinetconfig.setEnabledForExtensions(true);

     XmlRpcServerConfigImpl serverConfig =
                  (XmlRpcServerConfigImpl) xmlRpcServer.getConfig();
    serverConfig.setEnabledForExtensions(true);
    serverConfig.setContentLengthOptional(true);

My XML seems to be fine but I am not setting any encoding in the header.
  
Any ideas what's causing these errors ?

Thanks
Sree


---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org


Re: Exception thrown when setting content length optional to true

Posted by Jochen Wiedmann <jo...@gmail.com>.
On 9/18/06, Jimisola Laursen <li...@jimisola.com> wrote:

> Looking directly at the repo the files are dated "18-Sep-2006 13:13".
> Not sure which time zone the repo is in, but are these the correct files?

Yes, they've been built just some minutes ago.

Jochen

-- 
My wife Mary and I have been married for forty-seven years and not
once have we had an argument serious enough to consider divorce;
murder, yes, but divorce, never.
(Jack Benny)

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org


Re: Exception thrown when setting content length optional to true

Posted by Jimisola Laursen <li...@jimisola.com>.
Issue filed as XMLRPC-114. Maven project to produce has been attached.

Jimisola


Jimisola Laursen wrote:
> 
> Cleaned out my repo. Problem still exists. Filing an issue report.
> 
> Thank for you taking your time.
> 
> Jimisola
> 
> 
> Jimisola Laursen wrote:
>> 
>> I'll do so.
>> 
>> Just tried "mvn -U...", but none of the xmlrpc packages were
>> downloaded/updated.
>> Is there a delay before the packages are made available?
>> 
>> Looking directly at the repo the files are dated "18-Sep-2006 13:13".
>> Not sure which time zone the repo is in, but are these the correct files?
>> 
>> Regards,
>> Jimisola
>> 
>> 
>> Jochen Wiedmann wrote:
>>> 
>>> On 9/18/06, Jimisola Laursen <li...@jimisola.com> wrote:
>>> 
>>>> Sad to say that I have this problem with 3.1-SNAPSHOT as well.
>>>>
>>>> Can I provide more information is some way?
>>> 
>>> I have rebuilt the nightlies from the latest SVN tree. Please retry.
>>> If the problem actually persists, please file a Jira issue.
>>> 
>>> Jochen
>>> 
>>> -- 
>>> My wife Mary and I have been married for forty-seven years and not
>>> once have we had an argument serious enough to consider divorce;
>>> murder, yes, but divorce, never.
>>> (Jack Benny)
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
>>> For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Exception-thrown-when-setting-content-length-optional-to-true-tf2268435.html#a6371721
Sent from the Apache Xml-RPC - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org


Re: Exception thrown when setting content length optional to true

Posted by Jimisola Laursen <li...@jimisola.com>.
Cleaned out my repo. Problem still exists. Filing an issue report.

Thank for you taking your time.

Jimisola


Jimisola Laursen wrote:
> 
> I'll do so.
> 
> Just tried "mvn -U...", but none of the xmlrpc packages were
> downloaded/updated.
> Is there a delay before the packages are made available?
> 
> Looking directly at the repo the files are dated "18-Sep-2006 13:13".
> Not sure which time zone the repo is in, but are these the correct files?
> 
> Regards,
> Jimisola
> 
> 
> Jochen Wiedmann wrote:
>> 
>> On 9/18/06, Jimisola Laursen <li...@jimisola.com> wrote:
>> 
>>> Sad to say that I have this problem with 3.1-SNAPSHOT as well.
>>>
>>> Can I provide more information is some way?
>> 
>> I have rebuilt the nightlies from the latest SVN tree. Please retry.
>> If the problem actually persists, please file a Jira issue.
>> 
>> Jochen
>> 
>> -- 
>> My wife Mary and I have been married for forty-seven years and not
>> once have we had an argument serious enough to consider divorce;
>> murder, yes, but divorce, never.
>> (Jack Benny)
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
>> For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Exception-thrown-when-setting-content-length-optional-to-true-tf2268435.html#a6371530
Sent from the Apache Xml-RPC - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org


Re: Exception thrown when setting content length optional to true

Posted by Jimisola Laursen <li...@jimisola.com>.
I'll do so.

Just tried "mvn -U...", but none of the xmlrpc packages were
downloaded/updated.
Is there a delay before the packages are made available?

Looking directly at the repo the files are dated "18-Sep-2006 13:13".
Not sure which time zone the repo is in, but are these the correct files?

Regards,
Jimisola


Jochen Wiedmann wrote:
> 
> On 9/18/06, Jimisola Laursen <li...@jimisola.com> wrote:
> 
>> Sad to say that I have this problem with 3.1-SNAPSHOT as well.
>>
>> Can I provide more information is some way?
> 
> I have rebuilt the nightlies from the latest SVN tree. Please retry.
> If the problem actually persists, please file a Jira issue.
> 
> Jochen
> 
> -- 
> My wife Mary and I have been married for forty-seven years and not
> once have we had an argument serious enough to consider divorce;
> murder, yes, but divorce, never.
> (Jack Benny)
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Exception-thrown-when-setting-content-length-optional-to-true-tf2268435.html#a6371457
Sent from the Apache Xml-RPC - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org


Re: Exception thrown when setting content length optional to true

Posted by Jochen Wiedmann <jo...@gmail.com>.
On 9/18/06, Jimisola Laursen <li...@jimisola.com> wrote:

> Sad to say that I have this problem with 3.1-SNAPSHOT as well.
>
> Can I provide more information is some way?

I have rebuilt the nightlies from the latest SVN tree. Please retry.
If the problem actually persists, please file a Jira issue.

Jochen

-- 
My wife Mary and I have been married for forty-seven years and not
once have we had an argument serious enough to consider divorce;
murder, yes, but divorce, never.
(Jack Benny)

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org


Re: Exception thrown when setting content length optional to true

Posted by Jimisola Laursen <li...@jimisola.com>.
Jochen,

Sad to say that I have this problem with 3.1-SNAPSHOT as well.

Can I provide more information is some way?

Regards,
Jimisola


Jochen Wiedmann wrote:
> 
> Jimisola Laursen wrote:
> 
>> Do you have any input on this matter? Does it seem to be a
>> misconfiguration
>> or a bug?
> 
> This looks like one of the bugs, which have been detected and fixed in 
> SVN since the release of 3.0.
> 
> 
> Jochen
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Exception-thrown-when-setting-content-length-optional-to-true-tf2268435.html#a6370346
Sent from the Apache Xml-RPC - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org


Re: Exception thrown when setting content length optional to true

Posted by Jimisola Laursen <li...@jimisola.com>.
> No plans. Use one of the nightly builds, as available from
>
>     http://people.apache.org/repo/m2-snapshot-repository
>
> or
>
>     http://people.apache.org/dist/ws/xmlrpc/nightly/

Hmm, no plan at all. So, you don't know if it will be within the next few
months then either.
We are just about to have code freeze and it's hard to convince management
that a SNAPSHOT is better (and needed) that the 3.0 final :)

Jimisola
-- 
View this message in context: http://www.nabble.com/Exception-thrown-when-setting-content-length-optional-to-true-tf2268435.html#a6368118
Sent from the Apache Xml-RPC - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org


Re: Exception thrown when setting content length optional to true

Posted by Jochen Wiedmann <jo...@gmail.com>.
Jimisola Laursen wrote:

> Do you have an issue id?

No, it was detected by me while working on XMLRPC-113.

> When will there be a 3.0.1 release with fixes for this and other post 3.0?
> I really can't use the XML-RPC library now.

No plans. Use one of the nightly builds, as available from

     http://people.apache.org/repo/m2-snapshot-repository

or

     http://people.apache.org/dist/ws/xmlrpc/nightly/


Jochen

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org


Re: Exception thrown when setting content length optional to true

Posted by Jimisola Laursen <li...@jimisola.com>.
Just my regular luck... :(

Do you have an issue id?

When will there be a 3.0.1 release with fixes for this and other post 3.0?
I really can't use the XML-RPC library now.

Regards,
Jimisola


Jochen Wiedmann wrote:
> 
> Jimisola Laursen wrote:
> 
>> Do you have any input on this matter? Does it seem to be a
>> misconfiguration
>> or a bug?
> 
> This looks like one of the bugs, which have been detected and fixed in 
> SVN since the release of 3.0.
> 
> 
> Jochen
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Exception-thrown-when-setting-content-length-optional-to-true-tf2268435.html#a6362929
Sent from the Apache Xml-RPC - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org


Re: Exception thrown when setting content length optional to true

Posted by Jochen Wiedmann <jo...@gmail.com>.
Jimisola Laursen wrote:

> Do you have any input on this matter? Does it seem to be a misconfiguration
> or a bug?

This looks like one of the bugs, which have been detected and fixed in 
SVN since the release of 3.0.


Jochen

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org


Re: Exception thrown when setting content length optional to true

Posted by Jimisola Laursen <li...@jimisola.com>.
Joche,

Do you have any input on this matter? Does it seem to be a misconfiguration
or a bug?

Regards,
Jimisola


Jimisola Laursen wrote:
> 
> Hi!
> 
> I am trying to send a file over XMLRPC using an byte array (byte[]), but
> an exception is thrown when content length optional is set to true.
> At first I thought it had to do with the byte array, but I this exception
> with a simple ping/echo method as well.
> 
> I am using PropertyHandlerMapping on the server-side and a Proxy solution
> on the Agent side.
> I've used this same setup before, but I had to recreate the test from
> scratch so I am thinking that  I might have missed out on something.
> But since it works when content length optional is set to false I have my
> doubts.
> 
> Regards,
> Jimisola
> 
> These are the outputs that I get:
>  
> Client:
>  
>  [Fatal Error] :2:6: The processing instruction target matching
> "[xX][mM][lL]" is not allowed.
> Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
> 	at $Proxy0.echo(Unknown Source)
> 	at xmlrpctest.Client.main(Client.java:33)
> Caused by: org.apache.xmlrpc.client.XmlRpcClientException: Failed to parse
> servers response: The processing instruction target matching
> "[xX][mM][lL]" is not allowed.
> 	at
> org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:177)
> 	at
> org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:145)
> 	at
> org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:94)
> 	at
> org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:53)
> 	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:166)
> 	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:136)
> 	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:125)
> 	at
> org.apache.xmlrpc.client.util.ClientFactory$1.invoke(ClientFactory.java:104)
> 	... 2 more
> 	
> Server:
> lFatal Error] :1:1: Content is not allowed in prolog.
> 
> The code:
> 
> package xmlrpctest;
> 
> import java.io.IOException;
> import java.net.InetAddress;
> 
> import org.apache.xmlrpc.XmlRpcException;
> import org.apache.xmlrpc.server.PropertyHandlerMapping;
> import org.apache.xmlrpc.server.XmlRpcServer;
> import org.apache.xmlrpc.server.XmlRpcServerConfigImpl;
> import org.apache.xmlrpc.webserver.WebServer;
> 
> public class Server
> {
>     public static void main(String[] args) throws XmlRpcException,
> IOException
>     {
>         WebServer webServer = new WebServer(8080,
> InetAddress.getByName("localhost"));
>         
>         XmlRpcServer xmlRpcServer = webServer.getXmlRpcServer();
> 
>         // use reflection for (dynamic) mapping
>         PropertyHandlerMapping phm = new PropertyHandlerMapping();
> 
>         // add handler - using full name for use by dynamic proxy
>         phm.addHandler(TestRPC.class.getName(), TestRPCImpl.class);        
>         xmlRpcServer.setHandlerMapping(phm);
>         
>         XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl)
> xmlRpcServer.getConfig();
>         serverConfig.setEnabledForExtensions(true);
>         serverConfig.setContentLengthOptional(true);
> 
>         webServer.start();
>     }
> }
> 
> package xmlrpctest;
> 
> import java.io.FileInputStream;
> import java.net.URL;
> 
> import org.apache.xmlrpc.client.XmlRpcClient;
> import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
> import org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory;
> import org.apache.xmlrpc.client.util.ClientFactory;
> 
> public class Client
> {
>     public static void main(String[] args) throws Exception
>     {
>         URL url = new URL("http://localhost:8080/RPC2");
> 
>         XmlRpcClientConfigImpl clientConfig = new
> XmlRpcClientConfigImpl();
> 
>         clientConfig.setServerURL(url);
>         clientConfig.setEnabledForExtensions(true);
>         clientConfig.setContentLengthOptional(true);
>         XmlRpcClient client = new XmlRpcClient();
> 
>         // use Commons HttpClient as transport
>         client.setTransportFactory(new
> XmlRpcCommonsTransportFactory(client));
>         // set configuration
>         client.setConfig(clientConfig);
> 
>         // make a call using dynamic proxy
>         ClientFactory factory = new ClientFactory(client);
>         TestRPC testRPC = (TestRPC) factory.newInstance(TestRPC.class);
> 
>         System.out.println(testRPC.echo("ping"));
> 
>         /*
>         FileInputStream fis = new FileInputStream("/tmp/java.txt");
>         byte[] ba = new byte[fis.available()];
>         
>         fis.read(ba);
>         fis.close();
>         int length = testRPC.upload(ba);
>         
>         System.out.println(length);
>         */
>     }
> }
> 
> package xmlrpctest;
> 
> import org.apache.xmlrpc.XmlRpcException;
> 
> public interface TestRPC
> {
>     int upload(byte[] data) throws XmlRpcException, Exception;
> 
>     String echo(String s);
> 
> }
> 
> package xmlrpctest;
> 
> import java.io.FileOutputStream;
> 
> import org.apache.xmlrpc.XmlRpcException;
> 
> public class TestRPCImpl implements TestRPC
> {
> 
>     public int upload(byte[] data) throws XmlRpcException, Exception
>     {
>         FileOutputStream fos = new FileOutputStream("/tmp/java.txt.out");
>         fos.write(data);
>         fos.close();
>         
>         return data.length;
>     }
> 
>     public String echo(String s)
>     {
>         System.out.println("Returning: " + s);
>         return s;
>     }
> }
> 
> pom.xml:
> <?xml version="1.0" encoding="UTF-8"?><project>
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>test</groupId>
>   <artifactId>test</artifactId>
>   <version>0.0.1</version>
>   <description></description>
>   <dependencies>
>     <dependency>
>       <groupId>org.apache.xmlrpc</groupId>
>       <artifactId>xmlrpc-common</artifactId>
>       <version>3.0</version>
>     </dependency>
>     <dependency>
>       <groupId>org.apache.xmlrpc</groupId>
>       <artifactId>xmlrpc-client</artifactId>
>       <version>3.0</version>
>     </dependency>
>     <dependency>
>       <groupId>org.apache.xmlrpc</groupId>
>       <artifactId>xmlrpc-server</artifactId>
>       <version>3.0</version>
>     </dependency>
>             <dependency>
>                 <artifactId>commons-codec</artifactId>
>                 <groupId>commons-codec</groupId>
>                 <version>1.3</version>
>             </dependency>
> 
>             <dependency>
>                 <artifactId>commons-httpclient</artifactId>
>                 <groupId>commons-httpclient</groupId>
>                 <version>3.0.1</version>
>             </dependency>
> 
>             <dependency>
>                 <artifactId>commons-lang</artifactId>
>                 <groupId>commons-lang</groupId>
>                 <version>2.1</version>
>             </dependency>
>   </dependencies>
> </project>
> 

-- 
View this message in context: http://www.nabble.com/Exception-thrown-when-setting-content-length-optional-to-true-tf2268435.html#a6362347
Sent from the Apache Xml-RPC - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org