1
我使用從ksoap2-android庫中的SoapSerializationEnvelope創建的信封存在問題。我需要得到(期望的內容服務器)是:ksoap2-android信封的自定義
<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:東西到soapenv:東西和n0:getCompanyById到soa:getCompanyById。任何想法?提前致謝。 Cya
正如你所說,問題是我:type =「d:int」。解決方案是將值轉換爲long:「id.setValue((long)value)」。肥皂是如此遲鈍。我希望創造它的人會在地獄中燃燒。 Thx,你是我的上帝 – pawelo