1
votes

I have error to get value from web service. I try alltime but not success. I did webservice using with WCF, Entity framework. this server Works good. But I want to connect and get value from Android phone.

My Android code :

private final String NAMESPACE="http://tempuri.org/";
private final String SOAPACTION="http://tempuri.org/IService/GetValues";
private final String METHODNAME="GetTreatmentValues";

private final String URL="http://localhost:49674/Service.svc";

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.menu); button1.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {

          SoapObject request = new SoapObject(NAMESPACE,METHODNAME);
          request.addProperty("value",1);

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

          HttpTransportSE aht = new HttpTransportSE(URL);
          aht.debug = true;
          text2.setText(aht.toString());
          //AndroidHttpTransport aht = new AndroidHttpTransport(URL);
          try {
              aht.call(SOAPACTION,sp);  //I have ERROR! no work.
              //SoapPrimitive resultstring = (SoapPrimitive)sp.getResponse();
              text1.setText("test");
              //text2.setText(resultstring.toString());
          } catch (Exception e) {
              // TODO: handle exception
              text2.setText("hata!");
          }           
                  }       
             });

I get error aht.call(SOAPACTION,sp); text1 never sets "test" What should I do. I don't know what I miss. thanks. (using Ksoap2.4)

2

2 Answers

0
votes

Try This Example, or check your code with this code
http://www.c-sharpcorner.com/uploadfile/88b6e5/how-to-call-web-service-in-android-using-soap/

Hope you will get solution.

0
votes

I put my webservice into ISS. my link is http:// localhost:90/Service.svc?wsdl in this page, I see xml code

 -<wsdl:binding name="BasicHttpBinding_IService" type="tns:IService">
   <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    wsdl:operation name="GetTreatmentValues">

     <soap:operation style="document"
     soapAction="http://tempuri.org/IService/GetTreatmentValues"/>


     -<wsdl:input>

     <soap:body use="literal"/>

     </wsdl:input>

     -<wsdl:output>

     <soap:body use="literal"/>

     </wsdl:output>

     </wsdl:operation>

I write this code into Android app

private final String NAMESPACE="http://tempuri.org/"; 
private final String SOAPACTION="http://tempuri.org/GetTreatmentValues"; 
private final String METHODNAME="GetTreatmentValues"; 


private final String URL="http://localhost:90/Service.svc?singleWsdl";

but I allways get error in here :( :(

try {
              aht.call(SOAPACTION,sp);  //I have ERROR! no work.
              //SoapPrimitive resultstring = (SoapPrimitive)sp.getResponse();
              text1.setText("test");
              //text2.setText(resultstring.toString());
          } catch (Exception e) {
              // TODO: handle exception
              text2.setText("hata!");
          }