alamein72 / ksoap2-android

Automatically exported from code.google.com/p/ksoap2-android
0 stars 0 forks source link

Problem with WCF #118

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run a WCF local in Visual Studio
2. Create a android app using ksoap
3. Just run the app

What is the expected output? What do you see instead?
WCf method has a string return, so I should get this string by calling the 
method. Nothing, just a timeout connection.

What version of the product are you using? On what operating system?
.NET 4, C# WCF
Android 2.3
Eclipse Indigo with the android SDK
Windows 7

Please provide any additional information below.

Here's my code

WCF:

[ServiceContract]
    public interface IService1 {
        [OperationContract]
        string GetData();
    }

-----------
App.config

<service name="CommunicationInterface.Service1" 
behaviorConfiguration="CommunicationInterface.Service1Behavior">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8732/Design_Time_Addresses/CommunicationInterface/Service1.svc" />
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address ="" binding="basicHttpBinding" contract="CommunicationInterface.IService1" >

------

Android

public class MyActivity extends Activity {

    private static final String SOAP_ACTION = "http://tempuri.org/IService1/GetData";
    private static final String METHOD_NAME = "GetData";
    private static final String NAMESPACE = "http://tempuri.org/";
    private static final String URL = "http://10.0.0.2:8732/Design_Time_Addresses/CommunicationInterface/Service1.svc";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    public void callWCF(View view) throws IOException, XmlPullParserException {

         SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

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

         HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

         androidHttpTransport.call(SOAP_ACTION, envelope);

         Object response = envelope.getResponse();

         String results = response.toString();

    }
} 

I getting time-out every time I do androidHttpTransport.call(SOAP_ACTION, 
envelope);.

Original issue reported on code.google.com by Erick.Ga...@gmail.com on 29 Apr 2012 at 12:13

GoogleCodeExporter commented 8 years ago
I dont know about WCF webservices and stuff but the SOAPAction and namespace 
look wrong..  in either case it does not seem to be a problem related to ksoap 
itself but rather your code. 

Original comment by mosa...@gmail.com on 30 Apr 2012 at 6:20

GoogleCodeExporter commented 8 years ago
I found the problem.

Actually everything is right, but the IP 10.0.0.2 not seems to work in my case. 
So I put the ipv4 instead of 10.0.0.2 and everything works great.

Thx.

Original comment by Erick.Ga...@gmail.com on 1 May 2012 at 1:49