2011-03-27 80 views
0

以及我正在做一个连接...与web服务,j2me的web服务的sql服务器,但现在我正在做一个helloworld ...我可以,但现在比我想要做一个“世界你好” +农布雷... 参数不在网络服务接收,这里的Web服务ksoap与web服务连接,没有android(使用kso​​ap)

[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昂达“+农布雷......它不是 机器人为J2ME应用程序一个,我看的Android是洙......

PropertyInfo p1 = new PropertyInfo(); 
p1.setName("nombre"); 
p11.setValue("Angel"); 
busqueda.addProperty(p1); 

但KSOAP为J2ME没有这些方法..”的setName,设定值”; 我有downloades这个库,但我得到一个丑陋的错误,应用程序不能运行...... 有了这个,我看参数添加这样..

busqueda.addProperty("nombre","Angel"); 

但它不工作... 它不运行它没有任何错误,但Web服务从未接收参数...

谢谢计算器 的人我的英语不是非常好后悔

回答

0

我解决了这个问题,它是necesary写

envelope.dotNet=true; 
相关问题