ksoap and .net

M

Marcin Sulecki

Hello!
I've problem with call XML Web Services (.NET Framework) from middlet with
library ksoap1. After call method call() I haven't any response or error
message.
What am I doing wrong?

XML Web Services C#/ASP.NET code:

[System.Web.Services.Protocols.SoapRpcService]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
[System.Web.Services.Protocols.SoapRpcMethod]
public string HelloWorld()
{
return "Hello World";
}
}

Client code (java/j2me/ksoap1):

HttpTransport transport = null;
SoapObject soap = new SoapObject("http://tempuri.org","HelloWorld");

transport = new HttpTransport();
transport.setUrl("http://localhost/WSHello/Service1.asmx");
transport.setSoapAction("http://tempuri.org/HelloWorld");
transport.debug = true;

try
{
transport.call(soap); // <----- this
}

catch(Exception ex)
{
System.out.println(ex);
}
 
T

trent

Hi there

I managed to get this going. The .NET XML Web Service is the same as yours

regards

Trent

/*
* SOAPMIDlet.java
*
* Created on 18 February 2004, 14:13
*/

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import org.ksoap.*;
import org.kxml.*;
import org.ksoap.transport.*;


public class SOAPMIDlet extends MIDlet implements CommandListener {

private Command exitCommand; // The exit command
private Command connectCommand;
private Display display; // The display for this MIDlet
private Form mainForm;

public SOAPMIDlet() {
display = Display.getDisplay(this);
exitCommand = new Command("Exit", Command.SCREEN, 2);
connectCommand = new Command("Connect", Command.SCREEN, 3);
mainForm = new Form ("SOAP calls");
}

/**
* Start up the Hello MIDlet by creating the TextBox and associating
* the exit command and listener.
*/
public void startApp() {

mainForm.addCommand(exitCommand);
mainForm.addCommand(connectCommand);

mainForm.setCommandListener(this);
display.setCurrent(mainForm);
}

/**
* Pause is a no-op since there are no background activities or
* record stores that need to be closed.
*/
public void pauseApp() {
}

/**
* Destroy must cleanup everything not handled by the garbage collector.
* In this case there is nothing to cleanup.
*/
public void destroyApp(boolean unconditional) {
}

/*
* Respond to commands, including exit
* On the exit command, cleanup and notify that the MIDlet has been destroyed.
*/
public void commandAction(Command c, Displayable s) {
if (c == exitCommand)
{
destroyApp(false);
notifyDestroyed();
}
if (c == connectCommand)
{
try {
HttpTransport transport = null;
SoapObject soap = new SoapObject("http://tempuri.org","HelloWorld");

transport = new HttpTransport();
transport.setUrl("http://localhost/WSHello/Service1.asmx");
transport.setSoapAction("http://tempuri.org/HelloWorld");
transport.debug = true;
java.lang.Object o = transport.call(soap); // <----- this
StringItem item = new StringItem("SOAP result", o.toString());
mainForm.append(item);
display.setCurrent(mainForm);

}
catch (Exception e) {
e.printStackTrace ();
}
}
}


}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top