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 Roald Hoolwerf <ro...@hoolwerf.net> on 2009/06/25 17:39:30 UTC

XML RPC client seems to be sending GET request instead of POST

Good day,

I’m writing a servlet handling XML RPC using the ws-apache XML RPC server
and client. I’ve managed to get the server working in Apache Tomcat
5.5.27, at least the servlet gets initialized and Tomcat seems to respond
to incoming calls.

To clarify myself:
I’ve extended the XmlRpcServlet with my own Servlet class:

public class RemazServlet extends XmlRpcServlet {

	public void init(ServletConfig arg0) throws ServletException {
		super.init(arg0);
		System.out.println("----RemazServlet initialized");
	}

	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
		System.out.println("----doGet()”);
		super.doGet(req, resp);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse
response) throws IOException, ServletException {
		System.out.println("----doPost()”);
		super.doPost(request, response);
	}
}

My web.xml is as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>
	<servlet>
        <servlet-name>remazrpc</servlet-name>
        <servlet-class>nl.remaz.xmlrpc.webserver.RemazServlet</servlet-class>
        <load-on-startup>1</load-on-startup>

        <init-param>
          <param-name>enabledForExtensions</param-name>
          <param-value>true</param-value>
		</init-param>
        <init-param>
          <param-name>enabledForExtensions</param-name>
          <param-value>false</param-value>
		</init-param>
        <init-param>
          <param-name>contentLengthOptional</param-name>
          <param-value>false</param-value>
		</init-param>
	</servlet>

    <servlet-mapping>
        <servlet-name>remazrpc</servlet-name>
        <url-pattern>/remazrpc</url-pattern>
    </servlet-mapping>

</web-app>

When I start Tomcat, I see the line "----RemazServlet initialized"
appearing, which means my servlet is initialized (right?)
When I use my XmlRpcClient to connect to http://localhost:8080/remazrpc I
see the line "----doGet()” appearing. In return, I got a 405:
org.apache.xmlrpc.client.XmlRpcHttpTransportException: HTTP server
returned unexpected status: Method Not Allowed

That was to be expected, considering that XML RPC is POST so I expect that
performing a GET request returns an error.

But that is exactly my problem: Why is my client sending a GET request
instead of a POST request? I’ve tried “redirecting” the request to
super.doPost(), but that gave the following error:
org.apache.xmlrpc.XmlRpcException: Failed to parse XML-RPC request:
Premature end of file.

I’ve tried looking up the Content-length of the request, but for both
doGet() and doPost() those are -1. They shouldn’t be -1 as far as I know?

Can anyone give me some pointers as to why my client is sending a GET
request? Or otherwise: why my server is interpreting a request as GET
instead of POST?

Kind regards,
Roald Hoolwerf



Re: XML RPC client seems to be sending GET request instead of POST

Posted by Don Albertson <dg...@psu.edu>.
When faced with similar problems, I find it useful to intercept the 
request at the client side and verify that it really is doing what I 
think it is doing.
WebScarab is usually all I need.
dga

Roald Hoolwerf wrote:
> Hello Joched,
>
> Thank you replying, though unfortunately it doesn't help me much. My
> client is just an implementation of the ws-apache XmlRpcClient, there
> isn't much that I have done other than to tell my XmlRpcServlet to execute
> a command.
>
> I'm going to rewrite the client, but any suggestions is welcome.
>
>
> On Fri, June 26, 2009 08:05, Jochen Wiedmann wrote:
>   
>> On Thu, Jun 25, 2009 at 5:39 PM, Roald Hoolwerf<ro...@hoolwerf.net>
>> wrote:
>>
>>
>>     
>>> But that is exactly my problem: Why is my client sending a GET request
>>> instead of a POST request?
>>>       
>> No idea. That is definitely a nonsense and be it just for the length
>> restrictions of GET.
>>
>>     
>>> I’ve tried “redirecting” the request to
>>> super.doPost(), but that gave the following error:
>>> org.apache.xmlrpc.XmlRpcException: Failed to parse XML-RPC request:
>>> Premature end of file.
>>>
>>>       
>> Makes no sense.
>>
>>
>> A POST request allows to process an unnamed object: The request body.
>> In a GET request, we could at best select a particular parameter to
>> parse it.
>>
>> In other words, you need to have the client fixed.
>>
>>
>>
>>     
>>> I’ve tried looking up the Content-length of the request, but for both
>>>  doGet() and doPost() those are -1. They shouldn’t be -1 as far as I
>>> know?
>>>       
>> For GET the -1 is perfectly fine: There is no request body, hence no
>> content.
>>
>>
>> Jochen
>>
>>
>>
>> --
>> Don't trust a government that doesn't trust you.
>>
>>
>>
>>     
>
>
> Met vriendelijke groet,
> Roald Hoolwerf
>
>
>
>   


-- 
Science is not a monument of received Truth.
It is something that people do to look for truth.


Re: XML RPC client seems to be sending GET request instead of POST

Posted by Roald Hoolwerf <ro...@hoolwerf.net>.
Hello Joched,

Thank you replying, though unfortunately it doesn't help me much. My
client is just an implementation of the ws-apache XmlRpcClient, there
isn't much that I have done other than to tell my XmlRpcServlet to execute
a command.

I'm going to rewrite the client, but any suggestions is welcome.


On Fri, June 26, 2009 08:05, Jochen Wiedmann wrote:
> On Thu, Jun 25, 2009 at 5:39 PM, Roald Hoolwerf<ro...@hoolwerf.net>
> wrote:
>
>
>> But that is exactly my problem: Why is my client sending a GET request
>> instead of a POST request?
>
> No idea. That is definitely a nonsense and be it just for the length
> restrictions of GET.
>
>> I’ve tried “redirecting” the request to
>> super.doPost(), but that gave the following error:
>> org.apache.xmlrpc.XmlRpcException: Failed to parse XML-RPC request:
>> Premature end of file.
>>
>
> Makes no sense.
>
>
> A POST request allows to process an unnamed object: The request body.
> In a GET request, we could at best select a particular parameter to
> parse it.
>
> In other words, you need to have the client fixed.
>
>
>
>> I’ve tried looking up the Content-length of the request, but for both
>>  doGet() and doPost() those are -1. They shouldn’t be -1 as far as I
>> know?
>
> For GET the -1 is perfectly fine: There is no request body, hence no
> content.
>
>
> Jochen
>
>
>
> --
> Don't trust a government that doesn't trust you.
>
>
>


Met vriendelijke groet,
Roald Hoolwerf


Re: XML RPC client seems to be sending GET request instead of POST

Posted by Jochen Wiedmann <jo...@gmail.com>.
On Thu, Jun 25, 2009 at 5:39 PM, Roald Hoolwerf<ro...@hoolwerf.net> wrote:

> But that is exactly my problem: Why is my client sending a GET request
> instead of a POST request?

No idea. That is definitely a nonsense and be it just for the length
restrictions of GET.

> I’ve tried “redirecting” the request to
> super.doPost(), but that gave the following error:
> org.apache.xmlrpc.XmlRpcException: Failed to parse XML-RPC request:
> Premature end of file.

Makes no sense.

A POST request allows to process an unnamed object: The request body.
In a GET request, we could at best select a particular parameter to
parse it.

In other words, you need to have the client fixed.


> I’ve tried looking up the Content-length of the request, but for both
> doGet() and doPost() those are -1. They shouldn’t be -1 as far as I know?

For GET the -1 is perfectly fine: There is no request body, hence no content.


Jochen


-- 
Don't trust a government that doesn't trust you.