2012-10-19 18 views
3

이것은 WSDL입니다. 나는 php (Yii) 웹 서비스 호출을 통해 Android에 연결했습니다.XmlPullParserException : 예상 : START_TAG <... 정의

<wsdl:definitions name="StatisticController" targetNamespace="http://example.com/webservice/statistic/"> 
    <wsdl:message name="getGeneralstatRequest"/> 
    <wsdl:message name="getGeneralstatResponse"> 
    <wsdl:part name="return" type="xsd:struct"/> 
    </wsdl:message> 
    <wsdl:portType name="StatisticControllerPortType"> 
    <wsdl:operation name="getGeneralstat"> 
     <wsdl:documentation/> 
     <wsdl:input message="tns:getGeneralstatRequest"/> 
     <wsdl:output message="tns:getGeneralstatResponse"/> 
    </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:binding name="StatisticControllerBinding" type="tns:StatisticControllerPortType"> 
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> 
    <wsdl:operation name="getGeneralstat"> 
     <soap:operation soapAction="http://example.com/webservice/statistic/getGeneralstat" style="rpc"/> 
     <wsdl:input> 
      <soap:body use="encoded" namespace="http://example.com/webservice/statistic/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 
     </wsdl:input> 
     <wsdl:output> 
      <soap:body use="encoded" namespace="http://example.com/webservice/statistic/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 
     </wsdl:output> 
    </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:service name="StatisticControllerService"> 
     <wsdl:port name="StatisticControllerPort" binding="tns:StatisticControllerBinding"> 
      <soap:address location="http://example.com/webservice/statistic/ws/1"/> 
     </wsdl:port> 
    </wsdl:service> 

Webservice를가 작동 :하지만

10-19 11:17:36.068: W/System.err(11165): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <{http://schemas.xmlsoap.org/wsdl/}wsdl:definitions name='StatisticController' targetNamespace='http://example.com/webservice/statistic/'>@13:91 in [email protected]) 

XML을 얻을. 나는 http://www.validwsdl.com/

자바 코드 테스트 : 나는 3 주 동안 노력했지만, 그것은 작동하지 않는

private static String domain_name = URLEncoder.encode("example.com"); 
    private static final String METHOD_NAME = "getGeneralstat"; 
    private static final String NAMESPACE = "http://"+ domain_name +"/webservice/statistic/"; 
    //private static final String URL = "http://"+ domain_name +"/webservice/statistic/"; 
    private static final String URL = "http://"+ domain_name +"/webservice/generalstat2.wsdl"; 
    private static final String SOAP_ACTION = NAMESPACE + METHOD_NAME; 
... 
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
    envelope.setOutputSoapObject(request); 
    HttpTransportSE ht = new HttpTransportSE(URL,8000); // trying 8 sec 
    try {  
    ht.debug = true; 
    ht.call(SOAP_ACTION, envelope); 
... 
    } catch ... 
    } catch ... 
    } catch (XmlPullParserException xe) { 
    } catch ... 

. 나는 많은 많은 화제를 읽었지 만 문제는 해결되지 않았습니다.

답변

1

XMLParserException은 두 지점에서 throw 될 수 있습니다.

  1. 라이브러리는 응답 객체가 유효한 XML (예를 들어 당신이
    서버 오류와 HTML 응답을 얻을 수)
  2. 없는 전화 통화 후
  3. , 전에 SoapObject을 생성하려고

XML 서비스가 유효한지 확인하려면 웹 서비스 호출을 디버그하고 HTTPTransportSE 객체의 덤프 변수를 확인하십시오. 또한 덤프 변수의 내용을 soapUI에 복사하여 복사 할 수있는 xml 파트가 작동하지 않는지 확인할 수 있습니다.

http://mspmsp.brinkster.net/MobileJava/ch16.htm 나는 그것이 도움이되기를 바랍니다

작정 저를 도왔다.

+0

고마워요! 나는 그것을 읽고 당신에게 피드백을 줄 것입니다. – Cipo

+0

오류를 극복하도록 도와주었습니다. 고맙습니다. 오류 메시지로 인해 첫 번째 읽기에서 충돌이 발생하고 WSDL을 제대로 이해하지 못했지만 soapAction에 응답하고 동일한 "정의"를 사용하므로 webservice는 ksopa의 함수 호출을 언더 앤드하지 않기 때문에 사용합니다. – Cipo

0

주어진 wsdl이 올바르지 않습니다. 일부 네임 스페이스 선언이 누락되어 더하기 파일 끝에 wsdl : definitions 태그가 제대로 닫히지 않았습니다 (복사 + 붙여 넣기 오류 일 수 있음).

<wsdl:definitions name="StatisticController" 
targetNamespace="http://example.com/webservice/statistic/" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:tns="http://example.com/webservice/statistic/"> 
    <wsdl:message name="getGeneralstatRequest"/> 
    <wsdl:message name="getGeneralstatResponse"> 
    <wsdl:part name="return" type="xsd:struct"/> 
    </wsdl:message> 
    <wsdl:portType name="StatisticControllerPortType"> 
    <wsdl:operation name="getGeneralstat"> 
     <wsdl:documentation/> 
     <wsdl:input message="tns:getGeneralstatRequest"/> 
     <wsdl:output message="tns:getGeneralstatResponse"/> 
    </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:binding name="StatisticControllerBinding" type="tns:StatisticControllerPortType"> 
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> 
    <wsdl:operation name="getGeneralstat"> 
     <soap:operation soapAction="http://example.com/webservice/statistic/getGeneralstat" style="rpc"/> 
     <wsdl:input> 
      <soap:body use="encoded" namespace="http://example.com/webservice/statistic/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 
     </wsdl:input> 
     <wsdl:output> 
      <soap:body use="encoded" namespace="http://example.com/webservice/statistic/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 
     </wsdl:output> 
    </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:service name="StatisticControllerService"> 
     <wsdl:port name="StatisticControllerPort" binding="tns:StatisticControllerBinding"> 
      <soap:address location="http://example.com/webservice/statistic/ws/1"/> 
     </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

내가 빠르고 간단한 검증 단계로 soapUI에 WSDL을 가져 오는 것이 좋습니다 :이 수정 된 버전입니다.

+0

예 (복사 - 붙여 넣기 오류)입니다. 죄송합니다. 당신의 도움을 주셔서 감사합니다. – Cipo

관련 문제