【问题标题】:Illegal Property error using ksoap in android-studio在 android-studio 中使用 ksoap 的非法属性错误
【发布时间】:2019-02-06 20:53:15
【问题描述】:

我正在尝试使用 kSoap 库来检索一些公交车站数据。以下是有关我正在尝试提出的请求的一些详细信息。 details

每当我尝试获得结果响应时,我都会收到以下错误;

java.lang.RuntimeException: illegal property: GetRealTimeStopDataResult

这是我检索 RealTimeResult 的尝试:

class CallWebService extends AsyncTask<String, Void, String> {
    @Override
    protected void onPostExecute(String s) {
        text.setText("Bus = " + s);
    }

    @Override
    protected String doInBackground(String... params) {
        SoapObject result;
        int i = 999;
        String resString = "";
        SoapObject soapObject = new SoapObject(NAMESPACE, METHOD_NAME);

        PropertyInfo propertyInfo = new PropertyInfo();
        propertyInfo.setName(PARAMETER_NAME1);
        propertyInfo.setValue(params[0]);
        propertyInfo.setType(String.class);

        PropertyInfo propertyInfo1 = new PropertyInfo();
        propertyInfo1.setName(PARAMETER_NAME2);
        propertyInfo1.setValue("true");
        propertyInfo1.setType(String.class);

        soapObject.addProperty(propertyInfo);
        soapObject.addProperty(propertyInfo1);

        SoapSerializationEnvelope envelope =  new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(soapObject);

        HttpTransportSE httpTransportSE = new HttpTransportSE(URL);

        try {
            httpTransportSE.call(SOAP_ACTION, envelope);
            SoapObject soapPrimitive = (SoapObject) envelope.bodyIn;
            SoapObject body = (SoapObject) soapPrimitive.getProperty(0);
            resString = body.getProperty("GetRealTimeStopDataResult").toString();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return resString;
    }

引用的变量是;

String URL = "http://rtpi.dublinbus.ie/DublinBusRTPIService.asmx?WSDL";
String NAMESPACE = "http://dublinbus.ie/";
String SOAP_ACTION = "http://dublinbus.ie/GetRealTimeStopData";
String METHOD_NAME = "GetRealTimeStopData";
String PARAMETER_NAME1 = "stopId";
String PARAMETER_NAME2 = "forceRefresh";

编辑: 记录 body.toString() 显示:

anyType{schema=anyType{element=anyType{complexType=anyType{choice=anyType{element=anyType{complexType=anyType{sequence=anyType{element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; }; }; }; }; }; }; }; diffgram=anyType{DocumentElement=anyType{StopData=anyType{ServiceDelivery_ResponseTimestamp=2019-02-06T21:14:18.243+00:00; ServiceDelivery_ProducerRef=bac; ServiceDelivery_Status=true; ServiceDelivery_MoreData=false; StopMonitoringDelivery_Version=1.0; StopMonitoringDelivery_ResponseTimestamp=2019-02-06T21:14:18.243+00:00; StopMonitoringDelivery_RequestMessageRef=anyType{}; MonitoredStopVisit_RecordedAtTime=2019-02-06T21:14:18.243+00:00; MonitoredStopVisit_MonitoringRef=4903; MonitoredVehicleJourney_LineRef=39; MonitoredVehicleJourney_DirectionRef=Inbound; FramedVehicleJourneyRef_DataFrameRef=2019-02-06; FramedVehicleJourneyRef_DatedVehicleJourneyRef=696; MonitoredVehicleJourney_PublishedLineName=39; MonitoredVehicleJourney_OperatorRef=bac; MonitoredVehicleJourney_DestinationRef=7339; MonitoredVehicleJourney_DestinationName=Burlington Road via Blanchardstown S.C.; MonitoredVehicleJourney_Monitored=true; MonitoredVehicleJourney_InCongestion=false; MonitoredVehicleJourney_BlockRef=39015; MonitoredVehicleJourney_VehicleRef=33598; MonitoredCall_VisitNumber=34; MonitoredCall_VehicleAtStop=false; MonitoredCall_AimedArrivalTime=2019-02-06T21:18:26+00:00; MonitoredCall_ExpectedArrivalTime=2019-02-06T21:18:26+00:00; MonitoredCall_AimedDepartureTime=2019-02-06T21:18:26+00:00; MonitoredCall_ExpectedDepartureTime=2019-02-06T21:18:26+00:00; Timestamp=2019-02-06T21:14:18.567+00:00; LineNote=anyType{}; }; StopData=anyType{ServiceDelivery_ResponseTimestamp=2019-02-06T21:14:18.243+00:00; ServiceDelivery_ProducerRef=bac; ServiceDelivery_Status=true; ServiceDelivery_MoreData=false; StopMonitoringDelivery_Version=1.0; StopMonitoringDelivery_ResponseTimestamp=2019-02-06T21:14:18.243+00:00; StopMonitoringDelivery_RequestMessageRef=anyType{}; MonitoredStopVisit_RecordedAtTime=2019-02-06T21:14:18.243+00:00; MonitoredStopVisit_MonitoringRef=4903; MonitoredVehicleJourney_LineRef=37; MonitoredVehicleJourney_DirectionRef=Inbound; FramedVehicleJourneyRef_DataFrameRef=2019-02-06; FramedVehicleJourneyRef_DatedVehicleJourneyRef=3984; MonitoredVehicleJourney_PublishedLineName=37; MonitoredVehicleJourney_OperatorRef=bac; MonitoredVehicleJourney_DestinationRef=7340; MonitoredVehicleJourney_DestinationName=Wilton Terrace via Castleknock; MonitoredVehicleJourney_Monitored=true; MonitoredVehicleJourney_InCongestion=false; MonitoredVehicleJourney_BlockRef=37008; MonitoredVehicleJourney_VehicleRef=44253; MonitoredCall_VisitNumber=4; MonitoredCall_VehicleAtStop=false; MonitoredCall_AimedArrivalTime=2019-02-06T21:32:53+00:00; MonitoredCall_ExpectedArrivalTime=2019-02-06T21:32:53+00:00; MonitoredCall_AimedDepartureTime=2019-02-06T21:32:53+00:00; MonitoredCall_ExpectedDepartureTime=2019-02-06T21:32:53+00:00; Timestamp=2019-02-06T21:14:18.583+00:00; LineNote=anyType{}; }; StopData=anyType{ServiceDelivery_ResponseTimestamp=2019-02-06T21:14:18.243+00:00; ServiceDelivery_ProducerRef=bac; ServiceDelivery_Status=true; ServiceDelivery_MoreData=false; StopMonitoringDelivery_Version=1.0; StopMonitoringDelivery_ResponseTimestamp=2019-02-06T21:14:18.243+00:00; StopMonitoringDelivery_RequestMessageRef=anyType{}; MonitoredStopVisit_RecordedAtTime=2019-02-06T21:14:18.243+00:00; MonitoredStopVisit_MonitoringRef=4903; MonitoredVehicleJourney_LineRef=39; MonitoredVehicleJourney_DirectionRef=Inbound; FramedVehicleJourneyRef_DataFrameRef=2019-02-06; FramedVehic

【问题讨论】:

    标签: java android soap android-ksoap2


    【解决方案1】:

    您应该首先在http://rtpi.dublinbus.ie/DublinBusRTPIService.asmx?WSDL 加载/转换WSDL(这不是端点URL,就像您的代码对待它一样),以便拥有SOAP 响应的类;在有可用的WDSL 文件时不建议使用通用类(这确实是值得感激的,因为它准确地描述了要使用的网络服务)。例如wsdl2ksoapSoapUI。另请参阅我添加的android-ksoap2 标签。

    http://rtpi.dublinbus.ie/DublinBusRTPIService.asmx 好像是终点,

    没有?WSDL... 否则你可以发布任何你想要的并且总是会得到WSDL

    产生这些类:

    http://rtpi.dublinbus.ie/DublinBusRTPIService.asmx?WSDL
    Service Name: DublinBusRTPIService
    Element Class: TestService Properties: 0
    Element Class: TestServiceResponse Properties: 1
    Element Class: GetRealTimeStopData Properties: 2
    Element Class: GetRealTimeStopDataResponse Properties: 1
    Element Class: GetRealTimeStopDataResult Properties: 0
    Element Class: GetRealTimeStopData_ForceLineNoteVisit Properties: 3
    Element Class: GetRealTimeStopData_ForceLineNoteVisitResponse Properties: 1
    Element Class: GetRealTimeStopData_ForceLineNoteVisitResult Properties: 0
    Element Class: GetRoutes Properties: 1
    Element Class: GetRoutesResponse Properties: 1
    Element Class: GetRoutesIncNiteLink Properties: 1
    Element Class: GetRoutesIncNiteLinkResponse Properties: 1
    Element Class: GetRoutesIncNiteLink_MobileFareCalc Properties: 1
    Element Class: GetRoutesIncNiteLink_MobileFareCalcResponse Properties: 1
    Element Class: GetDestinations Properties: 1
    Element Class: GetDestinationsResponse Properties: 1
    Element Class: GetAllDestinations Properties: 0
    Element Class: GetAllDestinationsResponse Properties: 1
    Element Class: GetStopDataByAddress Properties: 1
    Element Class: GetStopDataByAddressResponse Properties: 1
    Element Class: GetStopDataByAddressResult Properties: 0
    Element Class: GetStopDataByRouteAndDirection Properties: 2
    Element Class: GetStopDataByRouteAndDirectionResponse Properties: 1
    Element Class: GetStopDataByRouteAndDirectionResult Properties: 0
    Element Class: GetStopDataByRouteAndDirection_MobileFareCalc Properties: 2
    Element Class: GetStopDataByRouteAndDirection_MobileFareCalcResponse Properties: 1
    Element Class: GetStopDataByRouteAndDirection_MobileFareCalcResult Properties: 0
    Element Class: GetStopDataByRoute Properties: 1
    Element Class: GetStopDataByRouteResponse Properties: 2
    Element Class: GetStopDataByRouteResult Properties: 1
    Element Class: GetRoutesServicedByStopNumber Properties: 1
    Element Class: GetRoutesServicedByStopNumberResponse Properties: 1
    Element Class: StartTimer Properties: 0
    Element Class: StartTimerResponse Properties: 1
    Element Class: StopTimer Properties: 0
    Element Class: StopTimerResponse Properties: 1
    Element Class: GetCurrentSettings Properties: 0
    Element Class: GetCurrentSettingsResponse Properties: 1
    Element Class: SetCurrentSettings Properties: 1
    Element Class: SetCurrentSettingsResponse Properties: 0
    Element Class: postXMLData Properties: 2
    Element Class: postXMLDataResponse Properties: 1
    Element Class: ClearCacheItem Properties: 1
    Element Class: ClearCacheItemResponse Properties: 1
    SuperClass: BaseObject
    Complex Type: RoutesResponse Properties: 1
    SuperClass: BaseObject
    Complex Type: ArrayOfRoute Properties: 1
    SuperClass: BaseObject
    Complex Type: Route Properties: 19
    SuperClass: BaseObject
    Complex Type: Destination Properties: 6
    SuperClass: BaseObject
    Complex Type: DestinationsResponse Properties: 1
    SuperClass: BaseObject
    Complex Type: ArrayOfDestination Properties: 1
    SuperClass: BaseObject
    Complex Type: ArrayOfString Properties: 1
    Class Count: 44
    Complex Types: 7
    Woohoo
    

    【讨论】:

    • 这是一个非常有用的答案,我以后会看看这些东西。但是我仍然不确定如何使用它来帮助我处理我的回复我正在获取(请参阅我帖子底部的编辑)我不确定如何正确解析此信息以访问其中嵌入的信息。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-24
    • 1970-01-01
    • 2016-04-07
    • 2015-08-23
    相关资源
    最近更新 更多