A
Asuka
Neues Mitglied
- 0
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
und bekomme bei result ne NullPointerException. Hat jemand ne Idee, woran das liegen koennte?
Vielen Dank im Voraus und viele Gruesse
Asuka
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
Code:
// Soap object parameter initialization
// SOAP_ACTION: You build this from "NAMESPACE string" +
// "METHOD_NAME string"
// METHOD_NAME: User provided, you get this from the wsdl
// NAMESPACE: User provided, you get this from the wsdl
// URL: User provider, you get this from the wsdl
private static final String SOAP_ACTION = "http://tempuri.org/CelsiusToFahrenheit";
private static final String METHOD_NAME = "CelsiusToFahrenheit";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://www.w3schools.com/webservices/tempconvert.asmx";
TextView tv;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
tv = (TextView) findViewById(R.id.text0);
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
Request.addProperty("Celsius", "32");
// PART 4
// Create SOAP Envelope and serialize webservice XML object
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(Request);
AndroidHttpTransport tns = new AndroidHttpTransport(URL);
try {
// PART 8
// Make the Web Service Call
tns.call(SOAP_ACTION, soapEnvelope);
// PART 9
// Extract the response from the Web Service Object
SoapPrimitive result = (SoapPrimitive) soapEnvelope.getResponse();
// Print out response
tv.setText("Quote Results: " + result);
} catch (Exception e)
{
e.printStackTrace();
}
}
Vielen Dank im Voraus und viele Gruesse
Asuka