2011-03-27 5 views
0

잘하고 있어요 ... 웹 서비스와 SQL 서버, J2ME와 웹 서비스,하지만 지금은 하나의 helloworld하고있다 ... 나는 그것을 할 수 있지만, 지금은 하나에 "Hello World"를하고 싶은 것보다 ...ksoap 웹 서비스와 연결, 아니 안드로이드 (ksoap 사용)

+ 브레 ... 매개 변수는 여기에, 웹 서비스에서 웹 서비스

[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"를 공백으로 반환하지만 결코 "que 온다 "브레가 + ... 그렇지 안드로이드를위한 J2ME를위한 응용 프로그램입니다, 내가 ... 그것은 김입니다 안드로이드에 대한

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

을 볼 수 있지만, J2ME에 대한 ksoap 그 방법이 없습니다 .."에서는 setName, setValue "; 내가 downloades이 라이브러리를 가지고 있지만이와 내가 매개 변수 때문에 추가 참조 ... 나는 추한 버그를 얻고 응용 프로그램이 실행되지 않습니다 ..

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

하지만 그것은 ... 작동하지 않습니다 그것이 어떤 버그가없는 실행 않지만, 웹 서비스는 매개 변수를받지 않습니다 ...

당신에게 유래 의 사람들에게 감사 내 영어는 내가 그것을 해결, 그것은 모든 necesary 쓰기

답변

0

매우 잘 미안하지 않다

envelope.dotNet=true;