如果你不想使用KSOAP,您可以使用HttpURLConnection類和InputStream的
HttpURLConnection my_httpConnection = (HttpURLConnection) new URL("https://integrator-ut.vegaconnection.com/Authentication.svc?wsdl").openConnection();
my_httpConnection.setRequestMethod("POST");
my_httpConnection.setDoInput(true);
my_httpConnection.setDoOutput(true);
my_httpConnection.setRequestProperty("Content-type", "text/xml; charset=utf-8");
OutputStream my_outPutStream = this.my_httpConnection.getOutputStream();
Writer my_writer = new OutputStreamWriter(my_outPutStream);
my_writer.write(YOUR_REQUEST); //YOUR_REQUEST is a String
my_writer.flush();
my_writer.close();
BufferedReader my_bufferReader = new BufferedReader(new InputStreamReader(this.my_httpConnection.getInputStream()));
char[] buffer = new char[10000];
int nbCharRead=0;
try
{
while((nbCharRead = my_bufferReader.read(buffer, 0, 10000)) != -1)
{
/* Your treatement : saving on a file/arraylist/etc
}
}
你必須使字符串YOUR_REQUEST基於要恢復
值
它看起來就像
<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" ... >
<soapenv:Header/>
<soapenv:Body>
...
</soapenv:Body>
</soapenv:Envelope>
[的WebMethod] public string Login(string userName,string pwd) { string msg = string.Empty; 嘗試 { Authentication.Authentication auth = new Authentication.Authentication(); Authentication.LoginToken login = auth.CreateToken(userName,pwd); msg =「登錄成功」; (例外ex) { msg = ex.Message; } return msg; } – jalakam
你正在使用哪種工具進行Web服務方法(如ksaop)? – naresh
實際上基於那個WSDL URL我想出來createToke方法... – jalakam