Quote:
Originally Posted by zona21
hi
I have been using ksoap2 for a couple of days and i can't send the parameters to my web service,I can connect it but i don't know what's the problem for sending parameters.
this is my code
import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.*;
public class webService {
public webService() {
String serviceUrl = "h t t p://192.168.44.250/SerW_SubirArch/SubirArch.asmx";
String serviceNamespace = "h t t p://192.168.44.250/SerW_SubirArch/";
String soapAction = "mx.com.medisist.WebService/SignosVitalesblack";
String methodName= "SignosVitalesblack";
SoapObject rpc = new SoapObject(serviceNamespace, methodName);
rpc.addProperty("idPaciente", String.valueOf(340).toString());
rpc.addProperty("glucosa",String.valueOf(120).toSt ring());
rpc.addProperty("Medicamento","Metformina tableta 1000mg");
rpc.addProperty("Cantidad",String.valueOf(5).toStr ing());
rpc.addProperty("medida","Pastillas");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.ENC;
envelope.setOutputSoapObject(rpc);
HttpTransport ht = new HttpTransport(serviceUrl);
ht.debug = true;
ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
int result= -1;
try {
ht.call(soapAction, envelope);
result = Integer.valueOf((envelope.getResult()).toString()) .intValue();
} catch (org.xmlpull.v1.XmlPullParserException ex2) {
} catch (Exception ex) {
String bah = ex.toString();
System.out.println(bah);
}
}
}
I would appreciate much if you could help me
|
hi everybody
finally, I could transfer parameters to my web service, my mistake was that i was writing on the variable *serviceNamespace something like this: String serviceNamespace = "h t t p://192.168.44.250/SerW_SubirArch/";
the situation was happening because i had another nameSpace on my web Service it was:
[WebService(Namespace = "mx.com.medisist.WebService")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class SubirArch : System.Web.Services.WebService{
furthermore I had to put the same name on my code variable *serviceNamespace because it has to be the same String to pass the parameters, now my new code is:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Medisist;
import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.*;
public class webService {
public webService() {
String serviceUrl = "h t t p://192.168.44.250/SerW_SubirArch/SubirArch.asmx";
String serviceNamespace = "mx.com.medisist.WebService";
String soapAction = "mx.com.medisist.WebService/SignosVitalesblack";
String methodName="SignosVitalesblack";
SoapObject rpc = new SoapObject(serviceNamespace, methodName);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
rpc.addProperty("idPaciente","340");
rpc.addProperty("glucosa","120");
rpc.addProperty("Medicamento","Metformina tableta 1000mg");
rpc.addProperty("Cantidad","5");
rpc.addProperty("medida","Pastillas");
envelope.setOutputSoapObject(rpc);
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.XSI;
HttpTransport ht = new HttpTransport(serviceUrl);
ht.debug = true;
ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
String result= null;
try {
ht.call(soapAction, envelope);
result = (envelope.getResult()).toString();
} catch (org.xmlpull.v1.XmlPullParserException ex2) {
} catch (Exception ex) {
String bah = ex.toString();
System.out.println(bah);
}
}
}
I appreciate much and i hope that this code can be helpfully