Note that there are some explanatory texts on larger screens.

plurals
  1. POConnect Android App to Java web services And pass Value to Web services
    primarykey
    data
    text
    <p>This is the web services that i want to connect and send value from android virtual machine.</p> <pre><code>@WebService(serviceName = "EmoDeneme") @Stateless() public class EmoDeneme { /** * This is a sample web service operation */ @WebMethod(operationName = "hello") public String hello(@WebParam(name = "name") String name) { String BargeName = ""; int BargeNo = 0; String Starting = ""; String StartingDate = ""; try { MongoClient mongoClient = new MongoClient("localhost", 27017); DB db = mongoClient.getDB("Barge"); DBCollection collection = db.getCollection("Emo"); DBObject match = new BasicDBObject("$match", new BasicDBObject("html.table.tbody.Barge.Name", name)); DBObject unwind = new BasicDBObject("$unwind", "$html.table.tbody.Barge"); AggregationOutput output = collection.aggregate(unwind, match); for (DBObject result : output.results()) { DBObject htmlObj = (DBObject) result.get("html"); DBObject tableObj = (DBObject) htmlObj.get("table"); DBObject tbodyObj = (DBObject) tableObj.get("tbody"); DBObject bargeObj = (DBObject) tbodyObj.get("Barge"); BargeName = (String) bargeObj.get("Name"); BargeNo = (Integer) bargeObj.get("Bargeno"); Starting = (String) bargeObj.get("Starting"); StartingDate = Starting.substring(0, 10); } } catch (UnknownHostException e) { e.printStackTrace(); } catch (MongoException e) { e.printStackTrace(); } return "Terminal: " + " BargeName :" + BargeName + " BargeNo: " + BargeNo + " ETA : " + StartingDate; } } </code></pre> <p>This is the Android Code to connect to web service</p> <pre><code>public class MainActivity extends Activity { private static final String SOAP_ACTION = ""; private static final String METHOD_NAME = "hello"; private static final String NAMESPACE = "http://mongodb.me.org/"; private static final String URL = "http://10.0.2.2:8080/EmoDeneme/EmoDeneme?WSDL"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Thread networkThread = new Thread() { @Override public void run() { try { SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); String firstName = "Aan"; //Pass value for fname variable of the web service PropertyInfo fnameProp =new PropertyInfo(); fnameProp.setName("name");//Define the variable name in the web service `method` fnameProp.setValue(firstname);//Define value for fname variable fnameProp.setType(String.class);//Define the type of the variable request.addProperty(fnameProp);//Pass properties to the variable SoapSerializationEnvelope envelope = new `SoapSerializationEnvelope(SoapEnvelope.VER11);` envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE ht = new HttpTransportSE(URL); ht.call(SOAP_ACTION, envelope); final SoapPrimitive response = (SoapPrimitive)envelope.getResponse(); final String str = response.toString(); runOnUiThread (new Runnable(){ public void run() { TextView result; result = (TextView)findViewById(R.id.textView1);//I have created a text view `&amp; It's id is textView1` result.setText(str); } }); } catch (Exception e) { e.printStackTrace(); } } }; networkThread.start(); } } </code></pre> <p>It does not work, can someone help me please what i do wrong. Thank you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload