私はすでに.net c#を使用して開発したasmxを使用しており、うまく機能しています
しかし、Java Androidエラーを使用して呼び出す必要があるときにエラーが見つかりました: java.lang.ClassCastException:org.ksoap2.serialization.SoapObject cannot be cast to org.ksoap2.serialization.SoapPrimitive
私のasmxに表示される結果:
<customer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
<customerID>1</customerID>
<companyName>ABC</companyName>
<contactName>Jack</contactName>
<customerID>2</customerID>
<companyName>SS Company</companyName>
<contactName>Mary</contactName>
</customer>
私のJava cs:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView)findViewById(R.id.textView1);
SoapObject Request = new SoapObject (NAMESPACE, METHOD_NAME);
Request.addProperty("custID", "member");
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(Request);
AndroidHttpTransport aht = new AndroidHttpTransport(URL);
try
{
aht.call(SOAP_ACTION, soapEnvelope);
SoapObject resultString = (SoapObject) soapEnvelope.getResponse();
tv.setText(resultString.toString());
}
catch(Exception e)
{
tv.setText(e.toString());
}
}
http://www.w3schools.com/webservices/tempconvert.asmxを使用すると、上記のコードが機能します