ksoap2 tutorial funktioniert nicht

  • Antworten:2
Christine Bauers
  • Forum-Beiträge: 1

15.10.2010, 12:14:24 via Website

Hey Leute,

ich versuche mich gerade in Webservices in Verbindung mit Android einzuarbeiten und habe ein Tutorial gefunden. Ich folge den Anweisungen nehme exakt die gleiche jar, hier mal der Quellcode

1// Soap object parameter initialization
2 // SOAP_ACTION: You build this from "NAMESPACE string" +
3 // "METHOD_NAME string"
4 // METHOD_NAME: User provided, you get this from the wsdl
5 // NAMESPACE: User provided, you get this from the wsdl
6 // URL: User provider, you get this from the wsdl
7 private static final String SOAP_ACTION = "http://tempuri.org/CelsiusToFahrenheit";
8 private static final String METHOD_NAME = "CelsiusToFahrenheit";
9 private static final String NAMESPACE = "http://tempuri.org/";
10 private static final String URL = "http://www.w3schools.com/webservices/tempconvert.asmx";
11 TextView tv;
12
13 public void onCreate(Bundle savedInstanceState) {
14 super.onCreate(savedInstanceState);
15 tv = (TextView) findViewById(R.id.text0);
16
17 SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
18 Request.addProperty("Celsius", "32");
19
20 // PART 4
21 // Create SOAP Envelope and serialize webservice XML object
22 SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(
23 SoapEnvelope.VER11);
24 soapEnvelope.dotNet = true;
25 soapEnvelope.setOutputSoapObject(Request);
26 AndroidHttpTransport tns = new AndroidHttpTransport(URL);
27 try {
28 // PART 8
29 // Make the Web Service Call
30 tns.call(SOAP_ACTION, soapEnvelope);
31
32 // PART 9
33 // Extract the response from the Web Service Object
34 SoapPrimitive result = (SoapPrimitive) soapEnvelope.getResponse();
35
36 // Print out response
37 tv.setText("Quote Results: " + result);
38 } catch (Exception e)
39
40 {
41 e.printStackTrace();
42 }
43
44 }



und bekomme bei result ne NullPointerException. Hat jemand ne Idee, woran das liegen koennte?

Vielen Dank im Voraus und viele Gruesse
Asuka

Antworten
Gelöschter Account
  • Forum-Beiträge: 281

15.10.2010, 14:43:40 via Website

Vielleicht findet er dein Textview im Layout nicht... Wäre eine Möglichkeit.

Antworten
Mac Systems
  • Forum-Beiträge: 1.727

15.10.2010, 15:47:45 via Website

Und die fliegt in welcher Zeile ?

Windmate HD, See you @ IO 14 , Worked on Wundercar, Glass V3, LG G Watch, Moto 360, Android TV

Antworten