我在SAP ECC 6.0中激活了一项服务,我可以成功地从SOAP UI 5进行测试,生成以下SOAP REQUEST
SOAPUI 5.0生成的请求成功运行
<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>
然而,当我使用以下代码从KSOAP2 API调用此服务时,我无法获得正确的响应,而是会出现元素缺失错误。
代码(基于android)生成错误请求
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();
}
我的代码生成的soap请求下面有一个元素缺失,但我不知道如何使用KSOAP2 API将其添加到我的请求中。
以上代码创建的请求
<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)
必需
我想在第一个请求中添加标记,以便在我的soap请求中添加但不能这样做。
其他信息:
以下&#34; PurchaseOrderItemSelectionByAccountAssignment&#34;标签可能有多个参数,但我只使用&#34; PurchaseOrderItemAccountAssignmentCostCentreID&#34;参数。
任何人都知道我哪里出错了,以及如何更改它以创建正确的肥皂请求?
的问候,
答案 0 :(得分:0)
我的问题已使用kvmserialization接口实现解决,如下面的链接所述。
这实际上是实现复杂类型的一种情况。
经验教训:如果您在创建/解析soap请求或响应时遇到问题,请使用KSOAP API映射您的WSDL及其内容,您可以在进行一些研究后找到答案。