BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-09-2009, 01:39 AM   #1 (permalink)
New Member
 
Join Date: Jul 2009
Model: 8830
PIN: N/A
Carrier: Telus
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Web Service Call - XmlPullParserException

Please Login to Remove!

I created a very basic application that calls a "Hello World" type .Net Web Service. The web service simply returns "Hi". I am using the Blackberry JDE 4.2 and also kSOAP2 (ksoap2-j2me-core-2.1.2.jar). In the simulator, this program works fine. When I load it onto my Blackberry 8830, I get the following error message:

Quote:
org.xmlpull.v1.XmlPullParserException: expected: START_TAG { h t t p://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <HTML>@1:6 in java.io.InputStreamReader@a1db4758)
Here is my code:

Code:
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import java.util.*;
import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.*;
import org.xmlpull.v1.*;

class StockQuoteDemo extends UiApplication
{
    private EditField _status;
    
    public static void main (String[] args)
    {
        StockQuoteDemo theApp = new StockQuoteDemo ();
        theApp.enterEventDispatcher ();
    }

    public StockQuoteDemo ()
    {
        pushScreen (new StockQuoteScreen ());
        doSOAP();
    }    
    
    final class StockQuoteScreen extends MainScreen 
    {      
        public StockQuoteScreen ()
        {
            LabelField title = new LabelField ("Sample Web Service Call", LabelField.ELLIPSIS|LabelField.USE_ALL_WIDTH);
            setTitle (title);
            
             _status = new EditField();
             add(_status);
        }
        
        public boolean onClose ()
        {
            Dialog.alert ("Goodbye!");
            System.exit (0);
            return true;
        }
    }  
    
    // Update the GUI with the data received
    private void updateLocationScreen(final String msg)
    {
        invokeLater(new Runnable(){
            public void run()
            {
                _status.setText(msg);
            }
        });
    }    
    
    private static final String SOAP_ACTION = "h t t p://theURL.com/WebServiceTest"; 
    private static final String METHOD_NAME = "WebServiceTest"; 
    private static final String NAMESPACE = "h t t p://theURL.com/"; 
    private static final String URL = "h t t p://theURL.com/test/hi/service.asmx";  
        
    public void doSOAP()
    {         
        String message = "";

        try
        {
            SoapObject rpc = new SoapObject (NAMESPACE, METHOD_NAME);

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet = true;  
            envelope.bodyOut = rpc; 
            
            HttpTransport transport = new HttpTransport(URL);  

            transport.debug = true;
            transport.call(SOAP_ACTION, envelope);  
            message = "" + envelope.getResult();                   
        }
        catch (Exception e)
        {
            e.printStackTrace ();
            System.out.println(e.toString());
            message = "" + e.toString();
        }
        
        // Create the string buffer to write the results to the screen
        StringBuffer sb = new StringBuffer();
        sb.append("Message:\n" + message + "\n");
        StockQuoteDemo.this.updateLocationScreen(sb.toString());
                
    }   
}
Has anyone else experienced this?

Stephen
Offline  
Old 07-09-2009, 02:19 AM   #2 (permalink)
New Member
 
Join Date: Jun 2009
Model: 8900
PIN: N/A
Carrier: XL
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

What's the xml response structure code looks like ?
Offline  
Old 07-09-2009, 07:59 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Feb 2009
Location: CANADA
Model: 9000
PIN: N/A
Carrier: Rogers
Posts: 64
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

There are lots of WORKING examples for ksoap2 on THIS forum just do some search
P.S. it could be web service problem as well.

Last edited by koic : 07-09-2009 at 08:02 AM.
Offline  
Old 07-09-2009, 08:29 PM   #4 (permalink)
New Member
 
Join Date: Jul 2009
Model: 8830
PIN: N/A
Carrier: Telus
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

How do I find the XML response code?

I did do a bunch of searching through this forum and others but I couldn't find anyone with a similar problem. The strange thing is that it works in the simulator just fine.

Stephen
Offline  
Old 07-09-2009, 09:33 PM   #5 (permalink)
Thumbs Must Hurt
 
Join Date: Feb 2009
Location: CANADA
Model: 9000
PIN: N/A
Carrier: Rogers
Posts: 64
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually, it is soap response
In exception section call:
PHP Code:
System.out.println("response: "+transport.responseDump()); 
And I also suggest to look at request as well:
PHP Code:
System.out.println("request: "+transport.requestDump()); 
Offline  
Old 07-09-2009, 11:08 PM   #6 (permalink)
New Member
 
Join Date: Jul 2009
Model: 8830
PIN: N/A
Carrier: Telus
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okay, here is the request and response:

PHP Code:
Request: <v:Envelope xmlns:i="h t t p : / /w w w.w3.org/2001/XMLSchema-instance" xmlns:d="h t t p : / /w w w.w3.org/2001/XMLSchema" xmlns:c="h t t p: / /schemas.xmlsoap.org/soap/encoding/" xmlns:v="h t t p : / /schemas.xmlsoap.org/soap/envelope/"><v:Header /><v:Body><WebServiceTest xmlns="h t t p : / /theurl.com/" id="o0" c:root="1" /></v:Body></v:Envelope
PHP Code:
Response: <HTML><HEAD>
<
TITLE>Access Denied</TITLE>
</
HEAD>
<
BODY>
<
FONT face="Helvetica">
<
big><strong></strong></big><BR>
</
FONT>
<
blockquote>
<
TABLE border=0 cellPadding=1 width="80%">
<
TR><TD>
<
FONT face="Helvetica">
<
big>Access Denied (authentication_failed)</big>
<
BR>
<
BR>
</
FONT>
</
TD></TR>
<
TR><TD>
<
FONT face="Helvetica">
Your credentials could not be authenticated"Credentials required."You will not be permitted access until your credentials can be verified.
</
FONT>
</
TD></TR>
<
TR><TD>
<
FONT face="Helvetica">
This is typically caused by an incorrect username and/or passwordbut could also be caused by network problems.
</
FONT>
</
TD></TR>
<
TR><TD>
<
FONT face="Helvetica" SIZE=2>
<
BR>
For 
assistancecontact your network support team.
</
FONT>
</
TD></TR>
</
TABLE>
</
blockquote>
</
FONT>
</
BODY></HTML
The access denied error is strange... It is the standard access denied message. If I go to the URL on my blackberry for the web service, I can access it no problem. When I try to invoke the method from there, I get the popup error "A problem occurred while trying to render the page". I also get that error message when I navigate directly to the method URL. Could this be because my Blackberry is having issues reading/displaying XML?

Stephen
Offline  
Old 07-13-2009, 08:44 PM   #7 (permalink)
New Member
 
Join Date: Jul 2009
Model: 8830
PIN: N/A
Carrier: Telus
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Does anyone have any idea why I am receiving this error message?

Stephen
Offline  
Old 07-23-2009, 09:36 PM   #8 (permalink)
New Member
 
Join Date: Jul 2009
Model: 8830
PIN: N/A
Carrier: Telus
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I fixed this issue by accident. I upgraded my Blackberry 8830 to the latest software version, v4.5.0.160 and the web service calls started working automatically.

Stephen
Offline  
Old 08-05-2009, 01:39 AM   #9 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2009
Model: 8120
PIN: N/A
Carrier: gmail
Posts: 18
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

you check your services url,name space,soapAction and method name parameter is set properly or not.....you can use a software like SoapClient ,which will give u this parameter ,if u pass ur wsdl file to it.........
Offline  




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