View Single Post
Old 05-06-2013, 07:54 AM   #89 (permalink)
ariinno
New Member
 
Join Date: May 2013
Model: 9800
PIN: N/A
Carrier: Airtel
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: **** BlackBerry and Ksoap2 Tutorial *****

I am using ksoap2.jar in my application for webservice call.

While conneting, to the server it is giving the below error when i am testing using device or simulator:

org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:0 in java.io.InputStreamReader@6111a1f1)

I am using the preverified Jar file. I wrote the below code:

Code:
              SoapObject rpc = new SoapObject(serviceNamespace, methodName);
		rpc.addProperty("UserID", "1");
		rpc.addProperty("UserName", "xyz");
		rpc.addProperty("ContactNo", "9014567890");
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

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

		HttpTransport ht = new HttpTransport(serviceUrl + getConnectionString().trim());
		ht.debug = true;
		System.out.println("debug true ------- ");
		ht.setXmlVersionTag(" version=\"1.0\" encoding=\"UTF-8\"?>");
		SoapObject  response = null;
		try
		{
			ht.call(soapAction, envelope);
			 response = (SoapObject )envelope.getResponse();
			 String resultbody = response.getProperty("updateUserDetailResult").toString();
		}
		catch(org.xmlpull.v1.XmlPullParserException ex2){
			
			resultLbl.setText(ex2.toString());
		}
		catch(Exception ex){
		String bah = ex.toString();
		resultLbl.setText(bah);
		}




/**
	 * Looks through the phone's service book for a carrier provided BIBS network
	 * 
	 * @return The uid used to connect to that network.
	 */
	private static String getCarrierBIBSUid() 
	{
		net.rim.device.api.servicebook.ServiceRecord[] records = ServiceBook.getSB().getRecords();
		int currentRecord;

		for (currentRecord = 0; currentRecord < records.length; currentRecord++) 
		{
			if (records[currentRecord].getCid().toLowerCase().equals("ippp")) {
				if (records[currentRecord].getName().toLowerCase().indexOf("bibs") >= 0) {
					return records[currentRecord].getUid();
				}
			}
		}
		return null;
	}

	/**
	 *  Getting the connection string based on the connection
	 * @return
	 */
	public static String getConnectionString() 
	{
		String connectionString = null;

		// Wifi is the preferred transmission method
		if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED) 
		{
			connectionString = ";interface=wifi";

		}
		// Is the carrier network the only way to connect?
		else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT) 
		{
			String carrierUid = getCarrierBIBSUid();
			if (carrierUid == null) 
			{
				// Has carrier coverage, but not BIBS. So use the carrier's TCP
				// network

				connectionString = ";deviceside=true";
			} 
			else 
			{
				// otherwise, use the Uid to construct a valid carrier BIBS
				// request

				connectionString = ";deviceside=false;connectionUID=" + carrierUid + ";ConnectionType=";
			}
		}

		// Check for an MDS connection instead (BlackBerry Enterprise Server)
		else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS)
		{
			connectionString = ";deviceside=false";

		}

		// If there is no connection available abort to avoid bugging the user
		// unnecssarily.
		else if (CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE) 
		{

		}

		// In theory, all bases are covered so this shouldn't be reachable.
		else 
		{
			connectionString = ";deviceside=true";
		}

		return connectionString;
	}
Can anyone please help as i am stuck in this from a long time..
Offline   Reply With Quote