How can I use php webservice in android applcation

I have code that works on iphone and I want to make the same application in android. I have to use php webservice. using a soap library. I want to use the following webservice http://www.medihand.org/freechoicedrivers/soap/members.php

here is the wsdl code

- - - - - - - - - - - - -

and I used the Android code that I put here

public class start extends Activity {

private static final String SOAP_ACTION = "urn: members # syncMemberDetails";

private static final String METHOD_NAME = "syncMemberDetails"; private static final String NAMESPACE = "http://schemas.xmlsoap.org/wsdl/"; // !!!!! IMPORTANT!!!!! THE URL OF THE CoLDFUSION WEBSERVER NOT LOCALHOST BECAUSE LOCALHOST IS THE ANDROID EMULATOR !!!!! private static final String URL = "http://www.medihand.org/freechoicedrivers/soap/members.php"; //String sample[] ={"milan","pratik"}; TextView tv; String s=""; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); /* s = " <?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + "<SOAP-ENV:Envelope\n"+ " SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"\n"+ " xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"\n"+ " xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\"\n"+ " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n"+ " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"+ " <SOAP-ENV:Body>\n"+ " <syncMemberDetails>\n"+ " <values xsi:type=\"xsd:Array\">\n"+ " <item>\n"+ " <username xsi:type=\"xsd:string\">test</username>\n"+ " <password xsi:type=\"xsd:string\">test</password>\n"+ " <dates xsi:type=\"xsd:Array\">\n"+ " <item>\n"+ " <year xsi:type=\"xsd:int\">2010</year>\n"+ " <month xsi:type=\"xsd:int\">12</month>\n"+ " <day xsi:type=\"xsd:int\">%30</day>\n"+ " <sync xsi:type=\"xsd:int\">(null)</sync>\n"+ " <times xsi:type=\"xsd:Array\">\n"+ " <item>\n"+ " <start xsi:type=\"xsd:int\">0</start>\n"+ " <finish xsi:type=\"xsd:int\">0</finish>\n"+ " <sync xsi:type=\"xsd:int\">0</sync>\n"+ " <timestamp xsi:type=\"xsd:date\">2010-11-10 18:07:44 GMT</timestamp>\n"+ " </item>\n"+ " </times>\n"+ " </item>\n"+ " <item>\n"+ " <year xsi:type=\"xsd:int\">2010</year>"+ " <month xsi:type=\"xsd:int\">12</month>"+ " <day xsi:type=\"xsd:int\">21</day>"+ " <sync xsi:type=\"xsd:int\">0</sync>"+ " <times xsi:type=\"xsd:Array\">"+ " </times>"+ " </item>"+ " </dates>\n"+ " </item>\n"+ " </values>\n"+ " </syncMemberDetails>\n"+ " </SOAP-ENV:Body>\n"+ "</SOAP-ENV:Envelope>";*/ tv = (TextView) findViewById(R.id.title); SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME); Request.addProperty("?????", "array value"); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.setOutputSoapObject(Request); AndroidHttpTransport aht = new AndroidHttpTransport (URL); try { aht.call(SOAP_ACTION, envelope); SoapPrimitive resultstring = (SoapPrimitive) envelope.getResponse(); Toast.makeText(this, String.valueOf(resultstring), 5000).show(); } catch(Exception E) { tv.setText("ERROR:" + E.getClass().getName() + ": " + E.getMessage()); } 

}}

what do I need to write in request.addProperty (????, "value")

in dotnew web service i used tag where? here .... so anyone knows plz tell me how can i access this php webservice

I also put the iphone code that is already running

+4
source share
1 answer

use this code and related changes (including ksoap library)

  String url="http://192.168.1.163/webservice/test.php"; String namespace="http://tempuri.org"; String method="getuser"; SoapObject request=new SoapObject(namespace,method); request.addProperty("u","admin"); ***//paraemeter of method(u is php method parametr)*** request.addProperty("i","icare"); **/*/paraemeter of method*** SoapSerializationEnvelope soapEnvelope=new SoapSerializationEnvelope(SoapEnvelope.VER10); soapEnvelope.setOutputSoapObject(request); AndroidHttpTransport ahi=new AndroidHttpTransport(url); try { ahi.call(soapaction,soapEnvelope); SoapPrimitive response=(SoapPrimitive)soapEnvelope.getResponse(); } catch(Exception e) { e.printStackTrace(); } 
+2
source

All Articles