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: 248
Registered: ‎11-23-2009
My Device: Not Specified
Accepted Solution

unexpected type (position:TEXT Connection refus...

Hi,

 

i am trying to access a webservice using ksoap2. I am working in blackberry JDE 4.2.1.

Below is my code snippet:

Code:
       try
         {
             //Create a instance of SoapObject
            String ServiceUrl=<Web Service Url>;
            String serviceNamespace = <Name Space>;
            String SoapAction=<Web Service Url>/HelloWorld;
            SoapObject rpc = new SoapObject(serviceNamespace,"HelloWorld"); 

            SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.bodyOut=rpc;
            envelope.dotNet=true;
            envelope.encodingStyle=SoapSerializationEnvelope.XSD;
            HttpTransport ht=new HttpTransport(ServiceUrl);
            ht.debug=true;  
                 
            try
            {
            ht.call(SoapAction,envelope);      
            String result=(envelope.getResult()).toString();
            }
            catch(org.xmlpull.v1.XmlPullParserException ex2)
            {                
                System.out.println( ht.requestDump.toString());
                System.out.println( ht.responseDump.toString());            
            }            
            //Dialog.alert("Archival Started");
            System.out.println("Archival Started");

            }

            catch(Exception ex)
            {
                System.out.println(ex);
            }

At the line ht.call(SoapAction,envelope);

an org.xmlpull.v1.XmlPullParserException occurs. The details are as follows:


@67EE0000 "unexpected type (position:TEXT Connection refus...@1:30 in java.io.InputStreamReader@7c6b177c) "


I have looked up online but no luck.

Can someone please guide me here.....

Thanks,
Saket

Developer
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified

Re: unexpected type (position:TEXT Connection refus...

Okay,

 

After further consulation with my colleague (Mr.Mahesh Labhe) we seem to have found out what why this error occurs and how to work around it.

 

The issue is in the url to the .net webservice.

 

If you are facing the same issue then please make a sure the following points are addressed:

1) In the ServiceUrl use the hostname ("//hostname:1234/....")of the machine rather than using "//localhost:1234/....". You can get the hostname by typing "hostname" in the command prompt. I guess localhost is relative, so if you use localhost in your url while running the app on the simulator then the simulator considers itself to be the localhost and hence your service will not be detected.

2) Make sure that your web serivce is running when trying to access the service from the client app.

3) If you are unable to directly access the .net webservice try deploying the serive on the IIS.

3) Check the version compatibility of the web service with the IIS. For example if the service is built on .net framework 3.5 then try building the same in 2.0 and check.

4) In IIS goto the properties of the website where you have deployed your service and under the ASP.NET tag change the version to "2.0.XXXXX"

 

After taking care of thr above points we were able to get the app up and running......

Hope this is useful to someone else too.....

 

-Saket

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: unexpected type (position:TEXT Connection refus...

you have solved your specific problem, nonetheless there is another problem with ksoap2 that you did not recognize: it cannot parse http errors. if you want to add this support download ServiceConnectionMidp from the ksoap2 source and overwrite openInputStream.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified

Re: unexpected type (position:TEXT Connection refus...

Hi Simon_hain,

 

Yes i would like to parse http errors. Can you please provide me with the link from where i can download ServiceConnectionMidp and also what steps are needed to be taken after downloading.....

 

Thanks,
Saket

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: unexpected type (position:TEXT Connection refus...

http://ksoap2.sourceforge.net/ is the project homepage.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified

Re: unexpected type (position:TEXT Connection refus...

Thanks for the link.

 

i have already looked up here and could not locate the midp file you mentioned. I know i must be missing something but to me all this is pretty new. So please bear with me and provide me with some more details if possible......

 

Thanks,
Saket

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: unexpected type (position:TEXT Connection refus...

you have to select "browser source" and click yourself through

 

http://ksoap2.svn.sourceforge.net/viewvc/ksoap2/trunk/ksoap2/ksoap2/src_midp/org/ksoap2/transport/Se...

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified

Re: unexpected type (position:TEXT Connection refus...

Thanks......

New Contributor
Posts: 3
Registered: ‎06-27-2010
My Device: 9100
My Carrier: edge

Re: unexpected type (position:TEXT Connection refus...

Hi Saket,

 

I get the same error , since your problem is in resolved status, can you tell me how you solved this problem ?

Highlighted
Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: unexpected type (position:TEXT Connection refus...

welcome to the support forums njsathya. it is best to start a new thread and refer to this one as people tend to ignore solved threads (and rightly so).

 

as for the error you get:

it most likely means that ksoap2 tries to parse an http error message - which it cannot do by default.

you can check your request/response using tcpmon or similar tools.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter