以下是我需要获取 TxRefNum 的SOAP Web服务的结构:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tem="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header/>
<soap:Body>
<tem:MakeCreditCardPayment>
<tem:objCreditCardBookingPaymentRow>
<tem:ProfessionalUserMappingStudioID>18</tem:ProfessionalUserMappingStudioID>
<tem:ConsumerUserMappingStudioID>5</tem:ConsumerUserMappingStudioID>
<tem:Cost>5</tem:Cost>
<tem:CardNumber>4111111111111111</tem:CardNumber>
<tem:CardHolderName>Shyam</tem:CardHolderName>
<tem:ExpirationDate>042020</tem:ExpirationDate>
<tem:CVV>123</tem:CVV>
<tem:ProfessionalSessionID>320</tem:ProfessionalSessionID>
<tem:TxRefNum></tem:TxRefNum>
</tem:objCreditCardBookingPaymentRow>
</tem:MakeCreditCardPayment>
</soap:Body>
</soap:Envelope>
我正在使用ksoap2库来解析以下数据,但无法找到适当的解决方案。这就是我在做的事情:
final String NAMESPACE = "http://tempuri.org/";
final String URL = NewURLs.BASE_URL + "api/PaymentService.asmx";
final String SOAP_ACTION = "http://tempuri.org/MakeCreditCardPayment";
final String METHOD_NAME = "MakeCreditCardPayment";
final String INNER_METHOD_NAME = "tem:objCreditCardBookingPaymentRow";
// the above parameter can be taken from the users web service
// (?WSDL)
// url
SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME);
SoapObject innerRequest = new SoapObject(NAMESPACE,INNER_METHOD_NAME);
innerRequest.addProperty("tem:ProfessionalUserMappingStudioID", bookingDetailsList.get(0).getUserMappingStudioID());
innerRequest.addProperty("tem:ConsumerUserMappingStudioID",loginCredentials.getUserMappingStudioId());
innerRequest.addProperty("tem:Cost",bookingDetailsList.get(0).getCost());
innerRequest.addProperty("tem:CardNumber", creditCardNo);
innerRequest.addProperty("tem:CardHolderName", creditCardHolder);
innerRequest.addProperty("tem:ExpirationDate", expirationDate);
innerRequest.addProperty("tem:CVV", cvv);
innerRequest.addProperty("tem:ProfessionalSessionID",bookingDetailsList.get(0).getProfessionalSessionID());
innerRequest.addProperty("tem:TxRefNum", "");
request.addProperty("tem:objCreditCardBookingPaymentRow",innerRequest);
utils.sysOut("some text", "" + request);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
String str = resultsRequestSOAP.toString();
Log.v("TAG_SOAP_ACTION", str);
答案 0 :(得分:0)
试试这样:
SoapObject res=(SoapObject)envelope.bodyIn;
SoapObject t=(SoapObject)res.getProperty("MakeCreditCardPayment");
for(int i=0; i<t.getPropertyCount(); i++){
SoapObject carditCard=(SoapObject)t.getProperty(i);
String userID = carditCard.getProperty("ProfessionalUserMappingStudioID").toString();
}