Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 80
Registered: ‎09-03-2012
My Device: 9810
My Carrier: Vodafone
Accepted Solution

IOException null while making SOAP request using ksoap2 library.

Hi I am trying to implement SOAP request using ksoap2 library but on running it on Torch 9810 I am getting IOException null

 

httpTransport.call(SOAP_ACTION, soapEnvelope); is giving exception.


Code for it is :

 

private String NAMESPACE="samplenamespace";
	private String url="webserviceurl";
	private String METHODNAME="getrecords";
	private String SOAP_ACTION=NAMESPACE+"/"+METHODNAME;


	private void sendSoapRequest(String email, String startDate, String enddDate) {
		SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		soapEnvelope.implicitTypes = true;
		soapEnvelope.dotNet = true;
		SoapObject soapReqObject = new SoapObject(
				NAMESPACE, METHODNAME);
		
		soapEnvelope.headerOut = new Element[1];
		soapEnvelope.headerOut[0] = buildAuthHeader();
		soapReqObject.addProperty("email", email);
		soapReqObject.addProperty("startdate", startDate);
		soapReqObject.addProperty("enddate", endDate);
				
		soapEnvelope.setOutputSoapObject(soapReqObject);
		HttpTransport httpTransport = new HttpTransport(url
				+ ";deviceSide=true;interface=wifi");
		httpTransport.debug=true;
		try {
			httpTransport.call(SOAP_ACTION,
					soapEnvelope);			
		} catch (final IOException e) {
			e.printStackTrace();
			UiApplication.getUiApplication().invokeLater(new Runnable() {

				public void run() {
					Dialog.alert("IOException " + e.getMessage());

				}
			});

		} catch (final XmlPullParserException e) {
			e.printStackTrace();
			UiApplication.getUiApplication().invokeLater(new Runnable() {

				public void run() {
					Dialog.alert("XmlPullParserException " + e.getMessage());

				}
			});
		} catch (final Exception e) {
			e.printStackTrace();
			UiApplication.getUiApplication().invokeLater(new Runnable() {

				public void run() {
					Dialog.alert("Exception " + e.getMessage());

				}
			});
		}
	}


	private Element buildAuthHeader() {
		Element h = new Element().createElement(NAMESPACE, "headername");
		Element username = new Element()
				.createElement(NAMESPACE, "username");
		username.addChild(Node.TEXT, "usernametext");
		h.addChild(Node.ELEMENT, username);
		Element pass = new Element().createElement(NAMESPACE, "password");
		pass.addChild(Node.TEXT, "passwordtext");
		h.addChild(Node.ELEMENT, pass);
		return h;
	}

 

I did tried checking a lot of post about KSOAP2 in supportforum . Also made changes according to them but none of them succeeded.

 

Any help ?

 

Always Success
Developer
Posts: 80
Registered: ‎09-03-2012
My Device: 9810
My Carrier: Vodafone

Re: IOException null while making SOAP request using ksoap2 library.

Resolved

problem was in parameters passing (wrong format of params)

Always Success