2
Answers

Pass multiple parameters to SAP SOAP webservice?

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)
0
durai venkatesh

durai venkatesh

NA 4 291 7y
Hi Krishna,
 
Thank you for the reply. I checkd the 2nd link but it is explaining about passing single parameter like Purchase order, Username and Password but i would like to pass the structure to SAP webservice. Please could you suggest how to pass the structure(highlighted in red which is structure) from android to SAP. Please be noted that single parameter(Highlighted in green) is passing correctly.
 
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", "");
 
 
Thanks,
Durai. 
0
Krishna Rajput Singh

Krishna Rajput Singh

NA 5.5k 2m 7y
Hi durai thank you for writing below links helpful for you.
 
https://blogs.sap.com/2014/08/25/part-2-connecting-soap-web-services-with-integration-gateway-in-smp3/
 
https://archive.sap.com/discussions/thread/1870354