2011-01-01 14 views
2

のために私はここでOK SOAPUIでソープ障害VersionMismatch KSOAP2は、Android

http://srilanka.lk:9080/services/CropServiceProxy?wsdl

作品をホストされているWebサービスにアクセスしようとしています。私はそれに適切な応答を得る。

SOAPUI要求

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:v1="http://schemas.icta.lk/xsd/crop/handler/v1/"> 
    <soap:Header/> 
    <soap:Body> 
     <v1:getCropDataList> 
     <v1:code>ABK</v1:code> 
     </v1:getCropDataList> 
    </soap:Body> 
</soap:Envelope> 

SOAPUI応答

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> 
    <soapenv:Body> 
     <ns1:getCropDataListResponse xmlns:ns1="http://schemas.icta.lk/xsd/crop/handler/v1/"> 
     <ns1:cropInfo> 
      <ns1:name>Ambul Kesel</ns1:name> 
      <ns1:price>35.0</ns1:price> 
      <ns1:location>Dambulla</ns1:location> 
     </ns1:cropInfo> 
     <ns1:cropInfo> 
      <ns1:name>Ambul Kesel</ns1:name> 
      <ns1:price>40.0</ns1:price> 
      <ns1:location>Dambulla</ns1:location> 
     </ns1:cropInfo> 
     </ns1:getCropDataListResponse> 
    </soapenv:Body> 
</soapenv:Envelope> 

しかしKsoap2でSOAP応答をAndroid用エラーです。以下はそれぞれrequestDumpとresponseDumpです。

requestDump

<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"> 
<v:Header /> 
<v:Body> 
<n0:getCropDataList id="o0" c:root="1" xmlns:n0="http://schemas.icta.lk/xsd/crop/handler/v1/"> 
<code i:type="d:string">CNT</code> 
</n0:getCropDataList> 
</v:Body> 
</v:Envelope> 

responseDump

<?xml version='1.0' encoding='UTF-8'?> 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"> 
<wsa:Action>http://www.w3.org/2005/08/addressing/soap/fault</wsa:Action> 
<wsa:RelatesTo>urn:uuid:3257ABC779195052D01293913466558</wsa:RelatesTo> 
</soapenv:Header> 
<soapenv:Body> 
<soapenv:Fault> 
<faultcode>VersionMismatch</faultcode> 
<faultstring>Only SOAP 1.1 or SOAP 1.2 messages are supported in the system</faultstring> 
<detail /> 
</soapenv:Fault> 
</soapenv:Body> 
</soapenv:Envelope> 

は、ここに私のコードです。

public void btnOnClick(View v){ 
     String NAMESPACE = "http://schemas.icta.lk/xsd/crop/handler/v1/"; 
     String URL = "http://220.247.225.202:9080/services/CropServiceProxy.CropServiceProxyHttpSoap12Endpoint"; 

     String METHOD_NAME = "getCropDataList"; 
     String SOAP_ACTION = "http://schemas.icta.lk/xsd/crop/handler/v1/getCropDataList"; 

     SoapObject soap_request = new SoapObject(NAMESPACE, METHOD_NAME); 
     soap_request.addProperty("code", "ABK"); 

     SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12); 
     envelope.setOutputSoapObject(soap_request); 
     envelope.addMapping(NAMESPACE, "cropInfo", CropInfo.class); 
     envelope.dotNet=false; 

     Marshal floatMarshal = new MarshalFloat(); 
     floatMarshal.register(envelope); 

     System.out.println("body out : " + envelope.bodyOut.toString()); 

     AndroidHttpTransport http_transport = new AndroidHttpTransport(URL); 
     //HttpTransportSE http_transport = new HttpTransportSE(URL); 
     http_transport.debug = true; 
     try { 
      http_transport.call(SOAP_ACTION, envelope);   

      //because we should expect a vector, two kinds of prices are given 
      Vector<CropInfo> result_array = (Vector<CropInfo>)envelope.getResponse(); 
      if(result_array != null){ 
       for (CropInfo current_crop: result_array){ 
        System.out.println(current_crop.getName()); 
        System.out.println(Float.toString(current_crop.getPrice())); 
       } 
      } 

     } catch (Exception e) { 
      e.printStackTrace(); 
      answer.setText("error caught"); 
      System.out.print("REQUEST: "); 
      System.out.println(http_transport.requestDump); 
      System.out.print("RESPONSE: "); 
      System.out.println(http_transport.responseDump); 
     } 



    } 

このためにKsoap2で適切な応答を得るにはどうすればよいですか?

+0

バージョン1.1を使用しましたか? – bigstones

+1

ちょうど私の5セント - それはメインのUIスレッド上で実行されるので、クリックリスナーですべてのものを行うことは非常に危険です。したがって、コード全体が実行されるまで、UIはブロックされます。無線範囲が悪い(ネットワーク速度が遅い)ケースを想像してください - ANR(アプリケーションが応答しない)エラーポップアップを取得するのは非常に簡単です。これを避けるために、クリックリスナーは他の(UI以外の) 'Thread'を起動する必要があります。そうしないと、' AsyncTask'を使うことを好むでしょう。 –

+0

1.1では、次のエラーが発生します。 soapenv:サーバー org.apache.axis2.databinding。ADBException:予期せぬサブ要素コード Chamila

答えて

0

あなたは1.1を使用していて、エラーメッセージをチェックアウトする必要があります。サーバー側のaxis2の何かに、コードサブ要素に問題があります。 implicitTypesをfalseに設定する必要があるかもしれません。封筒にいくつかのオプションを試してみてください。

0

SOAP標準の複数の仕様は、現在、あなたがここに

SoapSerializationEnvelopeエンベロープ=新しいSoapSerializationEnvelope(SoapEnvelope.VER12)を見ることができるように、標準のSOAP 1.2を使用してリクエストを送信しようとしている、があります。

は、あなたがこのようなSOAP 1.1標準としてリクエストを送信する必要があり、修正するには:

SoapSerializationEnvelopeエンベロープ=新しいSoapSerializationEnvelope(SoapEnvelope.VER11)。

0

コードオブジェクトの名前空間を設定していないようです。ターゲットネームスペースをhttp://schemas.icta.lk/xsd/crop/handler/v1/に設定するか、コードエレメントにn0名前空間を追加するかを確認する必要があります。

<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/"   xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"> 
    <v:Header /> 
    <v:Body> 
    <n0:getCropDataList id="o0" c:root="1" xmlns:n0="http://schemas.icta.lk/xsd/crop/handler/v1/"> 
     <n0:code i:type="d:string">CNT</code> 
    </n0:getCropDataList> 
    </v:Body> 
</v:Envelope>