[英]Problem with Ksoap2 response
Hey all, i'm having a little problem with ksoap2 and getting response i have the following code on Blackberry client side: 嘿所有,我对ksoap2有一点问题并得到回复我在Blackberry客户端有以下代码:
private boolean AddVoiceNote()
{
_webMethod = "AddVoiceNote";
_soapAction.concat(_webMethod);
Boolean response = null;
SoapObject methodCall = new SoapObject(_serviceNameSpace, _webMethod);
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.bodyOut = methodCall;
soapEnvelope.dotNet = false;
soapEnvelope.encodingStyle = SoapSerializationEnvelope.XSD;
soapEnvelope.setOutputSoapObject(methodCall);
methodCall.addProperty("name", _voiceNote.get_nombre());
methodCall.addProperty("comment", _voiceNote.get_comentario());
methodCall.addProperty("audio", Base64.encode(_voiceNote.get_audioArray()));
methodCall.addProperty("id", String.valueOf(_voiceNote.get_userId()));
methodCall.addProperty("postTwitter", String.valueOf(_voiceNote.is_twitterPost()));
methodCall.addProperty("postFacebook", String.valueOf(_voiceNote.is_facebookPost()));
HttpTransport transport = new HttpTransport(_serviceURL);
transport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
try {
transport.call(_soapAction, soapEnvelope);
SoapObject responseSoap = (SoapObject)soapEnvelope.getResponse();
response = (Boolean)responseSoap.getProperty("return");
System.out.println(responseSoap.toString());
return response.booleanValue();
} catch (IOException e) {
return false;
} catch (XmlPullParserException e) {
return false;
}
}
And this is the web method it is calling: 这是它调用的Web方法:
@WebMethod(operationName = "AddVoiceNote")
public Boolean AddVoiceNote(
@WebParam(name = "name")String name,
@WebParam(name = "comment")String comment,
@WebParam(name = "audio")String audio,
@WebParam(name = "id")String id,
@WebParam(name = "postTwitter")String postTwitter,
@WebParam(name = "postFacebook")String postFacebook)
{
VoiceNote voiceNote = new VoiceNote();
VoiceNoteMananger voiceNoteManager = new VoiceNoteMananger();
voiceNote.setComentario(comment);
voiceNote.setNombre(name);
voiceNote.setIdUser(Long.parseLong(id));
voiceNote.setFacebookPost(Boolean.getBoolean(postFacebook));
voiceNote.setTwitterPost(Boolean.parseBoolean(postTwitter));
voiceNote.setTrack(audio.getBytes());
return voiceNoteManager.addVoiceNote(voiceNote);
}
The problem i'm having is properly getting the response, i get a ClassCastException when trying to get it and the debugger just exits the method, any idea how I can fix this? 我遇到的问题是正确得到响应,我在尝试获取它时得到ClassCastException并且调试器只是退出方法,任何想法如何解决这个问题? Oh also here's the response xml I get from my Web Method: 哦,这也是我从Web方法得到的响应xml:
<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body><ns2:AddVoiceNoteResponse xmlns:ns2="http://WebService/">
<return>true</return></ns2:AddVoiceNoteResponse>
</S:Body>
</S:Envelope>
Sorry, I don't have the privilege to write comments, otherwise I would not post an answer for this little hint... 对不起,我没有权利写评论,否则我不会发布这个小提示的答案......
Actually, the envelope has got a method "stringToBoolean". 实际上,信封有一个方法“stringToBoolean”。 Here's a link to the method in the API. 这是API中方法的链接。
Greetings 问候
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.