BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 06-24-2010, 04:15 PM   #1 (permalink)
New Member
 
Join Date: Jun 2010
Model: 7100T
PIN: N/A
Carrier: Telus
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default KSoap - passing parameters

Please Login to Remove!

Hi,

I'm trying to get a call to a free public web service to work using KSoap.
It works on services without parameters, but as soon as I try to introduce a parameter it fails with the following message:

Code:
XCEPTION: SoapFault - faultcode: 'soap:Server' faultstring: 'System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: Procedure or function 'GetBibleWordsbyKeyWord' expects parameter '@BibleWords', which was not supplied.
   at WebServicex.BibleWebservice.GetBibleWordsbyKeyWord(String BibleWords)
   --- End of inner exception stack trace ---' faultactor: 'null' detail: org.kxml2.kdom.Node@16a55fa
My code is as follows:

Code:
	public static void main(String[] args) {
	       
		
			String serviceUrl = "webservicex.net/BibleWebservice.asmx";  
			String serviceNameSpace = "webserviceX.NET";  
			String soapAction = "webserviceX.NET/GetBibleWordsbyKeyWord ";  
			String methodName = "GetBibleWordsbyKeyWord  "; 

			
	        SoapObject sub = new SoapObject(serviceNameSpace, methodName);

	        sub.addProperty("BibleWords", "Enoch");
	        
	        SoapSerializationEnvelope envelope = new  SoapSerializationEnvelope(SoapEnvelope.VER11);  
	        envelope.bodyOut = sub;  
	        System.out.println(envelope.bodyOut.toString());
	        envelope.encodingStyle = SoapSerializationEnvelope.ENC;  
	        HttpTransportSE ht = new HttpTransportSE(serviceUrl);  
	        ht.debug = true;  
	        ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
	        try  {  
	        	ht.call(soapAction, envelope);  
	        	Object result = (envelope.getResponse());  
	        	System.out.println("kSOAP response: " + result.toString());
	        }  
	       catch(org.xmlpull.v1.XmlPullParserException ex2){  
	    	   System.out.println("EXCEPTION: " + ex2.getMessage());
	       }  
	       catch(Exception ex){  
	    	   String bah = ex.toString();  
	    	   System.out.println("EXCEPTION: "+bah);
	    	   System.out.println("HT REQUEST DUMP" + ht.requestDump);

	       }  
		}
Any help would be greatly appriciated.
Since I am new to this forum I have had to remove http: // www from all URLS above.
Offline  
Old 06-24-2010, 04:27 PM   #2 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2010
Model: 8530
PIN: N/A
Carrier: Sprint
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is working code from my small project. Hope it will help you.

//passing strings and returns EmployeeResponse object
FieldChangeListener employeeListener = new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
String serviceUrl = "http : //servername/service1.asmx";
String serviceNamespace = "http : //tempuri.org/";
String soapAction = "http : //tempuri.org/GetEmployeeDetail";
SoapObject rpc = new SoapObject(serviceNamespace,"GetEmployeeDetail");
rpc.addProperty("EmployeeID", "123");
rpc.addProperty("EmployeeName", "MyName");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;
// envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.XSD;
envelope.addMapping("http : //tempuri.org/encodedTypes",
"EmployeeResponse", new EmployeeResponse().getClass());

envelope.setOutputSoapObject(rpc);
HttpTransport ht = new HttpTransport(serviceUrl);
ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
ht.debug = true;
try {
ht.call(soapAction, envelope);
EmployeeResponse myObj = (EmployeeResponse) envelope
.getResponse();
add(new RichTextField("ID: " + myObj.EmpID + "\n" + "Name: "
+ myObj.EmpName + "\n" + "Phone: " + myObj.Phone + "\n"+ "Address: " + myObj.Address));
} catch (Exception ex) {
String msg = ex.toString();
System.out.println(msg);
add(new RichTextField("Error Message: " + msg));
}
}
};

Last edited by romah : 06-24-2010 at 04:29 PM.
Offline  
Old 06-25-2010, 08:45 AM   #3 (permalink)
New Member
 
Join Date: Jun 2010
Model: 7100T
PIN: N/A
Carrier: Telus
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, I'll give it a try
Offline  
Old 06-25-2010, 09:49 AM   #4 (permalink)
New Member
 
Join Date: Jun 2010
Model: 7100T
PIN: N/A
Carrier: Telus
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I got it to work.
It turned out that I was missing:

Code:
envelope.dotNet = true;
Thanks again
Offline  
Old 06-25-2010, 10:06 AM   #5 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2010
Model: 8530
PIN: N/A
Carrier: Sprint
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

You're welcome.
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

AD SSM2125A DIP-48 Dynamic Range Processors/Dual VCA/VCA IC
$8.98
AD SSM2125A DIP-48 Dynamic Range Processors/Dual VCA/VCA IC pictureKEYENCE PLC CPU module KZ-A500 and good
$130.0
KEYENCE PLC CPU module KZ-A500 and good picture1PC USED Siemens 6ES7216-2AD23-0XB0
$218.02
1PC USED  Siemens  6ES7216-2AD23-0XB0 pictureCrestron C2N-DVP4DI 4X1 Digital Video Graphic Processor
$29.99
Crestron C2N-DVP4DI 4X1 Digital Video Graphic Processor pictureAdvantech industrial motherboard PCA-6184 Rev. A2 With CPU and good
$170.0
Advantech industrial motherboard PCA-6184 Rev. A2 With CPU and good picture






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