RE: Problem with ksoap and .Net

[email protected] Thu, 25 Mar 2004 16:36:00 +0000 (WET)
Newsgroups gmane.comp.java.enhydra.ksoap
Message-ID <[email protected]>
Thanks a lot man. That did the trick.

I spend 4 days messing around with my j2me code but the problem was in the C# 
server.

Thanks one more time.

Regards, 

../Nuno Alexandre




> First off, if you are using c#, *I* have found your webservice will play
> *much* nicer if you add this above your method declaration:
> 
> [WebMethod]
> [System.Web.Services.Protocols.SoapRpcMethod]
> public *return type* *function name* (*param list*)
> 
> I will read this email in more detail when I get home later, and if I
> see anything wrong with the code will reply to the group.
> 
> Regards,
> 
> Steve
> 
> 
> 
> 
> -----Original Message-----
> From: [email protected] [mailto:[email protected]]
> Sent: Wednesday, March 24, 2004 12:37 PM
> To: [email protected]
> Subject: Ksoap: Problem with ksoap and .Net
> 
> 
> 
> I'm new to ksoap so I tried to use the StockQuoteDemo to my way.
> 
> 
> My problem is that I can connect to the WebService that I created but I
> can't 
> get to pass parameters to the methods.
> 
> For example when I try to send something to the "Test" (like "teste")
> method I 
> get for response the string " sssss   ss" but the result I was hoping
> for was 
> " sssss   ssteste".
> 
> If someone can help me...
> 
> Thanks in advance.
> 
> This is my java code:
> 
> 
> import javax.microedition.midlet.*;
> import javax.microedition.lcdui.*;
> import java.io.*;
> import javax.microedition.io.*;
> 
> import org.ksoap2.*;
> import org.ksoap2.serialization.*;
> import org.ksoap2.transport.*;
> 
> public class StockQuoteDemo2 extends MIDlet implements CommandListener {
> 
>     Form mainForm = new Form("DF");
>     TextField symbolField = new TextField("Symbol", "IBM", 5,
> TextField.ANY);
>     StringItem resultItem = new StringItem("", "");
>     Command getCommand = new Command("Get", Command.SCREEN, 1);
> 
>     public StockQuoteDemo2() {
>         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) {
>         try {
>             // build request string
>             String symbol = symbolField.getString();
>  
> 
>             //SoapObject rpc = new
> SoapObject("http://tempuri.org/","Test");
>                 
>               SoapObject rpc = new SoapObject("","Test");   
>           rpc.addProperty("a","teste");
> 
> 		
>             SoapSerializationEnvelope envelope =
>                 new SoapSerializationEnvelope(SoapEnvelope.VER11);
> 		
> 
>             envelope.bodyOut = rpc;
>            
> 
>             resultItem.setLabel(symbol);
> 
>             HttpTransport ht = new
> HttpTransport("http://localhost:8080/NewFile.
> asmx");
>              ht.debug = true;
>              
>              try {
>              	System.out.println("Vai tentar ligar");
>              
>                 ht.call("http://tempuri.org/Test",envelope);
>                 System.out.println(envelope.bodyIn.toString());
>                 
>                 System.out.println(envelope.toString());
>                 System.err.println (ht.requestDump);  
>                 System.err.println (ht.responseDump);  
>               
>              }
>              catch (Exception e) {
>                 e.printStackTrace();
>                 System.err.println (ht.requestDump);  
>                 System.err.println (ht.responseDump);  
>              }
> 
>             resultItem.setText("" + envelope.getResult());
> 
>         }
>         catch (Exception e) {
>             e.printStackTrace();
>             resultItem.setLabel("Error:");
>             resultItem.setText(e.toString());
>         }
>     }
> 
>     /** for me4se */
> 
>     public static void main(String[] argv) {
>         new StockQuoteDemo2().startApp();
>     }
> }
> 
> 
> 
> And this is my C# webservice : NewFile.asmx
> 
> 
> <%@ WebService language="C#" class="teste" %>
> 
> using System;
> using System.Web.Services;
> using System.Xml.Serialization;
> 
> 
> 
> public class teste{
> 
>     [WebMethod]
>     public string Add(string param1, string param2) {
>         return " cdfs  "+param1;
>     }
> 
>     [WebMethod]
>     public string Sub(string a, string b) {
> 
> 
>         return "testes"+a+b;
>     }
> 
>     [WebMethod]
>     public string Test(string a)
>     {
>         return " sssss   ss"+a;
>     }
> }
>  
> 
> 
> 
> _______________________________________________
> Ksoap mailing list
> [email protected]
> http://www.enhydra.org/mailman/listinfo.cgi/ksoap
> 
> _______________________________________________
> Ksoap mailing list
> [email protected]
> http://www.enhydra.org/mailman/listinfo.cgi/ksoap
>