2016-03-22 1 views
0

J'appelle le service web en utilisant Soap dans Android. Mais je reçois une erreurSoapFault - faultcode: 'soap: Client' faultstring: 'Erreur Unmarshalling:

SoapFault - faultcode: 'soap:Client' faultstring: 'Unmarshalling Error: unexpected element (uri:" http://ws.service.tbank.co.th/ ", local:"arg0"). Expected elements are <{}arg0> ' faultactor: 'null' detail: null .

fichier WSDL:

<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ws.service.tbank.co.th/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="BillPaymentValidate" targetNamespace="http://ws.service.tbank.co.th/"> 
<wsdl:types> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://ws.service.tbank.co.th/" targetNamespace="http://ws.service.tbank.co.th/" version="1.0"> 
<xs:element name="validateRef1" type="tns:validateRef1"/> 
<xs:element name="validateRef1Response" type="tns:validateRef1Response"/> 
<xs:complexType name="validateRef1"> 
<xs:sequence> 
<xs:element minOccurs="0" name="arg0" type="xs:string"/> 
</xs:sequence> 
</xs:complexType> 
<xs:complexType name="validateRef1Response"> 
<xs:sequence> 
<xs:element name="return" type="xs:boolean"/> 
</xs:sequence> 
</xs:complexType> 
</xs:schema> 
</wsdl:types> 
<wsdl:message name="validateRef1"> 
<wsdl:part element="tns:validateRef1" name="parameters"></wsdl:part> 
</wsdl:message> 
<wsdl:message name="validateRef1Response"> 
<wsdl:part element="tns:validateRef1Response" name="parameters"></wsdl:part> 
</wsdl:message> 
<wsdl:portType name="BillPaymentValidateImpl"> 
<wsdl:operation name="validateRef1"> 
<wsdl:input message="tns:validateRef1" name="validateRef1"></wsdl:input> 
<wsdl:output message="tns:validateRef1Response" name="validateRef1Response"></wsdl:output> 
</wsdl:operation> 
</wsdl:portType> 
<wsdl:binding name="BillPaymentValidateSoapBinding" type="tns:BillPaymentValidateImpl"> 
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 
<wsdl:operation name="validateRef1"> 
<soap:operation soapAction="" style="document"/> 
<wsdl:input name="validateRef1"> 
<soap:body use="literal"/> 
</wsdl:input> 
<wsdl:output name="validateRef1Response"> 
<soap:body use="literal"/> 
</wsdl:output> 
</wsdl:operation> 
</wsdl:binding> 
<wsdl:service name="BillPaymentValidate"> 
<wsdl:port binding="tns:BillPaymentValidateSoapBinding" name="BillPaymentValidateImplPort"> 
<soap:address location="http://TB58DBWHH3201P:8080/TbankWSService/BillPaymentValidate"/> 
</wsdl:port> 
</wsdl:service> 
</wsdl:definitions> 

SOAP request 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.service.tbank.co.th/"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <ws:validateRef1> 
     <arg0>1234567890</arg0> 
     </ws:validateRef1> 
    </soapenv:Body> 
</soapenv:Envelope> 

Example: SOAP response 
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
     <ns2:validateRef1Response xmlns:ns2="http://ws.service.tbank.co.th/"> 
     <return>true</return> 
     </ns2:validateRef1Response> 
    </soap:Body> 
</soap:Envelope> 

My code : 

public class Soap { 

    public boolean GetValidate(String billReference) { 
     String URL = "http://192.168.1.101:8080/TbankWSService/BillPaymentValidate?WSDL"; 
     String NAMESPACE = "http://ws.service.tbank.co.th/"; 
     String METHOD = "validateRef1"; 
     String SOAP_ACTION = ""; 
     boolean validation = false; 
     String result; 

     //Create request 
     SoapObject request = new SoapObject(NAMESPACE, METHOD); 
     PropertyInfo PI = new PropertyInfo(); 
     PI.setName("arg0"); 
     PI.setValue(billReference); 
     PI.setType(String.class); 
     request.addProperty(PI); 
     //Create envelope 
     SoapSerializationEnvelope envelope = 
       new SoapSerializationEnvelope(SoapEnvelope.VER11); 
     envelope.dotNet = true; 
     //Set output SOAP object 
     envelope.setOutputSoapObject(request); 
     // Create HTTP call object 
     HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 
     Log.d("Aamir","calling URL"); 

     androidHttpTransport.debug=true; 
     try { 
      // Invoke web service 
      androidHttpTransport.call(SOAP_ACTION, envelope); 
      Log.d("Aamir","Aamir"); 
      // Get the response 
      SoapPrimitive response = (SoapPrimitive) envelope.getResponse(); 
      //SoapObject response = (SoapObject) envelope.getResponse(); 
      Log.d("Aamir","Response :"+response); 

      // Assign it to boolean variable variable 
      validation = Boolean.parseBoolean(response.toString()); 

     } catch (Exception e) { 
      //Assign Error Status true in static variable 'errored' 
      Log.d("Aamir", "Exception"); 
      e.printStackTrace(); 
     } 
     return validation; 
    } 
} 

Je reçois une erreur:

03-22 12:47:05.613 2466 2490 W System.err: SoapFault - faultcode: 'soap:Client' faultstring: 'Unmarshalling Error: unexpected element (uri:"http://ws.service.tbank.co.th/", local:"arg0"). Expected elements are <{}arg0> ' faultactor: 'null' detail: null 

03-22 12:47:05.614 2466 2490 W System.err: at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:137) 

03-22 12:47:05.614 2466 2490 W System.err: at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:140) 

03-22 12:47:05.614 2466 2490 W System.err: at org.ksoap2.transport.Transport.parseResponse(Transport.java:129) 

03-22 12:47:05.614 2466 2490 W System.err: at org.ksoap2.transport.HttpTransportSE.parseResponse(HttpTransportSE.java:301) 

03-22 12:47:05.614 2466 2490 W System.err: at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:274) 

03-22 12:47:05.614 2466 2490 W System.err: at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:118) 

03-22 12:47:05.614 2466 2490 W System.err: at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:113) 

03-22 12:47:05.614 2466 2490 W System.err: at com.example.myapp.Soap.GetValidate(Soap.java:45) 

03-22 12:47:05.614 2466 2490 W System.err: at com.example.myapp.MyActivity$AsyncCallSoap.doInBackground(MyActivity.java:44) 
+0

Aidez un peu de votre corps à résoudre cette erreur .. please –

Répondre

0

je trouve la solution. C'est parce que je me trompe demande .. Besoin de vérifier la demande. vous pouvez le faire en utilisant Log.d (TAG, "requestdump:" + androidHttpTransport.requestDump); Log.d (TAG, "responseDump:" + androidHttpTransport.responseDump);

ET VÉRIFIEZ l'espace de noms. vous devrez peut-être jouer avec l'espace de noms qui est arrivé dans mon cas.