1. Introducing Channels - a new way to chat with other Android users!
    Dismiss Notice

Service unavailable exception when calling a webservice


Last Updated:

  1. nlokesh

    nlokesh New Member This Topic's Starter

    Joined:
    Jul 29, 2010
    Messages:
    1
    Likes Received:
    0
    Hi,
    I am trying to connect to a webservice from android application and it gives me service unavailable exception.

    The same code works when called in a standalone java program but when called inside an android application, it fails!.

    Code:

    Properties sysProperties = System.getProperties();
    sysProperties.put("proxyHost", "proxy.blrl.sap.corp");
    sysProperties.put("proxyPort", "8080");
    sysProperties.put("proxySet", "true");


    String message = "<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
    "<soap:Envelope " +
    "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
    "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "+
    "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
    "<soap:Body>"+
    "<n0:ZtestGetOverviewForMonObj xmlns:n0=\"urn:sap-com:document:sap:soap:functions:mc-style\"> " +
    "<ItMonObjId> </ItMonObjId> <ItMonObjName> <item><ContextName>A4Y</ContextName> </item> </ItMonObjName></n0:ZtestGetOverviewForMonObj>" +
    "</soap:Body>" +
    "</soap:Envelope>";

    String HostUrl = "10.66.51.53";

    String SoapActionUrl = "urn:sap-com:document:sap:soap:functions:mc-style/ZtestGetOverviewForMonObj";


    String wsURL="/zser_get_overview_for_mon_obj/200/zser_get_overview_for_mon_obj/zbn_get_overview_for_mon_obj";
    wsURL = "http://10.66.51.53:50089/sap/bc/srt/rfc/sap"+URLEncoder.encode(wsURL,"UTF-8");
    Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxy.blrl.sap.corp", 8080));
    URL url = new URL(wsURL);


    URLConnection urlconnection = url.openConnection(proxy);
    HttpURLConnection httpurlconnection = (HttpURLConnection)urlconnection;

    byte abyte0[] = message.getBytes();
    httpurlconnection.addRequestProperty("Host", HostUrl);
    httpurlconnection.addRequestProperty("Content-Length", String.valueOf(abyte0.length));
    httpurlconnection.addRequestProperty("Content-Type", "text/xml; charset=UTF-8");
    httpurlconnection.addRequestProperty("SOAPAction", SoapActionUrl);
    httpurlconnection.setRequestProperty("Connection", "close");
    httpurlconnection.setInstanceFollowRedirects(true);
    httpurlconnection.setRequestMethod("POST");

    httpurlconnection.setUseCaches(false);
    httpurlconnection.setAllowUserInteraction(true);

    httpurlconnection.setDoOutput(true);
    httpurlconnection.setDoInput(true);

    httpurlconnection.connect();


    When I tried, httpurlconnection.getResponseCode(), it returns 503 code.

    Do I have to set any additional configuration in the android for this to work?

    Can anyone help me here?

    Thanks & Regards,
    Lokesh
     

    Advertisement

Share This Page

Loading...