2017-03-02 3 views
0

"서버가 요청을 처리 할 수 ​​없습니다 ---> 인스턴스 오류"라는 오류 메시지가 나타납니다. SOAP 웹 서비스로 이미지를 업로드하려고 할 때.SOAP 웹 서비스로 서버에 이미지 업로드

제가 여기 붙어있어서 도와주세요. 나뿐만 바이트 배열 및 프로세스에 이미지를 변환

private class UploadImage extends AsyncTask<String, Void, String> { 
    @Override 
    protected void onPreExecute() { 
     progressDialog = new ProgressDialog(UploadImageActivity.this); 
     progressDialog.setIndeterminate(false); 
     progressDialog.setCancelable(false); 
     progressDialog.setMessage("Please wait.."); 
     progressDialog.show(); 
    } 

    @Override 
    protected String doInBackground(String... params) { 
     ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
     bitmap.compress(Bitmap.CompressFormat.PNG, 90, baos); 
     //bMap is the bitmap object 
     byte[] imagebyte = baos.toByteArray(); 

     SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);   
     request.addProperty("Email", UserContext.email); 
     request.addProperty("MobileNo", UserContext.mobilenumber); 
     request.addProperty("Image", imagebyte); 
     request.addProperty("Flage_InsertiedBy", UserContext.Flage_InsertiedBy); 

     SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
     envelope.dotNet = true; 
     envelope.setOutputSoapObject(request); 
     new MarshalBase64().register(envelope); 

     HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 
     try { 
      androidHttpTransport.call(SOAP_ACTION, envelope); 
      SoapPrimitive response = (SoapPrimitive) envelope.getResponse(); 
      webResponse = response.toString(); 
      System.out.println("test response upload " + webResponse); 
     } catch (Exception e) { 
      System.out.println("test response upload ex " + e.getMessage()); 
     } 
     return webResponse; 
    } 

    @Override 
    protected void onPostExecute(String result) { 
     progressDialog.dismiss(); 
    } 
+0

'request.addProperty ("Image", imagebyte);'. 비누 서버에만 텍스트를 보낼 수 있다고 생각하십시오. 바이트가 아닙니다. 컴파일러는 여러분의 코드를'request.addProperty ("Image", imagebyte.toString());로 변환하여 바이트에서 문자열을 만들려고 시도합니다. 하지만 바이트 배열의 내용은 문자열로 보내지는 것이 아니라 배열의 Java 식별자 인 @ 12345ade와 같은 문자열로 전송됩니다. 참조하려면 imagebyte.toString()을 인쇄하십시오. – greenapps

답변

0

:

여기 내 코드입니다. 매력처럼 작동

String NAMESPACE = "http://Webservices.MyDomain.com/WebServices";  
String METHOD_NAME = "UploadRequestImage"; 
String SOAP_ACTION = "http://Webservices.MyDomain.com/WebServices/UploadRequestImage"; 
String URL = "http://webservices.MyDomain.com/webservices/UpdateData.asmx";    

SoapObject table = null;      // Contains table of dataset that returned through SoapObject 
SoapObject client = null;      // Its the client petition to the web service   
SoapObject responseBody = null;     // Contains XML content of dataset     
SoapSerializationEnvelope sse = null; 

sse = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
new MarshalBase64().register(sse); 
sse.addMapping(NAMESPACE, "movie", this.getClass()); 
//Note if class name isn't "movie" ,you must change 
sse.dotNet = true; // if WebService written .Net is result=true 
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL, 600000);   

try { 
    client = new SoapObject(NAMESPACE, METHOD_NAME); 
    client.addProperty("TicketId", MyTicketId);  
    client.addProperty("UserId", UserId);  
    client.addProperty("imageBytes", ByteArray);  
    client.addProperty("FileName", "Image_" + SelectedId + ".jpg"); 
    sse.setOutputSoapObject(client); 
    sse.bodyOut = client; 
    androidHttpTransport.call(SOAP_ACTION, sse); 

    // This step: get file XML 
    responseBody = (SoapObject) sse.getResponse(); 
    // remove information XML,only retrieved results that returned 

    responseBody = (SoapObject) responseBody.getProperty(1); 
    // get information XMl of tables that is returned 

    table = (SoapObject) responseBody.getProperty(0); 

}//try block 
catch (Exception e) { 
    Log.d("ETC", e.getMessage());      
    return null; 
}//catch 

return table;