File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes Ksoap Error: expected: START_TAG with sony ericsson w300i when connect with .net ws Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Ksoap Error: expected: START_TAG with sony ericsson w300i when connect with .net ws" Watch "Ksoap Error: expected: START_TAG with sony ericsson w300i when connect with .net ws" New topic
Author

Ksoap Error: expected: START_TAG with sony ericsson w300i when connect with .net ws

Miguel Murillo
Greenhorn

Joined: Aug 21, 2009
Posts: 5
Good morning,

I have an error when intent connect from my Sony Ericsson w300i to an .Net 2005 (asp.net 2.0) webservice:

expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/} Envelope(positions:START_TAG<h1>@1:4 in java.IO.InputStreamReader@23456

The ws receive a String and return a String.


My application use Ksoap2 (core) library. I test the same application in the wireless toolkit 2.5.1 emulator, in a Nokia 6131 and in a Motorola rockr W5, working properly in all. The code I use to connect is:

SoapObject request = new SoapObject(NAMESPACE, "getResultados");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;

envelope.setOutputSoapObject(request);
request.addProperty("pregunta","unapreguntacualquiera");
HttpTransport ht = new HttpTransport(URL);

try
{
ht.call(NAMESPACE + "getResultados", envelope);
SoapObject result = (SoapObject) envelope.bodyIn;
String respuesta = result.getProperty(0).toString();
...


Also I tried with some extra lines:

envelope.encodingStyle = SoapSerializationEnvelope.ENC;

or with:

ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

but not change the result.


Also I monitored the network trafic (when use the emulator) obtaining:


Output (from emulator to ws):

<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
<getResultados xmlns="http://unaempresa.com/" id="o0" c:root="1">
<pregunta i:type="d:string">unapreguntacualquiera</pregunta>
</getResultados>
</v:Body>
</v:Envelope>


Response (from ws to emulator):

HTTP/1.1 200 OK..Server: Microsoft-IIS/5.1..Date: Wed, 19 Aug 2009 13:42:03 GMT..X-Powered-By: ASP.NET..X-AspNet-Version: 2.0.50727..Cache-Control: private, max-age=0..Content-Type: text/xml; charset=utf-8..Content-Length: 442....<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org 2001/XMLSchema">
<soap:Body>
<getResultadosResponse xmlns="http://unaempresa.com/">
<getResultadosResult>unarespuestacualquiera</getResultadosResult>
</getResultadosResponse>
</soap:Body>
</soap:Envelope>


I see all ok... and in the other devices func. Ok...


Thank you for your time!


regards.


excuse me for my poor english.
Aleksandar Babic
Ranch Hand

Joined: May 30, 2007
Posts: 68
See if there is anything interesting on this thread
http://www.coderanch.com/t/416242/Java-Micro-Edition/Mobile/Including-information-SOAP-header-web#1892027
Miguel Murillo
Greenhorn

Joined: Aug 21, 2009
Posts: 5
Hello Aleksandar,
thank you for response me.

We decided suspend the j2me develops because the tests we did on various cell returned very different results depending on each device!!

For example:
Nokia 6131: OK
Sony Ericsson w300i: (Error: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/} Envelope(positions:START_TAG<h1>@1:4 in java.IO.InputStreamReader@23456f).
Motorola Z6: Unable to process command “aceptar”. Blocking call performed in the event thread.
Motorola A1200: touch screen... we need use Canvas to implement in this phone. No test.
Motorola rockr W5: OK
Sony Ericsson w302 when intent install the jar... NO AUTHORIZATION
Nokia 2760: error when intent save a phone number on RMS.

We see that each manufacturer in each model implements in its own way and place restrictions on taste. This prevents us from creating an application that runs on most cell phones properly.

best regards.
Aleksandar Babic
Ranch Hand

Joined: May 30, 2007
Posts: 68
It seems that we're all get used to it over time.
Phone makers will always try to be 'unique'

But regarding your problem, why don't you create soap message manualy.
You don't need ksoap.
Just create message, open connection and write it to OutputStream.
Then read responce with InputStreamReader
(I can find you example with .net authentication etc. if you need)
Miguel Murillo
Greenhorn

Joined: Aug 21, 2009
Posts: 5
Hello Aleksandar,
it´s true, would be a good option to try manually avoiding ksoap.

Be grateful if you have an example to rewrite the application and retest in phones.

Thank you.

regards.
Aleksandar Babic
Ranch Hand

Joined: May 30, 2007
Posts: 68
This is some example for connecting to .net web servise with authentication and retrieve currency list.
(there is more parsing etc. later but it's not important for you)

The thing you need to know is how the soap message should look like.
If you are the one that creates web service than it's easy, but if you have only wsdl file than it can be tricky.
You can create standard java client and debug on request to retrieve exact message, or (better solution)
you can use SoapUI tool, generate client with wsdl, and inspect message in row format.



Hope this helps ;)
Miguel Murillo
Greenhorn

Joined: Aug 21, 2009
Posts: 5
Once again thank Aleksandar.

I use your code and could connect to the ws and get the info!!
(with little changes):

String message = "<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
"xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<soap:Body>"+
"<getEncuestasAResponder xmlns=\"http://mavha.com/\">" +
"<param>unparametro</param>" +
"</getEncuestasAResponder>" +
"</soap:Body>" +
"</soap:Envelope>";

(the rest equal)
...
...


but in the phone... no func!!! intent connect but return nothing... only intent connect (the world icon appear) but later on wait a few seconds disconnects...

I would try changing some parameters and if I could run the application in this phone (sony w300i) ... promise i will post the solution.

In the emulator works perfect!

thank you for your help.

excuse me again for my poor english.
Aleksandar Babic
Ranch Hand

Joined: May 30, 2007
Posts: 68
You're welcome ;)
I'm glad we made some progress.
I'm not sure what can be the problem with your phone but maybe you can check settings for java.
I recall similar problem when java wasn't allowed to use internet or had some restriction on the phone. And check same thing for application (if it has some restriction, or it's not allowed to make connection).

I would suggest that you log current progress of the application on display. When app needs to create connection you log info, after that log if connection is created... etc. for every step of the request (you can also use some logging library like microlog)
That will help you to find out on which line actual problem is and what causes the problem.

( I'm sorry too for my poor english )
Miguel Murillo
Greenhorn

Joined: Aug 21, 2009
Posts: 5
Hello Aleksandar!

I follow your suggest and try display progress in the screen but when the cells crashes can´t print because no return me the control...
I decided use Microlog (thank you for the info, will probe in other Android develop). I follow the steps, using the API (needed add jsr082 (bluetooth API) to compile) and put the code to write a log in a .txt file.

In the emulator works fine (one more time) but in the phone : ask me if I allow him to write, the phone blocks when intent connect with the ws, I force the close and the file never was created. I intented create and write a line in startApp() method (to prevent the block) but the file wasn´t created.

I guess after this... the phone is blocking all actions that involved permission or external libs.

Thank you for your time Aleksandar,
best regards!
Aleksandar Babic
Ranch Hand

Joined: May 30, 2007
Posts: 68
After all, it seems that there is some phone settings that must be changed.

If you handle all exceptions than you should be able to prevent application to crash.
I used to use lwuit framework and it has Dialog form that can be used as info form.
All critical code was handled with try/catch and if exception is thrown, in catch I define Dialog and write exception in it.
Whell, I'm not sure that it will help but who knows.

Best of luck
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ksoap Error: expected: START_TAG with sony ericsson w300i when connect with .net ws