[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlrpc-user
Subject:    DefaultHandlerMapping in XmlRpcServlet
From:       Yves_Gänssinger <Yves.Ganssinger () hiq ! se>
Date:       2013-12-12 15:25:58
Message-ID: 207DABF6D37D4D49A4CDB3112BEAE5CF19282D58 () HIQQBEXC101 ! sto ! hiq ! se
[Download RAW message or body]

Hello!

We need a servlet which handles XML-RPC requests from a third party. The third-party \
XMLRPC-API had already existed before, meaning the format of these incoming requests \
is fixed and we must adapt to them.

Unfortunately, these requests only contain a methodName and no handler name. Analogue \
to the calculator-example, the requests would only contain "add" as method name, and \
no "Calculator.add". To be more precise:

This is what I could handle without problems right now:
<?xml version="1.0"?><methodCall><methodName>Calculator.Add</methodName><params></params></methodCall>


This is what I have to live with, though:
<?xml version="1.0"?><methodCall><methodName>Add</methodName><params></params></methodCall>


How can I adapt the XmlRpcServlet so that it "forwards" these requests to the right \
handler class ("Calculator")?

I already tried to add a handler with a empty "pKey"
(
PropertyHandlerMapping phm = new PropertyHandlerMapping();
phm.addHandler("", ex.ample.com.Calculator);
).
That just lead to another error ("org.apache.xmlrpc.XmlRpcException: No such handler: \
Add") when I tried to send a request to the XmlRpcServlet.

I also read that in XML-RPC 2 it was possible to use a DefaultHandlerMapping. Though, \
it seems this DefaultHandlerMapping has not been included in the latest release, \
which I would like to use. Besides, neither the provided information on the XMLRPC2- \
site nor other sources could really help me to produce some working solution - not \
even with XML-RPC 2.

I'd be glad to get some example code in the answer.

Kind regards,
Yves Gänßinger


[Attachment #3 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"> <head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Consolas;
	panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
pre
	{mso-style-priority:99;
	mso-style-link:"HTML - förformaterad Char";
	margin:0cm;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:"Courier New";}
span.E-postmall17
	{mso-style-type:personal-compose;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
span.HTML-frformateradChar
	{mso-style-name:"HTML - förformaterad Char";
	mso-style-priority:99;
	mso-style-link:"HTML - förformaterad";
	font-family:"Courier New";}
.MsoChpDefault
	{mso-style-type:export-only;}
@page Section1
	{size:612.0pt 792.0pt;
	margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.Section1
	{page:Section1;}
-->
</style><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>
<body lang="SV" link="blue" vlink="purple">
<div class="Section1">
<p class="MsoNormal">Hello! <o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><span lang="EN-US">We need a servlet which handles XML-RPC \
requests from a third party. The third-party XMLRPC-API had already existed before, \
meaning the format of these incoming requests is fixed and we must adapt to them. \
<o:p></o:p></span></p> <p class="MsoNormal"><span \
lang="EN-US"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal"><span \
lang="EN-US">Unfortunately, these requests only contain a methodName and no handler \
name. Analogue to the calculator-example, the requests would only contain \
&#8220;add&#8221; as method name, and no &#8220;Calculator.add&#8221;. To be more \
precise: <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">This is what I could handle without problems \
right now:<o:p></o:p></span></p> <p class="MsoNormal"><span lang="EN-US" \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">&lt;?xml \
version=&quot;1.0&quot;?&gt;&lt;methodCall&gt;&lt;methodName&gt;Calculator.Add&lt;/met \
hodName&gt;&lt;params&gt;&lt;/params&gt;&lt;/methodCall&gt;<o:p></o:p></span></p> <p \
class="MsoNormal"><span lang="EN-US"><o:p>&nbsp;</o:p></span></p> <p \
class="MsoNormal"><span lang="EN-US">This is what I have to live with, though: \
<o:p></o:p></span></p> <p class="MsoNormal"><span lang="EN-US" \
style="font-size:10.0pt;font-family:&quot;Courier New&quot;">&lt;?xml \
version=&quot;1.0&quot;?&gt;&lt;methodCall&gt;&lt;methodName&gt;Add&lt;/methodName&gt;&lt;params&gt;&lt;/params&gt;&lt;/methodCall&gt;<o:p></o:p></span></p>
 <p class="MsoNormal"><span lang="EN-US"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">How can I adapt the XmlRpcServlet so that it \
&#8220;forwards&#8221; these requests to the right handler class \
(&#8220;Calculator&#8221;)? <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I already tried to add a handler with a empty \
&#8220;pKey&#8221; <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas;
color:black">(<o:p></o:p></span></p>
<p class="MsoNormal"><u><span lang="EN-US" style="font-size:10.0pt;font-family:
Consolas;color:black">PropertyHandlerMapping</span></u><span lang="EN-US" \
style="font-size:10.0pt;font-family:Consolas;color:black"> phm = </span><b><span \
lang="EN-US" style="font-size:10.0pt;font-family:Consolas;color:#7F0055">new</span></b><span \
lang="EN-US" style="font-size:10.0pt;font-family:Consolas;color:black"> \
PropertyHandlerMapping(); <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas;
color:black">phm.addHandler(</span><span lang="EN-US" style="font-size:10.0pt;
font-family:Consolas;color:#2A00FF">&quot;&quot;</span><span lang="EN-US" \
style="font-size:10.0pt;font-family:Consolas;color:black">,  \
ex.ample.com.Calculator); <o:p></o:p></span></p> <p class="MsoNormal"><span \
lang="EN-US" style="font-size:10.0pt;font-family:Consolas; color:black">).
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:Consolas;
color:black">T</span><span lang="EN-US">hat just lead to another error \
(&#8220;</span><u><span lang="EN-US" \
style="font-size:10.0pt;font-family:Consolas;color:#0066CC">org.apache.xmlrpc.XmlRpcException</span></u><span \
lang="EN-US" style="font-size:10.0pt;font-family:Consolas;color:red">:  No such \
handler: Add&#8221;) </span><span lang="EN-US">when I tried to send a request to the \
XmlRpcServlet.</span><span lang="EN-US" style="font-size:10.0pt;font-family: \
Consolas;color:red"> </span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I also read that in XML-RPC 2 it was possible \
to use a DefaultHandlerMapping. Though, it seems this DefaultHandlerMapping has not \
been included in the latest release, which I would like to use. Besides, neither the \
provided  information on the XMLRPC2- site nor other sources could really help me to \
produce some working solution &#8211; not even with XML-RPC 2. <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I&#8217;d be glad to get some example code in \
the answer.<o:p></o:p></span></p> <p class="MsoNormal"><span \
lang="EN-US"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal"><span \
lang="EN-US">Kind regards, <o:p></o:p></span></p> <p class="MsoNormal"><span \
lang="EN-US">Yves Gänßinger<o:p></o:p></span></p> <p class="MsoNormal"><span \
lang="EN-US"><o:p>&nbsp;</o:p></span></p> </div>
</body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic