嗨,我有一個代碼生成一個簡單的請求,我需要建立一個像一個請求,例如SOAP服務器:ksoap2 v prefixo任何其他前綴
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://10.1.5.80:8080/">
<soapenv:Header/>
<soapenv:Body>
<ns:GETSERVERTIME/>
</soapenv:Body>
</soapenv:Envelope>
,但我得到
<v:Envelope
xmlns:i="http://www.w3.org/1999/XMLSchema-instance"
xmlns:d="http://www.w3.org/1999/XMLSchema"
xmlns:c="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
<n0:GETSERVERTIME xmlns:n0="http://localhost:8080/" />
</v:Body>
</v:Envelope>
我只需要改變 「v」 到 「soapenv:」
我的代碼:
/**
* Created by Vinicius Gati on 30/12/14.
*
*/
public class ServerSOAP {
private static final String METHOD_NAME = "GETSERVERTIME";
private static final String NAMESPACE = "http://localhost:8080/";
private static final String SOAP_ACTION = "";
private static final String URL = "http://10.1.5.80:8080/ws/SERVERTIME.apw?WSDL";
public static String getServerTime() {
String retorno = "";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);
envelope.implicitTypes = false;
envelope.setAddAdornments(false);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
try {
androidHttpTransport.call(NAMESPACE + METHOD_NAME, envelope);
SoapObject response = (SoapObject) envelope.getResponse();
} catch (Exception e) {
e.printStackTrace();
}
return retorno;
}
}
但我瘋了試試這個,沒成功。
是的,我知道,這應該工作,但遺憾的是,從我們使用不使用v前綴工作ERP SOAP協議..我花了好幾個小時才發現...謝謝我會嘗試解決方案。 –