Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

calling .Net web Service by J2ME

Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've problem configuring the correct HttpTransport to call my .net Web Service. Could anyone help me ?? Please?
I think there is a mistake in in my new HttpProtocol("","") constructor invocation.
Thanx, Thanx in advance!!

this is my web service:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

namespace WS
/// <summary>
/// Descrizione di riepilogo per Service1.
/// </summary>
public class Service1 : System.Web.Services.WebService
public Service1()
//CODEGEN: chiamata richiesta da Progettazione servizi Web ASP.NET.
#region Component Designer generated code

//Richiesto da Progettazione servizi Web
private IContainer components = null;

/// <summary>
/// Metodo necessario per il supporto della finestra di progettazione. Non modificare
/// il contenuto del metodo con l'editor di codice.
/// </summary>
private void InitializeComponent()
/// <summary>
/// Pulire le risorse in uso.
/// </summary>
protected override void Dispose( bool disposing )
if(disposing && components != null)

// Il servizio di esempio HelloWorld() restituisce la stringa Hello World.
// Per generare, rimuovere i commenti dalle righe seguenti, quindi salvare e generare il progetto.
// Per verificare il servizio Web, premere F5.
public string sayHello()
return "Hello World";
and this is my simplest J2me code:

import java.lang.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import org.ksoap.*;
import org.ksoap.transport.*;
public class mio extends MIDlet implements
CommandListener, Runnable {
Form mainForm = new Form ("StockQuotes");
TextField symbolField = new TextField ("Symbol", "", 5,
StringItem resultItem = new StringItem ("", "");
Command getCommand = new Command ("Get", Command.SCREEN, 1);
public mio () {
mainForm.append (symbolField);
mainForm.append (resultItem);
mainForm.addCommand (getCommand);
mainForm.setCommandListener (this);
public void startApp () {
Display.getDisplay (this).setCurrent (mainForm);
public void pauseApp () {
public void destroyApp (boolean unconditional) {
public void commandAction (Command c, Displayable d) {

Thread th= new Thread(this);
public void run(){

try {
// Build request string
String symbol = symbolField.getString ();
resultItem.setLabel (symbol);
// Create a SoapObject by specifying the URN and themethod name
// of the SOAP RPC Web Service.
SoapObject rpc = new SoapObject
("http://localhost/WS/Service1.asmx", "sayHello");
// The addProperty method allows you to specify parametersto for
// the method used.
// rpc.addProperty ("symbol", symbol);
// The HttpTransport class can be used to make the actualcall.
// Its constructor accepts the Web Service endpoint as well as
// the method to be called.

resultItem.setText (""+new HttpTransport
"urn:Hello#sayHello").call (rpc));
catch (Exception e) {
e.printStackTrace ();
resultItem.setLabel ("Error:");
resultItem.setText (e.toString ());


public static void main (String [] argv) {
new mio ().startApp ();
and this is the soap request that my web service ask:
POST /WS/Service1.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "urn:Hello/sayHello"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:soap="">
<sayHello xmlns="urn:Hello" />
Posts: 1436
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I recall kSOAP v1.0 requires the SOAP server to explicitly encode the type. For example, you need:

But .NET servers often givens literal SOAP messages with "default" types like this one:

I believe kSOAP v2 has a "dotnet" tag in its deserialize class and it is supposed to fix that problem.
I'm thinking about a new battle cry. Maybe "Not in the face! Not in the face!" Any thoughts tiny ad?
Free, earth friendly heat - from the CodeRanch trailboss
    Bookmark Topic Watch Topic
  • New Topic