Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6974885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:17:44+00:00 2026-05-27T17:17:44+00:00

Im trying to consume Wcf from Android , my code private final static String

  • 0

Im trying to consume Wcf from Android , my code

private final static String SERVICE_URI = "http://188.59.2.211:8081/Survey.svc";

String email = "xx@gmail.com";
String password = "123";

public void onResume() {
        super.onResume();

        Login(email,password);
    }

private void Login(String email, String password)
    {
        try {

        URL url = new URL(SERVICE_URI + "/Login/email="+email+"&password="+password);
            HttpGet request = new HttpGet(url.toURI());
            request.setHeader("Accept", "application/json");
            request.setHeader("Content-type", "application/json");

            HttpClient httpClient = new DefaultHttpClient();
            HttpResponse response = (HttpResponse) httpClient.execute(request);
            if ( response != null )
            {
              Log.i( "login", "received " + response.toString());
            }
            else
            {
              Log.i( "login", "got a null response" );
            }

            HttpEntity responseEntity = response.getEntity();

            // Read response data into buffer
            char[] buffer = new char[(int)responseEntity.getContentLength()];
            InputStream stream = responseEntity.getContent();
            InputStreamReader reader = new InputStreamReader(stream);
            reader.read(buffer);
            stream.close();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

and the wcf service side,

[ServiceContract(Namespace = "http://saas.com")]
public interface ISurvey
{
    [OperationContract]
    [WebGet(
       UriTemplate = "/Login/email={email}&password={password}",
       BodyStyle = WebMessageBodyStyle.WrappedRequest,
       ResponseFormat = WebMessageFormat.Json,
       RequestFormat = WebMessageFormat.Json)]
    LoginResult Login(string email, string password);
}

and my config,

<system.serviceModel>
<behaviors>
  <endpointBehaviors>
    <behavior name="httpBehavior">
      <webHttp />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
  <service name="SAASService.Survey">
    <endpoint address=""
              behaviorConfiguration="httpBehavior"
              binding="webHttpBinding"
              contract="SAASService.ISurvey" />
    <endpoint address="mex"
              binding="mexHttpBinding"
              contract="IMetadataExchange" />
  </service>
</services>

The problem is that, Im using the below url,

“http://188.59.2.211:8081/Survey.svc/Login/email=xx@gmail.com&password=123&#8221;

and it is always giving “Bad Request” error , statusCode = 400

What is wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:17:45+00:00Added an answer on May 27, 2026 at 5:17 pm

    Calling a web service like that from Android won’t work. Also, SOAP is xml, not json, so your content type is wrong.

    To consume web services in Android, it’s best to use the ksoap-android library.
    You can check this tutorial for sample code.

    Here is a sample code that I used in one of my recent projects.

    private static final String NAMESPACE = "http://webService.protocols.users.mydomain.com/";
    private static final String URL = "http://1.1.1.1/domain/ws/userServices?wsdl";
    private static final String SOAP_ACTION = "";
    
    public boolean authenticate(String username, String password) {
        String METHOD_NAME = "authenticate";
    
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("arg0", username);
        request.addProperty("arg1", password);
    
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(request);
    
        HttpTransportSE httpTransport = new HttpTransportSE(URL);
        httpTransport.debug = true;
        try {
            httpTransport.call(SOAP_ACTION, envelope);
        } catch (Exception e) {
            return false;
        }
    
        SoapObject result = null;
        try {
            result = (SoapObject) envelope.getResponse();
        } catch (SoapFault soapFault) {
            return false;
        }
    
        // anything below this line relates to the service return type, may not apply to you
        boolean success = Boolean.valueOf(result.getProperty("success").toString());
        if (success)
            sessionId.set(result.getProperty("sessionId").toString());
        else
            error_message.set(result.getProperty("errorMessage").toString());
    
        return success;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’m having some difficulties while trying to consume an unmanaged-code dll from my application
I am trying to consume an ASMX web service from my WCF service. Here
I am trying to consume a wcf rest service via reflection if possible. Take
I am new to both WSE and WCF and I am trying to consume
I am trying to consume data from a webservice published by a 3rd party.
I'm trying to consume an ASP.NET Webservice from a Java application. The java app
I am trying to figure out a way to consume a WCF service I
I'm trying to use WCF to consume a web service provided by a third-party's
I am trying to get serialized results from a WCF service from database using
I am trying to consume a WCF service in a class library by adding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.