2014-04-10 1 views
-4

내 질문은 항상 ksoap2 라이브러리를 사용하는 사람들에게 간단해야합니다. 웹 서비스에서 내 웹 메소드 중 하나는 두 가지 속성을 가지고 있으므로 이클립스에서 addproperty를 사용하여 웹에 두 데이터를 전달하는 방법을 알고 있습니다. services.Plz 짧은 코드 예를 제공합니다.Ksoap2 속성 추가 (안드로이드)

+0

두 데이터로 무엇을 의미합니까? – yakhtarali

+0

google out .. 많은 예제를 찾을 수 있습니다. –

+0

public void ProductImageInsertion (String name, Byte imageLink) // 위의 예제와 같은 것입니다. void 데이터에 두 개의 데이터를 입력해야합니다. – user3484436

답변

1
public static String Login(Context c, String username, String password, 
      String fleetId) throws IOException, XmlPullParserException { 
     String METHOD_NAME = "Login"; 
     String SOAP_ACTION = "http://tempuri.org/xxxxxx/"; 
     SOAP_ACTION = SOAP_ACTION + METHOD_NAME; 
     SoapObject request = new SoapObject(CommonVariable.NAMESPACE, 
       METHOD_NAME); 
     // Use this to add parameters 
     request.addProperty("username", username); 
     request.addProperty("password", password); 
     Log.i("request", "request:" + request); 
     // Declare the version of the SOAP request 
     Log.i(WebCalls, "URL " + CommonVariable.URL); 
     Log.i(WebCalls, "Method Name " + METHOD_NAME); 
     Log.i(WebCalls, "request Name " + request); 
     String SoapResult = null; 
     SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
       SoapEnvelope.VER11); 

     envelope.setOutputSoapObject(request); 

     envelope.dotNet = true; 

     HttpTransportSE androidHttpTransport = new HttpTransportSE(
       CommonVariable.URL); 

     // this is the actual part that will call the webservice 
     androidHttpTransport.call(SOAP_ACTION, envelope); 

     // Get the SoapResult from the envelope body. 
     if (envelope.bodyIn instanceof SoapFault) { 
      SoapResult = ((SoapFault) envelope.bodyIn).faultstring; 
     } else { 
      SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn; 
      SoapResult = resultsRequestSOAP.getProperty(0).toString(); 
     } 

     Log.i(WebCalls, "Response " + SoapResult); 

     return SoapResult; 
    } 

은이 같은 웹 서비스의 속성을 추가 할 :

SoapObject request = new SoapObject(CommonVariable.NAMESPACE, 
       METHOD_NAME); 
     // Use this to add parameters 
     request.addProperty("username", username); 
     request.addProperty("password", password); 

내가 당신의 도움을 바랍니다.

+0

코드, 응답의 간단한 코드는 유효한 대답이 아닙니다. – Kedarnath

+0

예 : public void ProductImageInsertion (String name, Byte imageLink) //이 void 함수에 두 개의 데이터를 입력해야하지만 하나의 함수에 속성을 추가하는 방법 만 알면 두 logcat will SoapFault – user3484436

관련 문제