[英]customization of ksoap2-android envelope
我對使用ksoap2-android lib中的SoapSerializationEnvelope創建的信封有問題。 我需要得到的(服務器期望的)是:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soa="http://agh.edu.pl/soa">
<soapenv:Header/>
<soapenv:Body>
<soa:getCompanyById>
<id>1</id>
</soa:getCompanyById>
</soapenv:Body>
</soapenv:Envelope>
我實際上得到的是:
<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:getCompanyById id="o0" c:root="1" xmlns:n0="http://agh.edu.pl/soa">
<id i:type="d:int">5</id>
</n0:getCompanyById>
</v:Body>
</v:Envelope>
我的Java代碼:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo id = new PropertyInfo();
id.setName("id");
id.setValue(5);
id.setType(int.class);
request.addProperty(id);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(URL);
httpTransport.debug = true;
try {
httpTransport.call(request.getNamespace() + "/" + request.getName(), envelope);
} catch (Exception e)
{
System.out.println(httpTransport.requestDump);
System.out.println(httpTransport.responseDump);
System.out.println(e.getMessage());
}
我需要做的是將每個v:something更改為soapenv:something,將n0:getCompanyById更改為soa:getCompanyById。 任何想法? 提前致謝。 ya
這些信封幾乎是相同的-它們只是使用不同的前綴。 我建議使用SoapUI之類的工具:逐步,將工作信封更改為從代碼中獲得的內容。 一旦情況惡化,您就會知道導致問題的原因。
根據我的經驗,i:type =“ d:int”也可能會導致問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.