ksoap 与 Web 服务连接,无 Android(使用 ksoap)
好吧,我正在做一个连接...带有Web服务的sql服务器,带有j2me的Web服务,但现在我正在做一个helloworld...我可以,但现在我想做一个“hello world”+nombre.. 。 参数未在 Web 服务中接收,这里是 Web 服务
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// Para permitir que se llame a este servicio web desde un script, usando ASP.NET AJAX, quite la marca de comentario de la línea siguiente.
// [System.Web.Script.Services.ScriptService]
public class Service : System.Web.Services.WebService
{
public Service () {
}
[WebMethod]
public string HelloWorld(String nombre)
{
return "Que onda " + nombre;
}
}
,这是使用 ksoap 调用它的代码...
String nombremetodo="HelloWorld";
String url="http://localhost:49175/WebSite1/Service.asmx";
String namespace="http://tempuri.org/";
String SOAP_ACTION=namespace+nombremetodo;
public void traer()
{
SoapObject busqueda =new SoapObject(namespace,nombremetodo);
HttpTransport transportacion = new HttpTransport(url);
busqueda.addProperty(new String("nombre"),new String("Angel"));
System.out.println("parametro agregado");
//busqueda.addProperty(PropertyInfo.OBJECT_TYPE, "Angel");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
transportacion.debug=true;
envelope.bodyOut=busqueda;
System.out.println("todo ok");
try{
System.out.println("comenzando transportacion");
transportacion.call(SOAP_ACTION, envelope);
System.out.println("transportacion ok");
respuesta = envelope.getResponse().toString();
System.out.println("respuesta ok");
}
catch(Exception e)
{
texto.setString("fallo");
System.out.println("falla en el try");
System.out.println(e);
}
}
我得到它返回带有空格的“que onda”,因为所以我将其放入 Web 服务中,但从未返回“que onda”+nombre ...这是 j2me 的应用程序,而不是 android,我看android它是soo...
PropertyInfo p1 = new PropertyInfo();
p1.setName("nombre");
p11.setValue("Angel");
busqueda.addProperty(p1);
但是ksoap for j2me没有这些方法..“setName,setValue”; 我已经下载了这个库,但我遇到了一个丑陋的错误,并且应用程序无法运行...... 有了这个我看到参数被添加了所以..
busqueda.addProperty("nombre","Angel");
但这不起作用... 它确实运行了,没有任何错误,但是网络服务从未收到参数...
谢谢 STACKOVERFLOW 的人们 我的英语不太好,抱歉
well i am doing a connection... sql server with web service, web service with j2me, but now i am doing one helloworld...i could it, but now than i want to do one "hello world "+nombre...
parameter is not receive in web service, here the web service
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// Para permitir que se llame a este servicio web desde un script, usando ASP.NET AJAX, quite la marca de comentario de la línea siguiente.
// [System.Web.Script.Services.ScriptService]
public class Service : System.Web.Services.WebService
{
public Service () {
}
[WebMethod]
public string HelloWorld(String nombre)
{
return "Que onda " + nombre;
}
}
and this is the code for call it with ksoap...
String nombremetodo="HelloWorld";
String url="http://localhost:49175/WebSite1/Service.asmx";
String namespace="http://tempuri.org/";
String SOAP_ACTION=namespace+nombremetodo;
public void traer()
{
SoapObject busqueda =new SoapObject(namespace,nombremetodo);
HttpTransport transportacion = new HttpTransport(url);
busqueda.addProperty(new String("nombre"),new String("Angel"));
System.out.println("parametro agregado");
//busqueda.addProperty(PropertyInfo.OBJECT_TYPE, "Angel");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
transportacion.debug=true;
envelope.bodyOut=busqueda;
System.out.println("todo ok");
try{
System.out.println("comenzando transportacion");
transportacion.call(SOAP_ACTION, envelope);
System.out.println("transportacion ok");
respuesta = envelope.getResponse().toString();
System.out.println("respuesta ok");
}
catch(Exception e)
{
texto.setString("fallo");
System.out.println("falla en el try");
System.out.println(e);
}
}
i get it returns "que onda " with a space, because so i put it in web service, but never it returns "que onda "+nombre ... it is a application for j2me not for
android, i watch for android it is soo...
PropertyInfo p1 = new PropertyInfo();
p1.setName("nombre");
p11.setValue("Angel");
busqueda.addProperty(p1);
but ksoap for j2me doesn't have those methods.. "setName, setValue";
i have downloades this library but i get a ugly bug and application doesn't run...
with this i see parameter is added so..
busqueda.addProperty("nombre","Angel");
but this it doesn't work...
it does run it doesn't have any bug, but web service never receive the parameter...
thank you people of STACKOVERFLOW
my english is not very well sorry
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决了,有必要写
i solved it, it is necesary write