I have a service activated in SAP ECC 6.0 which i am successfully able to test from SOAP UI 5 which generates following SOAP REQUEST
Request Generated by SOAPUI 5.0 Working Successfully
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:glob="http://sap.com/xi/SAPGlobal20/Global">
<soapenv:Header/>
<soapenv:Body>
<glob:PurchaseOrderItemByAccountAssignmentQuery_sync>
<PurchaseOrderItemSelectionByAccountAssignment>
<PurchaseOrderItemAccountAssignmentCostCentreID schemeID="?" schemeAgencyID="?">15001030000600</PurchaseOrderItemAccountAssignmentCostCentreID>
</PurchaseOrderItemSelectionByAccountAssignment>
</glob:PurchaseOrderItemByAccountAssignmentQuery_sync>
</soapenv:Body>
</soapenv:Envelope>
However when i call this service from KSOAP2 API using following code i am not able to get correct response instead i get element missing error.
Code (android based) generating faulty request
private static final String NAMESPACE = "http://sap.com/xi/SAPGlobal20/Global";
private static String URL = "http://sapqas.trkl.com:8000/sap/bc/srt/xip/sap/ecc_purchaseorder003qr/330/abcdef/abcdef_binding";
private static final String METHOD_NAME = "PurchaseOrderItemByAccountAssignmentQuery_sync";
private static final String SOAP_ACTION = "";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo propInfo = new PropertyInfo();
propInfo.setName("PurchaseOrderItemAccountAssignmentCostCentreID");
propInfo.setType(String.class);
propInfo.setValue("15001030000600");
request.addProperty(propInfo);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.implicitTypes = true;
envelope.setOutputSoapObject(request);
androidHttpTransport.debug = true;
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
List <HeaderProperty> headerPropertyList = new ArrayList<HeaderProperty>();
headerPropertyList.add(new HeaderProperty("Authorization", "Basic bsadasdWxpsadasdZmNAsadaNA=="));
envelope.encodingStyle = SoapSerializationEnvelope.ENC;
try {
androidHttpTransport.call(SOAP_ACTION, envelope,headerPropertyList);
SoapObject response = (SoapObject) envelope.getResponse();
} catch (SoapFault e) {
Toast.makeText(MainlayoutActivity.this,
e.faultcode + " Error : 0" + e.getMessage(), Toast.LENGTH_LONG)
.show();
e.printStackTrace();
} catch (HttpResponseException e) {
// TODO Auto-generated catch block
Toast.makeText(MainlayoutActivity.this,
e.getStatusCode() + " Error : 1" + e.getMessage(),
Toast.LENGTH_LONG).show();
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
Toast.makeText(MainlayoutActivity.this,
"Error : 2" + e.getMessage(), Toast.LENGTH_LONG).show();
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
Toast.makeText(MainlayoutActivity.this,
e.getLineNumber() + "Error : 3" + e.getMessage(),
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
catch (Exception e) {
Toast.makeText(MainlayoutActivity.this,
"Error : 4" + e.toString(), Toast.LENGTH_LONG).show();
}
The soap request generated by my code is below which has an element missing but i am not sure how to add it to my request using KSOAP2 API.
Request created by Above Code
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
<n0:PurchaseOrderItemByAccountAssignmentQuery_sync id="o0" c:root="1" xmlns:n0="http://sap.com/xi/SAPGlobal20/Global">
<PurchaseOrderItemAccountAssignmentCostCentreID>15001030000600</PurchaseOrderItemAccountAssignmentCostCentreID>
</n0:PurchaseOrderItemByAccountAssignmentQuery_sync>
</v:Body>
</v:Envelope>
Error from Web Service: (CX_ST_GROUP_MISSING_CASE)
Required
I want to add tag from first request to be added in my soap request but not able to do so.
Additional Information:
below "PurchaseOrderItemSelectionByAccountAssignment" tag there could be multiple parameters but i am only using "PurchaseOrderItemAccountAssignmentCostCentreID" parameter.
Anyone has idea where i am going wrong and how to change it to create right soap request?
regards,
My problem has been resolved using the kvmserialization interface implementation as discussed in the link below.
This was essentially a case of implementing complex types.
Lesson Learnt : if you face an issue creating / parsing soap request or response please map your WSDL and its contents with the KSOAP API you shall find an answer after doing some research.