开发者

getInputStream throws Exception

开发者 https://www.devze.com 2023-02-21 15:43 出处:网络
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

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&Pick开发者_高级运维upDate=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.


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.


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


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号