2016-03-31 18 views
0

WebServiceにデータを送信したいが、それが正常に動作し、文字列にエラーを表示するフィードバックを返さなかった。私はKSOAP2を使用しています。 AndroidアプリケーションでWebサービスが動作していません


私はデバッグするとき、私は次のメッセージが出ます:すべてがそれに応じて働いた場合

オブジェクトが収集されてきたが、org.ksoap2.serialization.SoapObject.toString()

を評価することはできません、それは答える必要があります?私に 'OK' が、WebServiceがXML(responseDump)を返します。

< XMLバージョンを= "1.0" エンコード= "UTF-8"> <石鹸:?Envelopexmlns:石鹸= "のhttp://sc hemas.xmlsoap.org/soap/envelope/"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance "xmlns:xsd =" http://www.w3.org/2001/XMLSchema "> < soap:Faultsoap:サーバー</faultcode < faultstring> System.Web.Services.Protocols.SoapException:サーバーが要求を処理できませんでした。 --- > System.InvalidOperationException:CommandTextプロパティが初期化されていません。 System.Data.OracleClient.OracleCommandでSystem.Data.OracleClient.OracleCommand.ExecuteでSystem.Data.OracleClient.OracleCommand.get_StatementText()(OciStatementHandle StatementHandleで、CommandBehaviorの行動、ブールneedRowid、OciRowidDescriptor & rowidDescriptor、ArrayListの& resultParameterOrdinals)で mobPrev_SAP.wsvmetta.EnviarDados(文字列でMettaWebService.MettaServicos.EnviarDados(文字列クエリ)でMettaWebService.BancoDados.executaComando(文字列のクエリ)で.ExecuteNonQueryInternal System.Data.OracleClient.OracleCommand.ExecuteNonQueryで(ブールneedRowid、OciRowidDescriptor & rowidDescriptor)()クエリは、c:¥Users¥Deivite¥AppData¥Local¥Temp¥Compilacao¥wsvMetta_Eng¥wsvmetta.asmx.cs:line 65 --- 内の例外スタックトレースの末尾 ---

ここ

WebServiceの送信および受信するためのコードです:終わり

public String transmitWS(String col_numero, String qtd_consumo, String idate_itime, String vlr_med, 
         String cod_valor, String matric, String texto_obs, String observacao, 
         String idProgramacao){ 
    String HOST = ""; 
    String NAMESPACE = ""; 
    String URL = "";    //all right here 
    String SOAP_ACTION = ""; 
    String METHOD_NAME = ""; 

    String resultWS = null; 

    SoapObject requestTransmit = new SoapObject(NAMESPACE, METHOD_NAME); 
    PropertyInfo transmitPI = new PropertyInfo(); 
    transmitPI.setType(String.class); 
    transmitPI.setName("Query"); 
    transmitPI.setValue("update prev_programacao set col_numero = " + col_numero + ", status_ponto = 3, qtd_consumo =" + qtd_consumo + "," + 
      " idate_itime = TO_DATE('"+ idate_itime +"','YYYY-MM-DD HH24:MI:SS'), vlr_med = " + vlr_med + ", cod_valor = " + cod_valor + 
      ", matric = " + matric +", texto_obs = '" + texto_obs + "', observacao = '" + 
      observacao + "' where id_programacao = "+idProgramacao+""); 
    requestTransmit.addProperty(transmitPI); 
    SoapSerializationEnvelope envelopeTransmit = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
    envelopeTransmit.dotNet = true; 
    envelopeTransmit.setAddAdornments(false); 
    envelopeTransmit.implicitTypes = false; 
    envelopeTransmit.setOutputSoapObject(requestTransmit); 
    HttpTransportSE androidHttpTransportTransmit = new HttpTransportSE(URL); 
    //AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL); 
    try { 
     androidHttpTransportTransmit.debug = true; 
     androidHttpTransportTransmit.call(SOAP_ACTION, envelopeTransmit); 
     SoapObject responseTransmit = (SoapObject) envelopeTransmit.getResponse(); 
     resultWS = androidHttpTransportTransmit.requestDump; 
     resultWS = androidHttpTransportTransmit.responseDump; 

     Log.i("t", "doInBackground"); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
    return resultWS; 
} 

を、resultWSはnullです。 誰もがこのエラーの原因を知っていますか?

答えて

0

何が問題なのかを検出することはできませんが、ここではksoapを使用する機能があります。多分それは助けになるでしょう:

/** 
* Calls the stored proc on the server to return a dataset/SoapObject. This will always run the ProcReader method on the web server. 
* 
* @param storedProc The Stored Proc to call 
* @param params The parameter(s) for the stored proc (pipe seperated for multiple parameters) 
* @return The SoapObject returned by the Stored Proc call 
* @throws Exception 
*/ 
public static SoapObject callProcServiceForObject(String serviceMethod, String storedProc, String params) throws Exception { 
    String NAMESPACE = "http://" + GlobalVars.serviceIP + "/"; 
    String METHOD_NAME = getMethodName(serviceMethod); 
    String SOAP_ACTION = NAMESPACE + METHOD_NAME; 
    String URL = "http://" + GlobalVars.serviceIP + "/ATService.asmx"; 
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

    if (GlobalVars.encryptedService) { 
     request.addProperty("ePassword", CryptUtil.encryptString(GlobalVars.deviceSerialNumber)); 
     request.addProperty("eData", CryptUtil.encryptString(GlobalVars.serverDB)); 
     request.addProperty("eSP_Name", CryptUtil.encryptString(storedProc)); 
     request.addProperty("eParam", CryptUtil.encryptString(params)); 
    } else { 
     request.addProperty("sPassword", GlobalVars.deviceSerialNumber); 
     request.addProperty("sData", GlobalVars.serverDB); 
     request.addProperty("sSP_Name", storedProc); 
     request.addProperty("sParam", params); 
    } 
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 

    // Enable the below property if consuming .Net service 
    envelope.dotNet = true; 
    envelope.setOutputSoapObject(request); 
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL, timeout); 
    //count up the network traffic 
    numberOfBytesTransmitted = numberOfBytesTransmitted + StringToBytes(request.toString()); 

    SoapObject returnable = null; 
    try { 
     androidHttpTransport.call(SOAP_ACTION, envelope); 
     returnable = (SoapObject)envelope.getResponse(); 
    } catch (Exception e) { 
     e.printStackTrace(); 
     throw new Exception("Msg:" + e.getMessage() + "; SP:" + storedProc + "; Params: " + params + "; Method:" + METHOD_NAME); 
    } 
    numberOfBytesTransmitted = numberOfBytesTransmitted + StringToBytes(returnable.toString()); 
    return returnable; 
} 
+0

どのようなコードの違いは? – Mushu

関連する問題