ws-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adisa Dosunmu <adisc...@gmail.com>
Subject Basic Authentication with xmlrpc-3.1.2
Date Sun, 04 Nov 2012 10:03:48 GMT
Greetings. I've spent days trying to get basic authentication (username &
password) to work with xmlrpc-3.1.2. Up till now no result. I had an
application develop in C# which works well with the username & password but
i wanted to develop the application in java. This has been very
frustrating. I've scanned the Internet, Google, and this website, but I
can't find any successful examples of Basic Authentication being used with
xmlrpc.
Any help that you could give me would be greatly appreciated.

Here is my test program:



package awoko;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
/**
 *
 * @author Administrator
 */
public class client4 {
public static void call(String url, String user, String pass) throws Exception {
        XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
        config.setServerURL(new URL(url));
        config.setBasicEncoding(XmlRpcClientConfigImpl.UTF8_ENCODING);
        config.setBasicUserName(user);
        config.setBasicPassword(pass);

        config.setEnabledForExceptions(true);
        config.setEnabledForExtensions(true);


        XmlRpcClient client = new XmlRpcClient();
        client.setConfig(config);

        Map m = new HashMap();
        m.put("originNodeType", "EXT");
        m.put("subscriberNumber", "76639511");
        m.put("originTransactionID", "41");
        m.put("originHostName", "awoko");



        Object result = client.execute("GetBalanceAndDate", new Object [] {m});
        System.out.println("Returned: " + result);
    }

    public static void main(String[] args) throws Exception {
        String url = "http://192.168.48.42:10010/Air";
        String user = "test";
        String pass = "test";

        if(1 <= args.length) {
                url = args[0];
        }
        if(2 <= args.length) {
                user = args[1];
        }
        if(3 <= args.length) {
                pass = args[2];
        }

        client4.call(url, user, pass);
        System.out.println("Finished.");
    }
}



And here are the stack trace:

run:
Exception in thread "main" org.apache.xmlrpc.XmlRpcException: Failed
to create input stream: Connection reset
        at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.getInputStream(XmlRpcSunHttpTransport.java:60)
        at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:145)
        at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:95)
        at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:39)
        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 awoko.client3.main(client3.java:42)
Caused by: java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:168)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
        at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
        at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
        at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:652)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1064)
        at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.getInputStream(XmlRpcSunHttpTransport.java:58)
        ... 8 more
Caused by:
java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:168)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
        at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
        at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
        at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:652)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1064)
        at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.getInputStream(XmlRpcSunHttpTransport.java:58)
        at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:145)
        at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:95)
        at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:39)
        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 awoko.client3.main(client3.java:42)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

Mime
View raw message