Hi people
I am trying to connect to web service created in vb.net, through a midlet with KSoap.
My problem is not really connecting and getting a result, but rather setting a property in my midlet..
let me show you my code>
testWebService.java
------------------------------------------------------------------------
package testWebService;
/*
* testWebService.java
*
* Created on 21. november 2004, 19:18
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import javax.microedition.io.*;
import org.ksoap.*;
import org.ksoap.transport.*;
import org.ksoap.SoapObject;
public class testWebService extends MIDlet {
private Display display;
private
String url = "http://myDomain.dk/ws/ws.asmx";
TextBox textBox = null;
private Command cmExit;
public testWebService()
{
display = Display.getDisplay(this);
}
public void startApp() {
try
{
doWebService(url);
}
catch(Exception e)
{
System.out.println("Exception: " + e);
}
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
destroyApp(false);
notifyDestroyed();
}
public void doWebService(String url) throws Exception
{
StringBuffer sb = new StringBuffer();
String name = "Phobos";
TextBox textBox = null;
SoapObject client = new SoapObject(url, "sayHello");
client.addProperty("name", name);
HttpTransport ht = new HttpTransport(url, "http://MyDomain.dk/ws/sayHello");
sb.append("" + ht.call(client));
System.out.println(client.getNamespace());
textBox = new TextBox("Simple Web Service
Test: ", sb.toString(), 1024, 0);
display.setCurrent(textBox);
}
}
-------------------------------------------------------------------------
And the web service ws.asmx>
<%@ WebService language="VB" class="ws" %>
Imports System
Imports System.Web.Services
Imports System.Xml.Serialization
<WebService(Namespace:="http://myDomain.dk/ws/")> Public Class ws
<WebMethod> Public Function sayHello(name As String) As String
Return "hello mr. " & name
End Function
End Class
------------------------------------------------------------------------
When invoking the web service from the midlet I would prefer the result:
"hello mr. Phobos"
But the result is:
"hello mr."
No Phobos!
So my guess is that the addPropery() is not working somehow, most likely a mistake on my behalf, and this is where you, the people, enters the picture.. hopefully you can help me out..
By the way, I have tried to change the name of the property to something else (in midlet code) but this gave no error or nothing.
Thanks in advance!
/soren
[ November 24, 2004: Message edited by: soren eriksen ]