2
Answers

Pass multiple parameters to SAP SOAP webservice?

durai venkatesh

durai venkatesh

7y
272
1
Hi All,
 
           I need to Pass multiple parameters to SAP SOAP webservice using Android platform.
I have tried several ways, but unable to proceed. Kindly suggest me. Below I have mentioned the xml body and Android Code.
 
XML BODY
 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:sap-com:document:sap:rfc:functions">
<soapenv:Header/>
<soapenv:Body>
<urn:ZTEST_FM>
<!--Optional:-->
<IM_KUNNR></IM_KUNNR>
<!--Optional:-->
<IS_COPYREFERENCE>
<KTOKD>?</KTOKD>
<KUNNR>?</KUNNR>
<BUKRS>?</BUKRS>
<VKORG>?</VKORG>
<VTWEG>?</VTWEG>
<SPART>?</SPART>
</IS_COPYREFERENCE>
</urn:ZTEST_FM>
</soapenv:Body>
</soapenv:Envelope>
 
 
 
Android AsyncTask SOAP Webservice Call Code:
 
private static String SOAPACTION = "urn:sap-com:document:sap:rfc:functions/ZTEST_FM";
private static String METHODNAME = "ZTEST_FM";
private static String NAMESPACE = "urn:sap-com:document:sap:rfc:functions";
private static String URL ="https://Host:Port/sap/bc/srt/rfc/sap/zws_test_fm1/400/zws_test_fm1/zws_test_fm1";
public class SOAPWebServiceCall extends AsyncTask {
ProgressDialog responseDialog;
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
responseDialog = ProgressDialog.show(MainActivity.this, "", "Please Wait", true);
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
SoapObject request1 = new SoapObject(NAMESPACE, METHODNAME);
request1.addProperty("IM_KUNNR", "42");
request1.addProperty("IS_COPYREFERENCE", "");
request1.addProperty("KTOKD", "ZCON");
request1.addProperty("KUNNR", "");
request1.addProperty("BUKRS", "");
request1.addProperty("VKORG", "");
request1.addProperty("VTWEG", "");
request1.addProperty("SPART", "");
request1.addProperty("IS_COPYREFERENCE", "");
String xml = "..."; // contains Email, Password, TokenId etc
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = false;
envelope.implicitTypes = true;
envelope.setOutputSoapObject(request1);
/***************
* Https service means pls uncomment the SSLConnection.allowAllSSL
******************/
SSLConnection.allowAllSSL();
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL, 150000);
androidHttpTransport.debug = true;
androidHttpTransport.setXmlVersionTag("");
SoapObject response = null;
try {
List headerList = new ArrayList();
headerList.add(new HeaderProperty("Authorization",
"Basic " + org.kobjects.base64.Base64.encode("yugeshm:welcome02".getBytes())));
headerList.add(new HeaderProperty("Content-Type", "text/xml"));
headerList.add(new HeaderProperty("Accept", "application/soap+xml"));
androidHttpTransport.call(SOAPACTION, envelope, headerList);
response = (SoapObject) envelope.bodyIn;
resultString_LeaveDetails = androidHttpTransport.responseDump;
} catch (Exception e) {
e.printStackTrace();
}
return response.toString();
}
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
responseDialog.dismiss();
Log.w("Output result: ", result);
}
}
 
 
 
 
 
 
 
 
 

Attachment: Android_Code.zip

Answers (2)