为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

android webservice又一个方法

2018-09-11 3页 doc 47KB 18阅读

用户头像

is_451943

暂无简介

举报
android webservice又一个方法SOAP in Android Like many other Android developers I came to the same problem – parsing SOAP in Android. My short instruction how to do this… 1. download ksoap2 sourse files – ksoap2-src-2.1.1.zip (http://sourceforge.net/project/showfiles.php?group_id=158028&packag...
android webservice又一个方法
SOAP in Android Like many other Android developers I came to the same problem – parsing SOAP in Android. My short instruction how to do this… 1. download ksoap2 sourse files – ksoap2-src-2.1.1.zip (http://sourceforge.net/project/showfiles.php?group_id=158028&package_id=176860) 2. download kxml2 source files – kxml2-src-2.3.0.zip (http://sourceforge.net/project/showfiles.php?group_id=9157&package_id=58653) 3. put in your source folder: ksoap2-src-2.1.1.zip /src/org/ksoap2/ /src_j2se/org/ksoap2/ kxml2-src-2.3.0.zip /src/org/kxml2/ take missed kObjects files from here:http://kobjects.cvs.sourceforge.net/viewvc/kobjects/kobjects/src/org/kobjects/ /org/kobjects/base64/Base64.java /org/kobjects/isodate/IsoDate.java Download 4. Use simple code to connect the server 5. private static final String SOAP_ACTION = "myMethod"; 6. private static final String METHOD_NAME = "myMethod"; 7. private static final String NAMESPACE = "http://mynamespace.com/"; 8. private static final String URL = "http://myserver.com/bean"; 9.   10. void test() { 11. try { 12. SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 13. request.addProperty("prop1", "myprop"); 14.   15. SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 16. envelope.setOutputSoapObject(request); 17. HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 18. androidHttpTransport.call(SOAP_ACTION, envelope); 19.   20. Object result = envelope.getResponse(); 21.   22. //handle result here 23.   24. myExampleHandler.getResults(); 25. } catch (Exception e) { 26. e.printStackTrace(); 27. } } March 1st, 2009 in xml | tags: android, kobjects, ksoap2, kxml2, xml Comments (10) PiwaïMarch 3rd, 2009 at 5:54 pm I am trying to do exactly the same things, so I would like to thank you for posting this. By the way, could you also give an example of ParserHandler (the ContentHandler implementation) ? I am going to search Google, but I think it might be usefull for the next visitors  . villain_dmMarch 3rd, 2009 at 6:18 pm ParserHandler extends DefaultHandler-) I think this is a part of regular SAX parser tutorials like this: http://www.anddev.org/parsing_xml_from_the_net_-_using_the_saxparser-t353.html PiwaïMarch 3rd, 2009 at 6:54 pm Thanks for answering so fast. I will have a look at that. Anyway, even without parsing the response, everything works fine (using result.toString() ). So thanks a lot for that ! One more thing for visitors : if you use local webservices while developping, don’t put localhost or 127.0.0.1 in the url, since it will be the localhost of the Emulator, not the one of your computer. You should put your network IP instead (like 192.168.10.10). villain_dmMarch 3rd, 2009 at 8:06 pm well… actually I didn’t do any research in parsing response-) I replaced soap to the simple XML. result.toString() will be something like anyType{name=value; …}… SAX parser won’t help in this case:) please see ksoap2 tutorial how to handle this:http://google.com/codesearch/p?hl=en#fNok_iy2ojk/samples/org/ksoap2/samples/amazon/search/AmazonSearchClient.java PiwaïMarch 12th, 2009 at 7:39 pm Just wanted to give some more feedback : Android does not currently works fine with HTTPS and some Certificate Authorities, probably due to a lack of implementation of some algorithms. If you happen to encounter the following IOException : “Hostname was not verified”, here is the crappy patch I found : in org.ksoap2.transport.ServiceConnectionSE, I added the following code on line 50 (after “connection.setUseCaches(false);” in the constructor) : if (connection instanceof HttpsURLConnection) { ((HttpsURLConnection) connection) .setHostnameVerifier(new AllowAllHostnameVerifier()); } THIS IS A TEMPORARY AND BAD SOLUTION, since CA are not any more verified. aliciaApril 11th, 2009 at 9:39 am I tried to use your code, and I did not change anything except namespace, url etc. but it didn’t work. I tried to debug and every this call : androidHttpTransport.call(SOAP_ACTION, envelope); I get an unknown error, and fall catch block. I try to connect a dotnet web service, please help me if you know something.. Below is my func. names etc.. private static final String SOAP_ACTION = “http://tempuri.org/AddIntegers”; private static final String METHOD_NAME = “AddIntegers”; private static final String NAMESPACE = “http://tempuri.org/”; private static final String URL = “http://127.0.0.1:1416/WebServiceTest/Service.asmx”; MichaelMay 5th, 2009 at 3:55 pm thank you, i tried to get ksoap working the whole last week….and with your tutorial it worked in a few minutes… good job! Adam GainesJune 17th, 2009 at 4:39 am For some reason no matter what I do I get the following error: detailMessage “expected: END_TAG {http://schemas.xmlsoap.org/soap/envelope/}Body (position:END_TAG @1:375 in java.io.InputStreamReader@4377f160) ” (id=830060642608) MikeJuly 3rd, 2009 at 10:13 pm Thanks and i like the blog image headers eheh RTNSeptember 17th, 2009 at 4:14 pm Hi MAte, I am new to android platform and not sure which one is SOAP_ACTION, NAMESPACE AND URL. I have blow pasted my WSDL please have a look and tell me which one they are. thanks http://jax-ws.dev.java.net. RI’s version is JAX-WS RI 2.1.3.1-hudson-417-SNAPSHOT. –> http://jax-ws.dev.java.net. RI’s version is JAX-WS RI 2.1.3.1-hudson-417-SNAPSHOT. –>
/
本文档为【android webservice又一个方法】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索