开发者

How to use web service in J2ME application?

开发者_如何转开发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


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

How to use web service in J2ME application?

  • Read More
  • Here is a quick youtube tutorial


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜