Java Web服务(.net),未按预期工作
我已经使用Ksoap库在android中编程(实际上遵循了教程)了简单的web服务。但它似乎不起作用。下面是我的简单代码:Java Web服务(.net),未按预期工作,java,android,.net,web-services,Java,Android,.net,Web Services,我已经使用Ksoap库在android中编程(实际上遵循了教程)了简单的web服务。但它似乎不起作用。下面是我的简单代码: public class MainActivity extends Activity { TextView tv; SoapPrimitive response; final String SOAP_ACTION = "http://tempuri.org/CelsiusToFahrenheit"; final String METHOD_NAME = "Celsius
public class MainActivity extends Activity {
TextView tv;
SoapPrimitive response;
final String SOAP_ACTION = "http://tempuri.org/CelsiusToFahrenheit";
final String METHOD_NAME = "CelsiusToFahrenheit";
final String NAMESPACE = "http://www.tempuri.org/";
final String URL = "http://www.w3schools.com/webservices/tempconvert.asmx";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv = (TextView) findViewById(R.id.tv);
final Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getValue();
}
});
}
private void getValue() {
SoapObject soapObject = new SoapObject(NAMESPACE, METHOD_NAME);
soapObject.addProperty("Celsius", "33");
SoapSerializationEnvelope serial = new SoapSerializationEnvelope(SoapEnvelope.VER11);
serial.dotNet = true;
serial.setOutputSoapObject(soapObject);
HttpTransportSE transport = new HttpTransportSE(URL);
try {
transport.call(SOAP_ACTION, serial);
response = (SoapPrimitive) serial.getResponse();
tv.setText(response+"");
} catch (IOException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
}
}
}
我在文本视图中只得到一个“Error”响应。谁能告诉我这里出了什么问题吗?我发现了什么问题。我写道:
final String NAMESPACE = "http://www.tempuri.org/";
而不是
final String NAMESPACE = "http://tempuri.org/";
它现在起作用了。为什么投反对票?请解释一下。。