3

I create wcf with visual studio 2010 and publish on webmaterix 3.... I call this webservice in android app but not running... this my web.config:

<?xml version="1.0"?>
<configuration>
<system.web>
  <compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
  <behaviors>
  <serviceBehaviors>
    <behavior>

       <serviceMetadata httpGetEnabled="true"/>

      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
 <system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

</configuration>

and this my android code:

   private static final String NAMESPACE = "http://tempuri.org/";
            private static final String URL = 
                "http://localhost:60977/Service1.svc?singleWsdl";   
  private static final String SOAP_ACTION =     "http://tempuri.org/IService1/GetData";
            private static final String METHOD_NAME = "GetData";
             TextView txt=(TextView)findViewById(R.id.textView1);
        SoapObject request = new SoapObject(NAMESPACE,      METHOD_NAME);       
    SoapSerializationEnvelope envelope = 
        new    SoapSerializationEnvelope(SoapEnvelope.VER11); 

                envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new    HttpTransportSE(URL);
                name("SS");
                try {
                    name("0");
            androidHttpTransport.call(SOAP_ACTION, envelope);
                    name("1");
        SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
                    name("2");
                    name(resultsRequestSOAP.toString());
                    name("3");
            txt.setText("Received :" + resultsRequestSOAP.toString());

                } catch (Exception e) {
                    txt.setText(e.getMessage());
                    name(e.getMessage());
                    e.printStackTrace();
                }

when catch run,don't have any messages...

Nima.S-H
  • 777
  • 1
  • 9
  • 19
  • In AVD to connect to localhost you need to use url http://10.0.2.2/ instead of http://localhost/ – Nirmal Aug 05 '13 at 09:34

3 Answers3

0

1. change url to

private static final String URL = "http://localhost:60977/Service1.svc";   

and also check

getting java.io.IOException: HTTP request failed, HTTP status: 404 in ksoap2 while passing xml data to soap1.2 android

and

unable to get Response from HttpResponse when passing soap object (soap1.2) android?

Community
  • 1
  • 1
Tarsem Singh
  • 14,139
  • 7
  • 51
  • 71
0
 private static final String URL = 
                "http://localhost:60977/Service1.svc?singleWsdl"; 
            private static final String METHOD_NAME = "GetData";
    final String SOAP_ACTION = "http://tempuri.org/GetData";                  

                       try {
                           SoapObject request = new SoapObject(WebServiceUtil.NAMESPACE, METHOD_NAME);
                           SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                           envelope.dotNet = true;                        
                           envelope.setOutputSoapObject(request);

                           HttpTransportSE androidHttpTransport = new HttpTransportSE(WebServiceUtil.URL);
                           Log.d("URL  :: ", WebServiceUtil.URL);           
                           androidHttpTransport.call(SOAP_ACTION, envelope);


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

                       }

                }
Mohammod Hossain
  • 4,134
  • 2
  • 26
  • 37
0

actually, localhost is emulator itself here because the code runs inside the emulator. so you should connect to 10.0.2.2. for more details see Android Emulator Networking and don't forget the network permissions in the manifest file