BlackBerry Forums Support Community

Closed Thread
LinkBack Thread Tools
Old 04-22-2008, 04:13 AM   #1 (permalink)
Knows Where the Search Button Is
Join Date: Feb 2008
Model: 7100T
Carrier: Vodafone
Posts: 15
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default user credentials for webservice

Please Login to Remove!

hi i using ksoap to invoke the service.its working i need to give username n password since security is enabled for the service.wats the code for that

//package org.ksoap2.samples.quotes;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

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

public class StockQuoteDemo extends MIDlet implements CommandListener, Runnable {

Form mainForm = new Form("Create");
TextField symbolField = new TextField("Oppurtunity_ID:", "", 5, TextField.ANY);
StringItem resultItem = new StringItem("", "");
Command getCommand = new Command("Fetch", Command.SCREEN, 1);

public StockQuoteDemo() {

public void startApp() {

public void pauseApp() {

public void destroyApp(boolean unconditional) {

public void run(){
try {
// build request string
String symbol = symbolField.getString();

// Create SOAP object.This will contain your webservice request
SoapObject rpc = new SoapObject("", "Get__CompIntfc__SC_HANDHELD_CI");

// Lets assume, the SOAP Request contains following data:
// a 'String' data as Opportunity id.
rpc.addProperty("OPPORTUNITY_ID", symbol);
// rpc.addProperty("IntData", new Integer(10));

//Now, lets make SOAP envelope
SoapSerializationEnvelope envelope = new
envelope.bodyOut = rpc;

// Making webservice call
HttpTransport http = new HttpTransport("");"Get1.V1", envelope);

SoapObject result = (SoapObject)envelope.bodyIn;
resultItem.setText(result.getProperty("OPPORTUNITY _NAME")+" "+result.getProperty("PERSON_ID")+" "+result.getProperty("OPPORTUNITY_ID"));

catch (SoapFault sf){
String faultString = "Code: " + sf.faultcode + "\nString: " + sf.faultstring;

catch (Exception e) {


public void commandAction(Command c, Displayable d) {
new Thread(this).start();

/** for me4se */

public static void main(String[] argv) {
new StockQuoteDemo().startApp();
Old 04-23-2008, 07:37 AM   #2 (permalink)
Talking BlackBerry Encyclopedia
Join Date: Apr 2008
Location: Germany, BW
Model: -
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts

The easiest way is to modify the HttpTransport class of kSOAP to support basic authentication. BUT in this case you have to use SSL / HTTPS connection, otherwise it is a serious security problem...

add additional header to your connection in HttpTransport:
PHP Code:
connection.setRequestProperty("Authorization""Basic " login);
login is a String that has to be Base64 encoded and that could be passed as a paramter to the call() function.

PHP Code:
String login username ":" password;
//Encode the login information in Base64 format.
String login_encoded Base64OutputStream.encodeAsString(login.getBytes(),0,login.length(),false,false);

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Vintage EDM 926 ELECTROHOME monitor Apple II
Vintage  EDM 926 ELECTROHOME monitor Apple II   pictureGenuine WESCO N6K universal joint cross 2.475" unknown appl. vintage driveline
Genuine WESCO N6K universal joint cross 2.475Vintage Letterpress Print Type Ornament "An Apple A Day Bugs The A.M.A." Adcut
Vintage Letterpress Print Type Ornament Vintage Letterpress Print Type Ornament Apple for Teacher Adcut
Vintage Letterpress Print Type Ornament Apple for Teacher Adcut pictureVintage APPLE RED Retro SWINGLINE CUB Small Desk Top Stapler So CUTE
Vintage APPLE RED Retro SWINGLINE CUB Small Desk Top Stapler So CUTE picture

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