Click here to Skip to main content
15,886,026 members
Home / Discussions / Android
   

Android

 
QuestionLive GPS Tracking Pin
Jay28517-Feb-16 3:09
Jay28517-Feb-16 3:09 
AnswerRe: Live GPS Tracking Pin
Richard MacCutchan17-Feb-16 4:29
mveRichard MacCutchan17-Feb-16 4:29 
AnswerRe: Live GPS Tracking Pin
David Crow17-Feb-16 7:12
David Crow17-Feb-16 7:12 
QuestionUnable to use Listadapter along with getfilter() for dynamic search filter? Pin
A KA15-Feb-16 5:48
A KA15-Feb-16 5:48 
SuggestionRe: Unable to use Listadapter along with getfilter() for dynamic search filter? Pin
David Crow15-Feb-16 9:12
David Crow15-Feb-16 9:12 
QuestionNative vs Hybrid App Development Pin
Member 1232849715-Feb-16 3:13
Member 1232849715-Feb-16 3:13 
QuestionAndroid: cannot open drawer inside onReceivedError Pin
Bazzer13-Feb-16 11:09
Bazzer13-Feb-16 11:09 
QuestionConsuming WCF web service from android Pin
Member 1232072611-Feb-16 0:26
Member 1232072611-Feb-16 0:26 
Hi everybody,

I'm trying to get my android app to communicate with the standard ASP.net System.Web.ApplicationServices.AuthenticationService Web Service. For debugging purposes, I'm hosting the service locally and starting it from VS 2013. When I use the WCF Test Client, everything works like a charm, yet when trying to connect from the android emulator, I'm getting a code 400: Bad Request - Invalid Hostname. Since the WCF Test Cline can reach the service an I'm aware that I need to use 10.0.2.2:50816 instead of localhost:50816, I'm totally clueless as to why the host is invalid.

Here's the relevant lines from my web.config:

HTML
<system.web.extensions>
    <scripting>
      <webServices>
        <authenticationService enabled="true" requireSSL="false" />
      </webServices>
    </scripting>
  </system.web.extensions>


HTML
<system.serviceModel>
    <services>
      <service behaviorConfiguration="AuthenticationServiceBehaviors" name="System.Web.ApplicationServices.AuthenticationService">
        <endpoint address="" contract= "System.Web.ApplicationServices.AuthenticationService"
        binding="basicHttpBinding"
        bindingConfiguration = "userHttps"
        bindingNamespace="http://asp.net/ApplicationServices/v200"/>
      </service>
      <service behaviorConfiguration="ShinergyAdmin.services.MobileServiceBehavior" name="ShinergyAdmin.services.MobileService">
        <endpoint address="" binding="basicHttpBinding" contract="ShinergyAdmin.services.IMobileService">
          <identity>
            <dns value="host" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
     <bindings>
        <basicHttpBinding>
            <binding name="userHttps">
                <security mode="None" />
            </binding>
        </basicHttpBinding>
  </bindings>


This is my client-side invokation:

Java
private static final String NAMESPACE = "http://asp.net/ApplicationServices/v200/";
    private static String URL="http://10.0.2.2:50816/services/AuthService.svc?wsdl";
    private static final String METHOD_NAME = "Login";
    private static final String SOAP_ACTION = "\"http://asp.net/ApplicationServices/v200/AuthService.svc/Login\"";

    public String ValidateUser(String username, String password){

        SoapSerializationEnvelope envelope = null;
        SoapObject request = null;
        HttpTransportSE httpTransportSE = null;

        try {
            request = new SoapObject(NAMESPACE, METHOD_NAME);
            request.addProperty("username", username);
            request.addProperty("password", password);

            envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
            envelope.dotNet = true;
            envelope.setOutputSoapObject(request);

            httpTransportSE = new HttpTransportSE(URL, 27000); // second parameter is timeout
            httpTransportSE.debug = true;
            httpTransportSE.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            httpTransportSE.call(SOAP_ACTION, envelope);

            // if response is a simple text result, you can call SoapPrimitive, if not, you have to call SoapObject result and navigate in response's tree like an xml file
            SoapPrimitive result = (SoapPrimitive)envelope.getResponse();

            //To get the data.
            String textResult = result.toString();
            Log.i("textResult", textResult);

            return textResult;

        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }finally{
            // here you can see in LOG what is request you send and what is response received
            Log.i(getClass().getSimpleName(),"requestDump : "+httpTransportSE.requestDump);
            Log.i(getClass().getSimpleName(),"responseDump : "+httpTransportSE.responseDump);
        }

        return "Failure to Login";
    }


This is what I send (i.e., my request dump):
XML
<?xml version="1.0" encoding="utf-8"?><v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://www.w3.org/2003/05/soap-encoding" xmlns:v="http://www.w3.org/2003/05/soap-envelope"><v:Header /><v:Body><Login xmlns="http://asp.net/ApplicationServices/v200/" id="o0" c:root="1"><username i:type="d:string">Username</username><password i:type="d:string">Password</password></Login></v:Body></v:Envelope>

and finally, this is the response dump:
XML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid Hostname</h2>
<hr><p>HTTP Error 400. The request hostname is invalid.</p>
</BODY></HTML>


I absolutely can't find out where that error is. Frustration levels are constantly rising here, so any help is highly appreciated!
QuestionPopulate Spinner from Sqlite and display the associated record of selected or populated item Pin
Varma Lanke8-Feb-16 19:46
Varma Lanke8-Feb-16 19:46 
AnswerRe: Populate Spinner from Sqlite and display the associated record of selected or populated item Pin
Richard MacCutchan8-Feb-16 21:53
mveRichard MacCutchan8-Feb-16 21:53 
SuggestionRe: Populate Spinner from Sqlite and display the associated record of selected or populated item Pin
David Crow9-Feb-16 2:14
David Crow9-Feb-16 2:14 
QuestionTutorialObjectTracking-master Pin
Member 122599845-Feb-16 2:25
Member 122599845-Feb-16 2:25 
AnswerRe: TutorialObjectTracking-master Pin
David Crow5-Feb-16 2:32
David Crow5-Feb-16 2:32 
GeneralRe: TutorialObjectTracking-master Pin
Member 122599845-Feb-16 2:47
Member 122599845-Feb-16 2:47 
GeneralRe: TutorialObjectTracking-master Pin
Richard MacCutchan5-Feb-16 6:25
mveRichard MacCutchan5-Feb-16 6:25 
GeneralRe: TutorialObjectTracking-master Pin
Member 122599846-Feb-16 4:10
Member 122599846-Feb-16 4:10 
GeneralRe: TutorialObjectTracking-master Pin
Richard MacCutchan6-Feb-16 4:12
mveRichard MacCutchan6-Feb-16 4:12 
GeneralRe: TutorialObjectTracking-master Pin
Member 122599846-Feb-16 4:30
Member 122599846-Feb-16 4:30 
GeneralRe: TutorialObjectTracking-master Pin
Richard MacCutchan6-Feb-16 5:23
mveRichard MacCutchan6-Feb-16 5:23 
GeneralRe: TutorialObjectTracking-master Pin
David Crow7-Feb-16 9:03
David Crow7-Feb-16 9:03 
GeneralRe: TutorialObjectTracking-master Pin
Member 1225998410-Feb-16 6:54
Member 1225998410-Feb-16 6:54 
SuggestionRe: TutorialObjectTracking-master Pin
David Crow10-Feb-16 6:58
David Crow10-Feb-16 6:58 
QuestionInsert Images in EditText as in Notes app in Android Mobiles Pin
Tirumaleswara Reddy.K4-Feb-16 2:16
Tirumaleswara Reddy.K4-Feb-16 2:16 
QuestionRe: Insert Images in EditText as in Notes app in Android Mobiles Pin
David Crow4-Feb-16 6:21
David Crow4-Feb-16 6:21 
AnswerRe: Insert Images in EditText as in Notes app in Android Mobiles Pin
Tirumaleswara Reddy.K4-Feb-16 18:44
Tirumaleswara Reddy.K4-Feb-16 18:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.