2

My server image

I am working on webservice i don't have any ideas about webservices. I look same sample webservices (like live SOAP service) it work fine. I am to run the webservice in localhost i dont know whether my URL,Namespace and methodName are declared correctly.

The following code is my WSDL code

<definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"   
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:xs0="http://www.processmaker.com"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"   
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" 
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
xmlns="http://schemas.xmlsoap.org/wsdl/" 
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
targetNamespace="http://www.processmaker.com">
<types>
<xs:schema elementFormDefault="qualified"     
targetNamespace="http://www.processmaker.com">
<xs:element name="login">
<xs:complexType>
<xs:sequence>
<xs:element name="userid" type="xs:string"/>
<xs:element name="password" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</definitions>

My android code for calling the above service:

public class MainActivity extends Activity {
String str = null;
private static final String SOAP_ACTION = "http://www.processmaker.com/Login";
private static final String METHOD_NAME = "Login";
private static final String NAMESPACE = "http://www.processmaker.com/";
private static final String URL = "http://192.168.1.5/sysworkflow/en/neoclassic/setup/main";
SoapObject request;
TextView tv;

@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
            .permitAll().build();
    StrictMode.setThreadPolicy(policy);
    setContentView(R.layout.activity_main);

    tv = (TextView) findViewById(R.id.textView1);


    DownloadWebPageTask task = new DownloadWebPageTask();
    task.execute();
}


private class DownloadWebPageTask extends AsyncTask<String, Void, String> {
    @Override
    protected String doInBackground(String... urls) {
      String response = "";

        try {
            request = new SoapObject(NAMESPACE, METHOD_NAME);
            PropertyInfo weightProp = new PropertyInfo();
            weightProp.setName("USER_ID");
            weightProp.setValue("admin");
            weightProp.setType(String.class);
            request.addProperty(weightProp);

            PropertyInfo fromProp = new PropertyInfo();
            fromProp.setName("PASSWORD");
            fromProp.setValue("admin");
            fromProp.setType(String.class);
            request.addProperty(fromProp);

            /*
             * PropertyInfo toProp =new PropertyInfo(); toProp.setName("ToUnit");
             * toProp.setValue(toUnit); toProp.setType(String.class);
             * request.addProperty(toProp);
             */
            final SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);
            envelope.dotNet = true;
            envelope.setOutputSoapObject(request);
            final HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

            try {
                androidHttpTransport.call(SOAP_ACTION, envelope);
                SoapPrimitive response1 = (SoapPrimitive) envelope.getResponse();
                Log.i("myApp", response1.toString());
            //  tv.setText(response.toString());
                Toast.makeText(getApplicationContext(), response.toString(),
                        Toast.LENGTH_LONG).show();

            } catch (Exception e) {
                tv.setText(e.toString());

                e.printStackTrace();

            }
          }

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

    @Override
    protected void onPostExecute(String result) {
      tv.setText(result);
    }
  }

please someboby help me to do this..

Vini
  • 967
  • 1
  • 15
  • 33

1 Answers1

1

Hi use like this.

 private static final String SOAP_ACTION = "http://www.processmaker.com/Login";
private static final String METHOD_NAME = "Login";
private static final String NAMESPACE = "http://www.processmaker.com";
private static final String URL = "http://10.0.2.2/sysworkflow/en/classic/services/wsdl2";

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("userid", "admin");
request.addProperty("password", "admin");

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

  HttpTransportSE ht = new HttpTransportSE(URL);

 try {
    ht.call(SOAP_ACTION, envelope);
    final SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
    str = response.toString();

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

  }
    Log.d("WebRespone", str);

Hope this will help you.

Nirmal
  • 2,340
  • 21
  • 43
  • +1) thanks for your reply it shows connection timed out exception. – Vini Sep 26 '13 at 05:34
  • @Ela check my edited answer. if you didnt get the output the problem might be your URL. – Nirmal Sep 26 '13 at 05:50
  • @Ela whats your error. if your getting strictmode error please use async task. – Nirmal Sep 26 '13 at 05:59
  • i solved the force close error but that connection timed out exception is occur please help me to solve this issue... – Vini Sep 26 '13 at 06:11
  • it goes only upto this line... ht.call(SOAP_ACTION, envelope); then goes to catch block... – Vini Sep 26 '13 at 06:13
  • check my edited answer please use the proper url. you will get the output. – Nirmal Sep 26 '13 at 06:18
  • @nirmal, i have used your code and not working for me can you expain the above code in briefly.... – Selva Sep 26 '13 at 10:08
  • @Selvendran you are working localhost webservice or live url. – Vini Sep 26 '13 at 10:32
  • @Selvendran pls explain your problem i am not god to find your solution without your code. – Nirmal Sep 26 '13 at 10:33
  • @Ela if it is in server i can explain you. in localhost i cant you have to learn the webservice process. but i gave you all the procedure. and reference link too. pls check those things and implement. it is an easy one. – Nirmal Sep 26 '13 at 10:44
  • can you suggest which one need to put the url...it is my url http://localhost/sysworkflow/en/neoclassic/setup/main in my browser. – Vini Sep 26 '13 at 10:59
  • nirmal can you tell me how to solve this one.. SoapFault - faultcode: 'SOAP-ENV:Server' faultstring: 'Procedure 'login' not present' faultactor: 'null' detail: null – Vini Sep 27 '13 at 09:18