如何解决如何在Android中访问SOAP Web服务
| 我尝试使用httpPost访问soap Ws;这是我的代码 HttpPost httpPost=new HttpPost(WebService Url);
httpPost.addHeader(\"Content-Type\",\"application/soap+xml; charset=utf-8\");
httpPost.addHeader(\"Host\",HostName);
//get from the getflashinfo method;
String soapRequestXml=getFlashInfo(0);
Log.d(\"Message12\",soapRequestXml);
try
{
StringEntity se=new StringEntity(soapRequestXml,HTTP.UTF_8);
se.setContentType(\"text/xml\");
httpPost.setEntity(se);
HttpClient hC=new DefaultHttpClient();
HttpResponse reponse=hC.execute(httpPost);
Log.d(\"Message12\",response.toString());
}
catch (ClientProtocolException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
第二功能
String getFlashInfo(int target)
{
String sHeaderRequest=\"<s:Envelope xmlns:s=\\\"http://www.w3.org/2003/05/soap-envelope\\\" xmlns:a=\\\"http://www.w3.org/2005/08/addressing\\\">\"+
\"<s:Header>\" +
\"<a:Action s:mustUnderstand=\\\"1\\\">http://tempuri.org/IFlashInfoService/GetFlashInfo</a:Action>\" +
\"<a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo>\" +
\"<a:To s:mustUnderstand=\\\"1\\\">URL</a:To>\" +
\"</s:Header>\" +
\"<s:Body xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\" xmlns:xsd=\\\"http://www.w3.org/2001/XMLSchema\\\">\" +
\"<GetIdTargetRequest xmlns=\\\"http://tempuri.org/\\\">\" ;
String sHeaderRequest1;
if (target > 0)
{
sHeaderRequest1=\"<IdTarget>\"+\" \"+target+\" \"
+\"</IdTarget>\";
}
else
{
sHeaderRequest1=\"<IdTarget>0</IdTarget>\";
}
sHeaderRequest=sHeaderRequest+sHeaderRequest1;
sHeaderRequest=sHeaderRequest+\"</GetIdTargetRequest>\";
sHeaderRequest=sHeaderRequest+\"</s:Body>\";
sHeaderRequest=sHeaderRequest+\"</s:Envelope>\";
Log.d(\"Message12\",sHeaderRequest);
return sHeaderRequest;
}
尝试记录响应消息时出现Null Pointer异常
我用Ksop库
got some kind of xmlparse error and unknown source exception
请帮我
问候,
卡里亚尚
解决方法
我正在发布视频教程,这可能会有所帮助
http://www.vimeo.com/9633556
编码愉快!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。