2016-12-13 80 views
0

這裏是我的SOAP Web服務的,我需要得到TxRefNum結構庫解析SOAP Web服務:遇到問題使用kso​​ap2

<?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> 

我使用kso​​ap2庫來分析以下數據,但我無法找到適當的解決方案。下面是我在做什麼:

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

嘗試這樣的:

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(); 
} 
+0

怎麼樣的網址是什麼? –

+0

哪個網址? url用於發出請求並獲得響應。 –

相關問題