2011-03-11 2 views
1

WCF 서비스 .NET4 (SOAP)를 개발했으며이를 Android에서 사용하려고합니다. 는하지만 난이 오류가 얻을 문제 :이 줄WCF 서비스 및 Ksoap2를 사용하여 android에서 파일 업로드

org.xmlpull.v1.XmlPullParserException: expected: END_TAG {http://schemas.xmlsoap.org/soap/envelope/}Body (position:END_TAG @1:761 in [email protected])

을 :

private static final String SOAP_ACTION = "http://tempuri.org/OCRWebService/extractText"; 
private static final String METHOD_NAME = "extractText"; 
private static final String NAMESPACE = "http://tempuri.org/"; 
private static final String URL = "http://10.0.2.2/ocrwebservice/Service.svc"; 
private String extractText(byte[] _data){ 
    try { 

      SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 
      PropertyInfo p1=new PropertyInfo(); 
      p1.setName("image2up"); 
      p1.setType(_data); 
      request.addProperty(p1); 
      SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
      envelope.dotNet=true; 
      envelope.setOutputSoapObject(request); 
      AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL); 
      androidHttpTransport.debug=true; 
      androidHttpTransport.call(SOAP_ACTION, envelope); // error here 
      SoapObject result=(SoapObject)envelope.getResponse(); 
      String resultData=result.getProperty(0).toString(); 

     } catch (Exception e) { 
      Log.i("123",e.getMessage()); 
      } 
    return "false"; 

}

(내용 : 여기

androidHttpTransport.call(SOAP_ACTION, envelope); 

내 코드 나는 wcf servcice를 사용하여 안드로이드 장치에서 내 서버로 파일을 업로드하고 싶습니다.)

답변

0

이미지를 서버에 업로드하려고 시도했지만, 파서 예외가 아닌 직렬화 예외가 발생했습니다. 나는 ..... 문제는 내가 확실하지 않다 ... 것입니다 수 also.May URL에 구현하는

0
public void testWebService(Bitmap bmp) 
{ 
    MarshalBase64 marshal = new MarshalBase64(); 
    ByteArrayOutputStream out = new ByteArrayOutputStream(); 
    bmp.compress(CompressFormat.PNG, 100, out); 
    byte[] raw = out.toByteArray(); 
    SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, OPERATION_NAME); 
    request.addProperty("image", raw); 
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
    envelope.dotNet = true; 
    envelope.setOutputSoapObject(request); 
    marshal.register(envelope); 
    HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS); 
    try 
    { 
     httpTransport.call(SOAP_ACTION, envelope); 
     Object response = envelope.getResponse(); 
    } 
    catch (Exception exception) 
    { 
     exception.printStackTrace(); 
    } 
} 

봅니다 ..

+0

이것은 중복되지만 작동합니다. –

0

가 귀하의 오류로 인해 발생을 메소드 이름을 언급 SOAP_ACTION :

는 SOAP의 행동에 유 지정 http://packagename/method 유 그래서이에 SOAP 동작을 수정

전화 : 최종 문자열 SOAP_ACTION = "http://tempuri.org/extractText"; final String NAMESPACE = "http://tempuri.org/";

이 함께 시도 작동하지 않는 경우

최종 문자열 SOAP_ACTION = "http://tempuri.org/extractText"; final String NAMESPACE = "http : //org.tempury/";

희망이 있습니다. 마이크!

관련 문제