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
PIN: N/A
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 fine.now 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() {
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 run(){
try {
// build request string
String symbol = symbolField.getString();


// Create SOAP object.This will contain your webservice request
SoapObject rpc = new SoapObject("http://xmlns.oracle.com/Enterprise/Tools/schemas/M676127.V1", "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
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;

// Making webservice call
HttpTransport http = new HttpTransport("http://172.16.186.86:12345/PSIGW/PeopleSoftServiceListeningConnector/PSFT_CR/CI_SC_HANDHELD_CI.1.wsdl");
http.call("Get1.V1", envelope);

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

}
catch (SoapFault sf){
resultItem.setLabel("FAULT:\n");
String faultString = "Code: " + sf.faultcode + "\nString: " + sf.faultstring;
resultItem.setText(faultString);

}
catch (Exception e) {
e.printStackTrace();
resultItem.setLabel("Error:");
resultItem.setText(e.toString());
}


}


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

/** for me4se */

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

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);

... 
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

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

GE Medical System 1.5T 3" Round MRI Coil; Signa Dual Phased Array Adapter.
$1800.0
GE Medical System 1.5T 3ABB Contactors UA50-30 3 pole 660-690V 50Hz 50A coil 230VAC
$25.0
ABB  Contactors UA50-30 3 pole 660-690V 50Hz 50A  coil 230VAC pictureGE 1.5T UPPER EXTREMITY PHASED ARRAY FLEX COIL; P/N 544GE-64 by Medical Advance
$1800.0
GE 1.5T UPPER EXTREMITY PHASED ARRAY FLEX COIL; P/N 544GE-64 by Medical Advance pictureGE 1.5T MRI PHASED ARRAY FLEX COIL; P/N 543GE-64 by Medical Advance
$1800.0
GE 1.5T MRI PHASED ARRAY FLEX COIL; P/N 543GE-64 by Medical Advance pictureIGNITION COIL & SPARK PLUG MODULE Replacement For PARTNER HUSQVARNA K750 SAWS
$10.99
IGNITION COIL & SPARK PLUG MODULE Replacement For PARTNER HUSQVARNA K750 SAWS  picture






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