0

I am trying to create a android app to send text and photos to .net webservice. I have functions in my webservice. one of them gets a dummy name(I created this to check if I can make a connection) and the other one is to insert some data into DB. I want to post my work to get help.

private final String NAMESPACE = "http://methodoor.com/";
//webservice is working, you can check it online
private final String URL = "http://servicing2.rotanet.com.tr/service.asmx";
private final String SOAP_ACTION = "http://methodoor.com/checkupservice/SendData";
private final String METHOD_NAME = "SendData";


       //Create request
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

    request.addProperty("containerId",1);
    .........
    .........           
    request.addProperty("sFileID","asd");
    request.addProperty("userId",1);

    //Create envelope
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;
    //Set output SOAP object
    envelope.setOutputSoapObject(request);
    //Create HTTP call object
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try {
        //Invole web service
        androidHttpTransport.call(SOAP_ACTION, envelope);
        //Get the response
        SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
        //Assign it to fahren static variable
        fahren = response.toString();
    } catch (Exception e) {

    }

My problem is, I am not sure if this is the correct way to pass data to webservice. it doesnt crash or gives any error message. It just doesnt insert into the DB

2
  • Your code looks correct, and should work may be it is not inserting data coz you might giving wrong parameter tag or method name ...otherwise method is correct...if you want I can post example for your help.. Commented May 15, 2013 at 16:07
  • please. if you have any example, please post Commented May 15, 2013 at 16:08

1 Answer 1

3

here you go..make sure to check spelling of each tag in your service, method name and path of your service..

public SoapObject soap(String METHOD_NAME, String SOAP_ACTION, String NAMESPACE, String URL,String IP,String SERVICEPATH) throws IOException, XmlPullParserException 
 {
    abc.allowAllSSL();
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); //set up request
    //request.addProperty("iTopN", "5"); //variable name, value. I got the   variable      name, from the wsdl file!

    request.addProperty("UserId", login);
    request.addProperty("Password", password);


    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); // put all required data into a soap
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request); // prepare request
    envelope.bodyOut = request;
      Log.d("ENVELOPE",""+"Coming3");
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
    //androidHttpTransport.
    androidHttpTransport.call(SOAP_ACTION, envelope);

    Log.d("ENVELOPE",""+envelope.bodyIn);
    SoapObject result = (SoapObject) envelope.bodyIn; // get response
    Log.d("ENVELOPE",""+envelope.bodyIn);
    SoapObject responseBodyRaw,responseBody,tableRow;
    return result;
 }

Here is parameter details

private String NAMESPACE = "http://tempuri.org/";
private String SOAP_ACTION = "http://tempuri.org/UserProfile";
private String METHOD_NAME = "UserProfile";
private String URL="https://172.17.60.15/HostingService/PhoneForService.asmx";
//private String URL="https://172.19.2.250/testService/phone.asmx";
private String SERVICEPATH="/HostingService/PhoneForService.asmx";

I hope would be helpful for you

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.