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 Stanislav Miklik <st...@gmail.com> on 2009/07/12 18:45:48 UTC
Re: XmlRpcHttpTransportException (apache xmlrpc client, xmlrpc-c C++
server)
Hi,
I am not sure, but to me it looks like the problem on HTTP level (guess
404). Also I would try to capture the good case (with C++ client) and the
bad case (Java) with Wireshark / snoop and compare the HTTP request.
However it looks strange, but I would guess some different interpretation of
"sample.add"
Regards
Stano
On Sun, Jul 12, 2009 at 18:31, Lars Schnoor <La...@ifad.dk> wrote:
> Hi
> I am not sure if I can come with any useful for you, but I would try
> changing the argument to you function call from Vector to Object[]. My
> server runs Apaches XML-RPC and I have managed to use it with both xml-rpc
> for c and for c++.
>
> Lars
>
>
> Arne Kalaghan wrote:
>
>> Hello,
>> I have problems connecting an apache java xml-rpc client with a xmlrpc-c
>> C++ xml-rpc server (system is ubuntu linux 8.04).
>>
>> The client code is modified from the first example at
>> http://www.wordtracker.com/docs/api/ch03s02.html.
>>
>> The server code is
>> http://xmlrpc-c.svn.sourceforge.net/viewvc/xmlrpc-c/trunk/examples/cpp/xmlrpc_sample_add_server.cpp?revision=1083&view=markup
>>
>> When running the client (after server is started) I get:
>> Exception
>> in thread "main" org.apache.xmlrpc.client.XmlRpcHttpTransportException:
>> HTTP server returned unexpected status: Not Found
>> at
>> org.apache.xmlrpc.client.XmlRpcSunHttpTransport.getInputStream(XmlRpcSunHttpTransport.java:94)
>> at
>> org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:152)
>> at
>> org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:115)
>> at
>> org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
>> at
>> org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
>> at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
>> at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:158)
>> at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:147)
>> at test.apachexmlrpc.Client.main(Client.java:9)
>>
>> The
>> java client can communicate with a server from the same apache package,
>> and the C++ server can communicate with a C++ client from the same
>> xmlrpc-c package. What can be the reason for the incompatibilities
>> between java and C++?
>>
>> Here are the sources for completeness:
>>
>> Java client Client.java:
>> ================
>>
>> import org.apache.xmlrpc.XmlRpcClient;
>> import java.util.Vector;
>> public class Client {
>> public static void main( String args[] ) throws Exception {
>> XmlRpcClient client = new XmlRpcClient( "http://localhost:8080/"
>> );
>> Vector params = new Vector();
>> params.addElement( 5 );
>> params.addElement( 7 );
>> Object result = client.execute( "sample.add", params );
>> if ( result != null )
>> System.out.println( "Successfully pinged guest account." );
>> }
>> }
>>
>> C++ server xmlrpc_sample_add_server.cpp:
>> ================================
>> #include <cassert>
>> #include <stdexcept>
>> #include <iostream>
>> #ifdef WIN32
>> # include <windows.h>
>> #else
>> # include <unistd.h>
>> #endif
>>
>> #include <xmlrpc-c/base.hpp>
>> #include <xmlrpc-c/registry.hpp>
>> #include <xmlrpc-c/server_abyss.hpp>
>>
>> using namespace std;
>>
>> #ifdef WIN32
>> #define SLEEP(seconds) SleepEx(seconds * 1000);
>> #else
>> #define SLEEP(seconds) sleep(seconds);
>> #endif
>>
>>
>> class sampleAddMethod : public xmlrpc_c::method {
>> public:
>> sampleAddMethod() {
>> // signature and help strings are documentation -- the client
>> // can query this information with a system.methodSignature and
>> // system.methodHelp RPC.
>> this->_signature = "i:ii";
>> // method's result and two arguments are integers
>> this->_help = "This method adds two integers together";
>> }
>> void
>> execute(xmlrpc_c::paramList const& paramList,
>> xmlrpc_c::value * const retvalP) {
>>
>> int const addend(paramList.getInt(0));
>> int const adder(paramList.getInt(1));
>>
>> paramList.verifyEnd(2);
>>
>> *retvalP = xmlrpc_c::value_int(addend + adder);
>>
>> // Sometimes, make it look hard (so client can see what it's like
>> // to do an RPC that takes a while).
>> if (adder == 1)
>> SLEEP(2);
>> }
>> };
>>
>>
>>
>> int main(int const, const char ** const) {
>>
>> try {
>> xmlrpc_c::registry myRegistry;
>>
>> xmlrpc_c::methodPtr const sampleAddMethodP(new sampleAddMethod);
>>
>> myRegistry.addMethod("sample.add", sampleAddMethodP);
>>
>> xmlrpc_c::serverAbyss myAbyssServer(
>> myRegistry,
>> 8080, // TCP port on which to listen
>> "/tmp/xmlrpc_log" // Log file
>> );
>>
>> myAbyssServer.run();
>> // xmlrpc_c::serverAbyss.run() never returns
>> assert(false);
>> } catch (exception const& e) {
>> cerr << "Something failed. " << e.what() << endl;
>> }
>> return 0;
>> }
>>
>> Kind regards,
>> A. Kalaghan
>>
>>
>>
>>
>