ksoap2 を使用して、andriod Web サービス プログラムから SOAP Web サービスを利用したいと考えています。そのために、次のコードを書きました。これを Android エミュレーターで実行すると、logcat で応答が得られません。私の Web サービスの戻り値の型は XML file です。
public class SoapWebservicesExampleActivity extends Activity {
/** Called when the activity is first created. */
final String NAMESPACE = "urn:sap-com:document:sap:soap:functions:mc-style";
final String URL = "http://***********:8000/sap/bc/srt/wsdl/srvc_14DAE9C8D79F1EE196F1FC6C6518A345/wsdl11/allinone/ws_policy/document?sap-client=800&sap-user=*******&sap-password=*********";
//i am appending the Username and password as URL Parameters.
final String METHOD_NAME = "Z_GET_CUST_GEN";
final String SOAP_ACTION = "urn:sap-com:document:sap:soap:functions:mc-style/Z_GET_CUST_GEN";
// i am getting the method name tns from WSDL file.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); // set up
request.addProperty("Input", "1460");
// request.addProperty("Langu", "d");
//one property in the webservices
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); // put all required data into a soap
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(URL);
httpTransport.debug = true;
try {
httpTransport.call(SOAP_ACTION, envelope);
// by using call method we can call the services
SoapObject response = (SoapObject)envelope.getResponse();
String str = response.getProperty(0).toString();
System.out.println("theeeeeeeeeee"+str);
//printing the respose here
}
catch(SocketException ex){
ex.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}
しかし、ここでの問題は、ksoap2 jar ファイルを追加しているときにこの例外が発生したことです。
05-29 15:37:54.403: WARN/System.err(383): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <{http://schemas.xmlsoap.org/wsdl/}wsdl:definitions targetNamespace='urn:sap-com:document:sap:soap:functions:mc-style'>@1:686 in java.io.InputStreamReader@40547218)
05-29 15:37:54.403: WARN/System.err(383): at org.kxml2.io.KXmlParser.exception(KXmlParser.java:273)