How to use web service in J2ME application?

天大地大妈咪最大 提交于 2019-11-27 03:42:18

问题


Can somebody specify the step for using web services in a J2ME application`

I have downloaded Eclipse (SOA), have included the wsdl file in my code and have prepared web service in visual studio 2008. I want to use a .net web service in my J2ME application.

Thanks


回答1:


You can consume webservices in j2me, following would be the architecture look like,

  • Read More
  • Here is a quick youtube tutorial



回答2:


If your phone does not support JSR172, or you want to target every phone in the market, you still can consume webservices manually. That is to say, you need to create an XML to invoke the service, and parse another one to see the results. This can be a lot of work. There is library called kXML2 that may help you in both task. But when I needed to invoke a webservice from j2me I found to be easier to follow this workflow:
1 - Use visual studio to create a simple client application for that webservice in .Net. So I can be sure the service works as expected without relaying in my j2me client, which is still in development. 2 - Use a tracer like http://simile.mit.edu/wiki/HTTPTracer to spy the connection and see what is really happening between client and server...it's kind of fun.
3 - Duplicate this behavior in my own j2me application ...but trying to keep it simple. As an example, I needed to create an XML like

<SOAP>  
   <data>  
        <id>  
           numericID  
        </id>  
   </data>  
</SOAP>  

Since I knew it was going to be a numeric Id, I just create the XML as a String using a stringbuffer.
4 - Be careful about the String encoding and the http headers. You can compare your generated traffic in j2me with the one the client. You need to replicate the exact behavior



来源:https://stackoverflow.com/questions/4897165/how-to-use-web-service-in-j2me-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!