-1
저는 Ksoap libary를 사용하여 Android 웹에서 간단한 웹 서비스를 프로그래밍했습니다. 그러나 그것은 잘 작동하지 않는 것 같습니다. 아래는 간단한 코드입니다.웹 서비스 (.net)가 예상대로 작동하지 않습니다.
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();
}
}
}
텍스트 뷰에는 "오류"라는 응답 만 표시됩니다. 아무도 나에게 무엇이 잘못되었는지 말해 줄 수 있습니까?
왜 부정 투표입니까? 설명 해주십시오.. – rootpanthera