BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 03-16-2009, 12:32 PM   #21
subashbala
New Member
 
Join Date: Mar 2009
Model: Bold
PIN: N/A
Carrier: Rogers
Posts: 5
Default Problem using ksoap for accessing web services

Please Login to Remove!

Hi,

I m a newbie BB developer trying to use ksoap on BB JDE 4.3 to connect to a web service.

I followed the steps given in this thread.

Downloaded ksoap2-j2me-core-prev-2.1.2.

Placed the above file in C:\BlackBerry JDE 4.3.0\bin.

Preverified the file with command preverify -classpath "C:\BlackBerry JDE 4.3.0\lib\net_rim_api.jar" ksoap2-j2me-core-prev-2.1.2.jar

Added the preverified file ( present in C:\BlackBerry JDE 4.3.0\bin) to my project in BB JDE 4.3 .

Did a build on the code and got the following output

Building Ksoap2
C:\BlackBerry JDE 4.3.0\bin\rapc.exe -quiet import=..\lib\net_rim_api.jar library=HelloWorldFolder\Ksoap2 HelloWorldFolder\Ksoap2.rapc warnkey=0x52424200;0x52525400;0x52435200 "C:\BlackBerry JDE 4.3.0\subash\HelloWorldFolder\Ksoap2Demo.java" "C:\BlackBerry JDE 4.3.0\jar\ksoap2-j2me-core-prev-2.1.2.jar" "C:\BlackBerry JDE 4.3.0\subash\HelloWorldProjectFolder\helloworld_jd e.png"
Note: C:\BlackBerry JDE 4.3.0\subash\HelloWorldFolder\Ksoap2Demo.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\BlackBerry JDE 4.3.0\subash\HelloWorldFolder\Ksoap2Demo.java:117: Warning!: Invocation of questionable method: java.lang.String.<init>(String) found in: HelloWorldFolder.Ksoap2Demo$Ksoap2DemoScreen.obten erListaArticuloSOAP(String)
C:\BlackBerry JDE 4.3.0\subash\HelloWorldFolder\Ksoap2Demo.java:51: Warning!: inner class 'HelloWorldFolder.Ksoap2Demo$Ksoap2DemoScreen' should be declared static
C:\BlackBerry JDE 4.3.0\jar\ksoap2-j2me-core-prev-2.1.2.jar(org/ksoap2/serialization/MarshalHashtable$ItemSoapObject.class):1: Warning!: inner class 'org.ksoap2.serialization.MarshalHashtable$ItemSoa pObject' should be declared static
Build complete.

But when i run the program on the emulator, i m not seeing the app on the emulator. I ve given an icon , but it doesnt show up.

I dont know where the problem is . Do i have to have any other software up and running? Appreciateif you can help me.

Another thing to mention - i read somewhere that project dependencies have to be set. But when i right click the project and go to project dependencies, it shows ksoap2 , but it is disabled --> it does not allow me to select ksoap2.


Thanks

Last edited by subashbala; 03-16-2009 at 12:39 PM..
Offline  
Old 04-01-2009, 03:57 AM   #22
incarnis
New Member
 
Join Date: Mar 2009
Model: 9000
PIN: N/A
Carrier: O2 UK
Posts: 2
Default Simple ksoap2 example

Hi

I am new to Java, Blackberry and ksoap2, so I was wrestling with this for a couple of days.

This article helped a lot:

h**p://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&arti cleId=102

If you need parameters, just use the addProperty method on the SoapObject to add them. And if you just have a string value as a return, you can always use (envelope.getResult()).toString() to get hold of it (instead of the vector stuff in the example).

Hope this helps. Sorry can't hotlink urls as I am a newbie
Offline  
Old 04-02-2009, 06:05 AM   #23
darkdusky
New Member
 
Join Date: Apr 2009
Model: 7100T
PIN: N/A
Carrier: 02
Posts: 3
Default

I'm new to blackberry and haven't worked in java in a long time.
Can some-one explain the benefits of using SOAP over the httpConnection method below (this is a snippet from a tutorial at: h t t p://w w w.ibm.com/developerworks/opensource/tutorials/os-blackberry/section4.html


params.append("identifier", id);
params.append("data", data);
String url = "h t t p://ibm.msi-wireless.com/posttransaction.php?"
+ params.toString();
System.out.println(url);
//Connecting to Server
httpConnection = (HttpConnection)Connector.open(url);
inputStream = httpConnection.openDataInputStream();

I posted a thread asking for the maximum size of a query string. I'm interested to know which of the 2 methods can handle large delimited lists the best.
Offline  
Old 04-02-2009, 03:33 PM   #24
zona21
New Member
 
Join Date: Mar 2009
Model: 8800
PIN: N/A
Carrier: development
Posts: 2
Default problem using ksoap2 for sending parameters

hi

I have been using ksoap2 for a couple of days and i can't send the parameters to my web service,I can connect it but i don't know what's the problem for sending parameters.

this is my code


import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.*;

public class webService {

public webService() {
String serviceUrl = "h t t p://192.168.44.250/SerW_SubirArch/SubirArch.asmx";
String serviceNamespace = "h t t p://192.168.44.250/SerW_SubirArch/";
String soapAction = "mx.com.medisist.WebService/SignosVitalesblack";
String methodName= "SignosVitalesblack";

SoapObject rpc = new SoapObject(serviceNamespace, methodName);

rpc.addProperty("idPaciente", String.valueOf(340).toString());
rpc.addProperty("glucosa",String.valueOf(120).toSt ring());
rpc.addProperty("Medicamento","Metformina tableta 1000mg");
rpc.addProperty("Cantidad",String.valueOf(5).toStr ing());
rpc.addProperty("medida","Pastillas");


SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.ENC;
envelope.setOutputSoapObject(rpc);

HttpTransport ht = new HttpTransport(serviceUrl);
ht.debug = true;
ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

int result= -1;
try {

ht.call(soapAction, envelope);

result = Integer.valueOf((envelope.getResult()).toString()) .intValue();


} catch (org.xmlpull.v1.XmlPullParserException ex2) {
} catch (Exception ex) {
String bah = ex.toString();
System.out.println(bah);

}

}
}





I would appreciate much if you could help me
Offline  
Old 04-03-2009, 10:30 AM   #25
zona21
New Member
 
Join Date: Mar 2009
Model: 8800
PIN: N/A
Carrier: development
Posts: 2
Talking

Quote:
Originally Posted by zona21 View Post
hi

I have been using ksoap2 for a couple of days and i can't send the parameters to my web service,I can connect it but i don't know what's the problem for sending parameters.

this is my code


import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.*;

public class webService {

public webService() {
String serviceUrl = "h t t p://192.168.44.250/SerW_SubirArch/SubirArch.asmx";
String serviceNamespace = "h t t p://192.168.44.250/SerW_SubirArch/";
String soapAction = "mx.com.medisist.WebService/SignosVitalesblack";
String methodName= "SignosVitalesblack";

SoapObject rpc = new SoapObject(serviceNamespace, methodName);

rpc.addProperty("idPaciente", String.valueOf(340).toString());
rpc.addProperty("glucosa",String.valueOf(120).toSt ring());
rpc.addProperty("Medicamento","Metformina tableta 1000mg");
rpc.addProperty("Cantidad",String.valueOf(5).toStr ing());
rpc.addProperty("medida","Pastillas");


SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.ENC;
envelope.setOutputSoapObject(rpc);

HttpTransport ht = new HttpTransport(serviceUrl);
ht.debug = true;
ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

int result= -1;
try {

ht.call(soapAction, envelope);

result = Integer.valueOf((envelope.getResult()).toString()) .intValue();


} catch (org.xmlpull.v1.XmlPullParserException ex2) {
} catch (Exception ex) {
String bah = ex.toString();
System.out.println(bah);

}

}
}





I would appreciate much if you could help me


hi everybody

finally, I could transfer parameters to my web service, my mistake was that i was writing on the variable *serviceNamespace something like this: String serviceNamespace = "h t t p://192.168.44.250/SerW_SubirArch/";
the situation was happening because i had another nameSpace on my web Service it was:


[WebService(Namespace = "mx.com.medisist.WebService")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class SubirArch : System.Web.Services.WebService{

furthermore I had to put the same name on my code variable *serviceNamespace because it has to be the same String to pass the parameters, now my new code is:




/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Medisist;

import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.*;


public class webService {

public webService() {
String serviceUrl = "h t t p://192.168.44.250/SerW_SubirArch/SubirArch.asmx";
String serviceNamespace = "mx.com.medisist.WebService";
String soapAction = "mx.com.medisist.WebService/SignosVitalesblack";
String methodName="SignosVitalesblack";

SoapObject rpc = new SoapObject(serviceNamespace, methodName);


SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

rpc.addProperty("idPaciente","340");
rpc.addProperty("glucosa","120");
rpc.addProperty("Medicamento","Metformina tableta 1000mg");
rpc.addProperty("Cantidad","5");
rpc.addProperty("medida","Pastillas");


envelope.setOutputSoapObject(rpc);
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.XSI;


HttpTransport ht = new HttpTransport(serviceUrl);
ht.debug = true;
ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

String result= null;
try {

ht.call(soapAction, envelope);


result = (envelope.getResult()).toString();


} catch (org.xmlpull.v1.XmlPullParserException ex2) {
} catch (Exception ex) {
String bah = ex.toString();
System.out.println(bah);

}

}
}

I appreciate much and i hope that this code can be helpfully

Last edited by zona21; 04-03-2009 at 10:32 AM..
Offline  
Old 05-04-2009, 09:26 PM   #26
ShannyMan
New Member
 
Join Date: May 2009
Model: 9530
PIN: N/A
Carrier: Verizon
Posts: 4
Default

Excellent post! What about sending a complex type? I can't seem to find much information on sending one, there's plenty available on recieving it back in the response, and I do have that part working.

Thanks.
Offline  
Old 06-22-2009, 08:41 PM   #27
cagreen
New Member
 
Join Date: Apr 2009
Model: 7100T
PIN: N/A
Carrier: None
Posts: 4
Smile

Thanks to jeckerlin for the initial post and everyone after for their contributions. I still struggled for longer than I would have like getting Eclipse, KSoap and the BB to play nice. I have since summarized my experience going from a clean machine to getting KSoap up and running on the device. I hope this helps someone else. It can be found here: w w w.craigagreen.com/index.php?/Blog/blackberry-and-net-webservice-tutorial-part-1.html
Offline  
Old 06-23-2009, 12:38 PM   #28
koic
Thumbs Must Hurt
 
Join Date: Feb 2009
Location: CANADA
Model: 9000
PIN: N/A
Carrier: Rogers
Posts: 64
Default

Well, that is a good idea!
But I bet it will be much more complicated
when it comes to deal with complex() response from web server.
I looked over internet and could not find any good example
related to de-serialization of that response with ksoap2.
I am not sure if envelope.addMapping() works at all.
In my development I had to use SAX for that purpose,
which worked just fine
Offline  
Old 07-03-2009, 12:55 PM   #29
cagreen
New Member
 
Join Date: Apr 2009
Model: 7100T
PIN: N/A
Carrier: None
Posts: 4
Angry

I can't seem to get both complex return types and input parameters working at the same time. They are mutually exclusive for me!

I was initially able to pass strings to my .NET service and return a string... no problem. But to return complex types I had to set the SoapRpcMethod attribute on the server. That now allows me to return a complex type, but now my input parameters aren't properly deserialized on the server. I've tried numerous things, even instantiating my own SoapPrimitive instance (as seen below).
I'm hoping that it's something as trivial as a bad namespace that I've overlooked. Any insight is much appreciated.

Java Client:
Code:
String serviceUrl = "h t t p : //xx.xxx.xxx.xxx/HelloWorldService/Service.
String serviceNamespace = "h t t p ://tempuri.org/";
String soapAction = "h t t p : //tempuri.org/HelloWorld";		
SoapObject rpc = new SoapObject(serviceNamespace, "HelloWorld");		
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
		    
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.XSD;
envelope.addMapping("h t t p : //tempuri.org/encodedTypes", "Complex", new Complex().getClass());
		
HttpTransport ht = new HttpTransport(serviceUrl);
ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
ht.debug = true;
    

try 
{	    		
//	rpc.addProperty("a","45");
//     	rpc.addProperty("b","54");
	rpc.addProperty("a",new SoapPrimitive(SoapSerializationEnvelope.XSD,"String","45"));
       	rpc.addProperty("b",new SoapPrimitive(SoapSerializationEnvelope.XSD,"String","54"));
       	ht.call(soapAction, envelope);
      	SoapObject body = (SoapObject)envelope.bodyIn;
        String req = ht.requestDump;
        String resp = ht.responseDump;

        ... and so on...
.NET Web Service:
Code:
    [WebService(Namespace = "h t t p ://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.None)]
    public class Service : System.Web.Services.WebService
    {
        [SoapRpcMethod]
        [WebMethod]  
        public Complex[] HelloWorld(String a, String b)
        {
         ...
        }
     }
Offline  
Old 07-03-2009, 01:17 PM   #30
koic
Thumbs Must Hurt
 
Join Date: Feb 2009
Location: CANADA
Model: 9000
PIN: N/A
Carrier: Rogers
Posts: 64
Default

Did not make sense to show this example, - it's everywhere and it works.
Again, try to use SAX parser to de-serialize complex response
Offline  
Old 07-03-2009, 01:29 PM   #31
cagreen
New Member
 
Join Date: Apr 2009
Model: 7100T
PIN: N/A
Carrier: None
Posts: 4
Default

Perhaps I wasn't clear in my previous post. I'm good with the deserializing the complex type back on the client.
My question now is "what am I doing incorrectly that is making my input parameters on the server be null"? As I mentioned earlier, I did have this working, but not when using SoapRpcMethod on the server.

By showing my sample code I'm hoping that there is something obvious that I've overlooked that someone could point out.

Thanks
Offline  
Old 07-06-2009, 11:42 AM   #32
koic
Thumbs Must Hurt
 
Join Date: Feb 2009
Location: CANADA
Model: 9000
PIN: N/A
Carrier: Rogers
Posts: 64
Default

Quote:
Originally Posted by cagreen View Post
...my input parameters on the server be null...
I would check requestDump and responseDump first.
Input params types should be exactly the same in both dumps.
Offline  
Old 07-28-2009, 01:42 AM   #33
narendra
New Member
 
Join Date: Jul 2009
Model: 8320
PIN: N/A
Carrier: Blackberry
Posts: 1
Default JVM Error :104

Hi,

I am using this tutorial and config project according to the mentioned steps. but when I run my project , an runtime error occurs:

"JVM Error : 104"
"Uncaught Runtime Exception"

How I run my project is :
Right click on project > Run As>Blackberry Simulator

Is this the right way ?

please give me more information about this type of applications.

Thanks.
Offline  
Old 08-13-2009, 12:37 AM   #34
nirmalsat
Knows Where the Search Button Is
 
Join Date: Aug 2009
Model: 8300
PIN: N/A
Carrier: Vodafone
Posts: 22
Default Cant find Project dependencies!!!

Hi, I ve been tryin to do the same thing but with eclipse. In step 4 u mention that we need to go to project dependencies.. The same was mentioned in another post .
But am not able to find it.. Please help me out
Offline  
Old 08-20-2009, 09:10 PM   #35
ScottVickery
New Member
 
Join Date: Aug 2009
Model: n/a
PIN: N/A
Carrier: n/a
Posts: 1
Default Send parameters OR be able to get back complex objects

Quote:
Originally Posted by cagreen View Post
Perhaps I wasn't clear in my previous post. I'm good with the deserializing the complex type back on the client.
My question now is "what am I doing incorrectly that is making my input parameters on the server be null"? As I mentioned earlier, I did have this working, but not when using SoapRpcMethod on the server.

By showing my sample code I'm hoping that there is something obvious that I've overlooked that someone could point out.

Thanks
I am having the same problem. That is I can send parameters OR get back complex objects, but, not both. The two cases are:

- send parameters successfully and get back an untyped string that looks like this: "anyType{Id=-70; someList=anyType{" where anyType is not useful to me.

- Or, my parameters are sent as nulls, and I get something useful back. Something like this: "ObjectName1{Id=-3; someList=[ObjecName2{Id=-6;" where ObjectName1 & ObjectName2 are interesting to me.

The behavior is changed by including the [SoapRpcMethod] attribute above the method in my web service. With the attribute, I get the object back in a useful format, but, can not send parameters. Without it, the opposite.

Anyone have a solution to this?

Thanks,
Scott
Offline  
Old 11-19-2009, 01:45 AM   #36
akangbro
New Member
 
Join Date: Nov 2009
Model: 7100
PIN: N/A
Carrier: IT Programmer
Posts: 2
Default

hai guys

nice tutorial...

i have exception, i dunno what should i do
this is exception : expected: START_TAG {h t t p:/ / schemas.xmlsoap. org/soap/envelope/}Envelope (position:START_TAG (empty) < br>@1:6 in java.io.InputStreamR eader@d590dbc)
Offline  
Old 11-19-2009, 02:05 AM   #37
akangbro
New Member
 
Join Date: Nov 2009
Model: 7100
PIN: N/A
Carrier: IT Programmer
Posts: 2
Default

Quote:
Originally Posted by akangbro View Post
hai guys

nice tutorial...

i have exception, i dunno what should i do
this is exception :
Code:
expected: START_TAG {h t t p:/ / schemas .xmlsoap.  org/soap/envelope/}Envelope (position:START_TAG (empty) < br>@1:6 in java.io .InputStreamR eader@d590dbc) 
this is my wsdl
Code:
< definitions targetName space="h tt p:/ / www.wso2 .org / php">
xxx8722;
<types>
xxx8722;
< xsd:schema elementFormDefault="qualified" targetNamespace="h tt p:/ / wso2. org/projects/wsf/php/ds">
<  xsd:element name="gettrxjual" type="ns0:gettrxjual"/>
< xsd:element name="poliss" type="ns0:polissType"/>
xxx8722;
< xsd:complexType name="gettrxjual">
xxx8722;
< xsd:sequence>
< xsd:element name="noagen1" type="xsd:any"/>
< xsd:element name="noagen2" type="xsd:any"/>
< xsd:element name="noagen3" type="xsd:any"/>
< xsd:element name="noagen4" type="xsd:any"/>
< /xsd:sequence>
< /xsd:complexType>
xxx8722;
< xsd:complexType name="polissType">
xxx8722;
< xsd:sequence>
< xsd:element name="polis" minOccurs="0" maxOccurs="unbounded" nillable="true" type="ns0:polisType"/>
</ xsd:sequence>
</ xsd:complexType>
xxx8722;
< xsd:complexType name="polisType">
xxx8722;
< xsd:sequence>
< xsd:element name="nmleng" type="xsd:any"/>
< xsd:element name="tgllhr" type="xsd:dateTime"/>
< xsd:element name="ultah" type="xsd:any"/>
< xsd:element name="nmagen" type="xsd:any"/>
< xsd:element name="nopoli" type="xsd:any"/>
< xsd:element name="ketsta" type="xsd:any"/>
< xsd:element name="nomohp" type="xsd:any"/>
< /xsd:sequence>
< /xsd:complexType>
< /xsd:schema>
< /  types>
xxx8722;
< me ssage name="gettrxjual">
< par t name="parameters" element="ns0:gettrxjual"/>
< /me ssage>
xxx8722;
< mes sage name="gettrxjualResponse">
< part  name="parameters" element="ns0:poliss"/>
< /mes sage>
xxx8722;
< portTy pe name="data_service_lapula_service.phpPortType">
xxx8722;
< opera tion name="gettrxjual">
< inpu t message="tns:gettrxjual"/>
< outp ut message="tns:gettrxjualResponse"/>
< /ope  ration>
< /portType>
xxx8722;
< binding name="data_service_lapula_service.phpSOAPBinding" type="tns:data_service_lapula_service.phpPortType">
< s oap:binding transport="h t t p :// s chemas.xmlsoap.org/soap/ht tp" style="document"/>
xxx8722;
< operatio n name="gettrxjual">
< soap :operation soapAction="h tt p: / /192.168.100.7:8901/data_service/l apula_service.php/gettrxjual" style="document"/>
xxx8722;
< input>
< soap:body use="literal"/>
< /input>
xxx8722;
< output>
< soap:body use="literal"/>
<  /output>
< /operation>
< /binding>
xxx8722;
< service name="data_service_lapula_service.php">
xxx8722;
< port name="data_service_lapula_service.phpSOAPPort_Http" binding="tns:data_service_lapula_service.phpSOAPBinding">
< soap:address location="ht tp :/ /192.168.100.7:8901/data_service/lapula_service.php"/>
</ port>
</ service>
</ definitions>
and

this is my source code
Code:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

import org.ksoap2.*;
import org.ksoap2.transport.*;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.xmlpull.v1.XmlPullParserException;
import java.util.Vector;
import java.io.IOException;
/**
 * @author secangkirkopipanas
 */
public class gui_mobile3 extends MIDlet implements CommandListener, Runnable{
   private Display display;
   private String url = "htt p  : //127.0.0.1/ data_service/lapula_service.php";

   private TextBox textbox = null;
private Form form;
    private TextField input;
    private StringItem output;
    private Command cmOk;
    private Command cmExit;


   public gui_mobile3() {
      form = new Form("Mobile");
       input = new TextField("No. Agen", "", 10, TextField.ANY);
        output = new StringItem("","");
        cmOk = new Command("OK", Command.OK,1);
        cmExit = new Command("EXIT", Command.EXIT, 2);

        form.append(input);
        form.append(output);

        form.addCommand(cmOk);
        form.addCommand(cmExit);
        form.setCommandListener(this);

   }

   public void startApp() {
	display = Display.getDisplay(this);
        display.setCurrent(form);
     
   }

   public void pauseApp() {
   }

   public void destroyApp(boolean unconditional) {
   }

public void commandAction(Command c, Displayable d) {
        if(c==cmOk)
            new Thread(this).start();
        if(c==cmExit)
        {
            destroyApp(false);
            notifyDestroyed();
        }
        //throw new UnsupportedOperationException("Not supported yet.");
    }

public void run() {
try {
         testWebService();
      } catch (Exception ex) {
         System.out.println(ex);
      }
}

   public void testWebService() throws Exception {
      StringBuffer stringBuffer = new StringBuffer();
      TextBox textBox = null;
	String tem=null;
	SoapObject resultsRequestSOAP = null;
	String result = null;

      // First WebService - echos name that is passed in, in this case 'Robertus Lilik Haryanto'
      String method = "gettrxjual";
	String namespace = "ht t p :/ /wso2.org/projects/wsf/php/ds";
	String soapAction = "h ttp:// 19 2.168.100.7:8901/data_service/lapula_service.php/gettrxjual";
      SoapObject client = new SoapObject(namespace , method);
	client.addProperty("noagen1", "010300080");
	client.addProperty("noagen2", "010300080");
	client.addProperty("noagen3", "010300080");
	client.addProperty("noagen4", "010300080");
	
      // Creating the Soap Envelope      
	SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	envelope.setOutputSoapObject(client);
	envelope.encodingStyle = SoapSerializationEnvelope.XSI;

	HttpTransport transport = new HttpTransport(url);
	transport.setXmlVersionTag("< ? xml version=\"1.0\" encoding=\"utf-8\"? >");
      // Call the WebService
      try {
            transport.call(soapAction,envelope); 	
		result = (envelope.getResult()).toString();	
		System.out.println("hasil : "+result);
        } catch (XmlPullParserException ex) {
		System.out.println(ex.getMessage());
            output.setText(ex.getMessage());
        } catch (IOException ex) {
            output.setText(ex.getMessage());
        } catch (Exception ex) {
            output.setText(ex.getMessage());
        }
	stringBuffer.append(resultsRequestSOAP);
	textBox = new TextBox("hasil ", stringBuffer.toString(), 4096, 0);
	display.setCurrent(textBox);

}
}
i spent 2 weeks for this @_@
please help me

thanks

Last edited by akangbro; 11-19-2009 at 02:19 AM..
Offline  
Old 11-29-2009, 07:53 AM   #38
peterjtracey
New Member
 
Join Date: Oct 2009
Model: 7100T
PIN: N/A
Carrier: ATT
Posts: 5
Default Handling the result

Quote:
Originally Posted by jeckerlin View Post
looks like I got a little ahead of myself. Looks like you need to do things a little differently so the blackberry device will load the ksoap files correctly.

Modified steps appear to be:
1) You need a preverified ksoap2-j2me-core-2.1.2.jar (attached) file. The ones from the kSoap site arent preverified and when attempting to do so it failed. I attempting to go through a preverification process but have been unsuccessful. I obtained the attached jar from a post by richard.puckett of a preverified ksoap2-j2me-core-2.1.2.jar file.

Since I'm new to the forums, I cant specify a direct link to the file. If you do a search for a thread called 'Preverified ksoap2' you can find Richard's link
to the file.

2) Within your JDE project, create a lib folder. Using Windows Explorer, create a lib folder within your project and put the ksoap2-j2me-core-2.1.2.jar file in there.


3) Create a new 'Library' in your JDE workspace called kSoap. Add the preverified ksoap2-j2me-core-2.1.2.jar in the lib folder to that library.

4) Set the project dependencies to depend on the new library. Right click your main project -> select project dependencies -> select the kSoap library as a dependency

5) compile w/o errors

Below is simple code to call a .Net web service:

code extract from java file:
String serviceUrl = "<url to web service>l";
String serviceNamespace = "h t t p : / / tempuri . org /";
String soapAction = "h t t p : / / tempuri.org / HelloWorld";

SoapObject rpc = new SoapObject(serviceNamespace, "HelloWorld");

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.XSD;

HttpTransport ht = new HttpTransport(serviceUrl);
ht.debug = true;

try
{
ht.call(soapAction, envelope);

String result = (envelope.getResult()).toString();


}
catch(org.xmlpull.v1.XmlPullParserException ex2){

}
catch(Exception ex){
String bah = ex.toString();

}


Code Extract from .Net web Service
namespace TestService
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "h t t p : / / tempuri . org /")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{

[WebMethod]
public string HelloWorld()
{
return "Hello World" + System.DateTime.Now.ToString();
}
}
}
This may work, I have gotten it to work using similar code, but handling the response is missing something I think. This is what I have:

Code:
public String hackToGetResponse(String key, String response) {
	System.out.println("hackToGetResponse:" + response);
	String start = "anyType{key=" + key + "; value=";
	String end = "; }";
 
	if (response.indexOf(start) == -1 ||
		response.indexOf(end) == -1) return "";
 
	System.out.println("hackToGetResponse:" + "response.substring(0, " + response.indexOf(start)  + ").substring(0, " + response.indexOf(end) + ");");
	response = response.substring(response.indexOf(start) + start.length());
	response = response.substring(0, response.indexOf(end));
 
	if (response.indexOf("anyType{}") != -1) return "";
 
	return response;
}
and then after the request is sent call hackToGetResponse with:

Code:
SoapObject result = (SoapObject) ((SoapObject)envelope.getResponse()).getProperty(0);
 
		key = hackToGetResponse("serviceToken", result.toString());
This is necessary because the response SoapObject doesn't make it easy to get at values. If this code doesn't work for you (I'm using PHP as the server so your server's output may be different) pay close attention to what's outputted in the console and modify the parsing code.

Pete Tracey
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Vintage V-Mac Industries Inc. Pipe Threader Vosper Drophead Threader - READ picture

Vintage V-Mac Industries Inc. Pipe Threader Vosper Drophead Threader - READ

$199.00



Vintage Mac Warehouse  3.5” Floppy Disk Solar Powered Calculator Company Swag picture

Vintage Mac Warehouse 3.5” Floppy Disk Solar Powered Calculator Company Swag

$51.80



Vintage White APPLE IMAC EMC 1857 15

Vintage White APPLE IMAC EMC 1857 15" 20GB HDD Mac OSX 10.2 256MB RAM 500MHz

$85.00



Vintage MAC TOOLS 18MM Combination Wrench M18CW Metric 12 point **Made in USA** picture

Vintage MAC TOOLS 18MM Combination Wrench M18CW Metric 12 point **Made in USA**

$26.50



Vintage UNHOLTZ-DICKIE MAC-6C Equipment - Untested As-is picture

Vintage UNHOLTZ-DICKIE MAC-6C Equipment - Untested As-is

$71.99



VINTAGE RICHARD PETTY #43 MAC TOOLS RACING RED MAGNETIC 90's CAR FENDER COVER picture

VINTAGE RICHARD PETTY #43 MAC TOOLS RACING RED MAGNETIC 90's CAR FENDER COVER

$89.99







Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.