1

I'm trying to invoke a webservice and parse the returned XML, so my invoke URL is :

http://192.168.1.12/cr.ws/CarCategories.asmx/CarCategoryComparatorRQ?IdUser=1076&IdCurrency=1&IdLanguage=1&IdCarCategory=0&IdPickupRentCarAgencies=3&IdReturnRentCarAgencies=3&PickupDate=6/4/2011&ReturnDate=9/4/2011&Supplier=Prima%20Rent%20a%20Car&b=prima

in my browser I get the desired response :

<CarCategoryComparatorRS>
<CarCategory>
<IdCar>22</IdCar>
<IdCarCategory>22</IdCarCategory>
<Supplier>AvantGarde Rent a Car</Supplier>
<PickupRentCarAgencies>Tunis; Aéroport de Tunis-Carthage</PickupRentCarAgencies>
<IdPickupRentCarAgencies>5</IdPickupRentCarAgencies>
<ReturnRentCarAgencies>Tunis; Aéroport de Tunis-Carthage</ReturnRentCarAgencies>
<IdReturnRentCarAgencies>5</IdReturnRentCarAgencies>
<IdUser>705</IdUser>
<Title>Catégorie A [ex:Kia Rio;Renault Symbol]</Title>
<IdCurrency>1</IdCurrency>
<ImageUrl>Car-22-20090521-125545.jpg</ImageUrl>
<MemberReductionValue>0</MemberReductionValue>
<Rate>150</Rate>
<DelayRate>0</DelayRate>
<ReductionValue>135</ReductionValue>
<DayRate>45</DayRate>
<Reduction>10%</Reduction>
<AccompteValue>67.500</AccompteValue>
<Accompte>50</Accompte>
<TotalRate>0000135000</TotalRate>
</CarCategory>
</CarCategoryComparatorRS>

But this function trows java.io.FileNotFoundException

protected InputStream getInputStream() {
 try {
 return feedUrl.openConnection().getInputStream();
 } catch (IOException e) {
 throw new RuntimeException(e);
 }

Please help me, I wasted couple hours searching but nothing :(

Thanks.

asked Apr 3, 2011 at 21:46

4 Answers 4

3

The error is caused by the spaces in this param :"Supplier=Prima Rent a Car", so i replaced this param by UrlEncoder.encode("Supplier=Prima Rent a Car") and it worked.

answered Apr 4, 2011 at 7:46
Sign up to request clarification or add additional context in comments.

1 Comment

This method is deprecated. One should use URLEncoder.encode(String, String), where the second paramether is the encoding ("UTF-8" for an example)
0

If you type that URL in your device's browser address bar do you get anything?

answered Apr 3, 2011 at 23:10

1 Comment

Yes i got the XML i mentioned earlier.
0

It looks like you are trying to request an address on a local machine or LAN. Are you requesting this on the android device? My guess is you need to run your server on the machine on a different interface or open up connections to the required port.

answered Apr 3, 2011 at 23:56

1 Comment

in fact the service runs on a real server, but for security reasons I changed the address by a local url.
0

I think your url is being interpreted as a file url.

What about logging your url before you call openConnection as a sanity check:

Log.e("MyApp", feedUrl);

On second thought, could you post the logcat output? I'm skeptical as to how your code could ever throw a FileNotFoundException.

answered Apr 4, 2011 at 2:03

3 Comments

Finally I solved this, there's a param in that url which causes this error, so for this param i used UrlEncoder.encode(param) and it worked like a charm
Great. Might I ask which characters were causing the problem?
this param : "Supplier=Prima Rent a Car" the spaces between the words seem to be the cause

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.