2013-01-29 1 views
0

http://i.stack.imgur.com/pK9rm.png http://i.stack.imgur.com/27Qj0.pngKsoap2 .NET 웹 서비스 연결

내가 ksoap2를 사용하여 연결 웹 서비스에 원하는, 내가 작업 예제를 가지고 있지만 어떻게 내 응용 프로그램을 통합 할 수 있습니까?

공용 클래스 WebServiceDemoActivity는

+0

에 정말 간단 보는 예입니다. – Mertuarez

+0

ksoap2를 사용하여 얻었으나 이제 웹 서비스에 대한 내 응답을 구문 분석하려고합니다. –

+0

또는이 http://code.google.com/p/android-ws-client/ this는 mutch가 더 좋습니다. – Mertuarez

답변

0

당신이 당신이 필요한 모든 CLASSE를 만들 수 있습니다 다른 클라이언트에게

http://code.google.com/p/android-ws-client/

를 사용하는 재고하시기 바랍니다 활동 {

private static String SOAP_ACTION = "http://tempuri.org/UrunleriListele"; 
    private static String NAMESPACE = "http://tempuri.org/"; 
    private static String METHOD_NAME = "UrunleriListele"; 
    private static String URL = "http://services.annebebekavm.com/Service1.asmx?WSDL"; 

    Button btnFar,btnCel,btnClear; 
    EditText txtFar,txtCel; 

@Override 
public void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    btnFar = (Button)findViewById(R.id.btnFar); 

    txtFar = (EditText)findViewById(R.id.txtFar); 


    btnFar.setOnClickListener(new View.OnClickListener() 
    { 
       @Override 
       public void onClick(View v) 
       { 

       SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);  


       request.addProperty("Fahrenheit",txtFar.getText().toString()); 


       SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 

       envelope.setOutputSoapObject(request); 
       envelope.dotNet = true; 

       try { 
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 


        androidHttpTransport.call(SOAP_ACTION, envelope); 


        SoapObject result = (SoapObject)envelope.bodyIn; 

        if(result != null) 
        { 

          txtFar.setText(result.getProperty(0).toString()); 
        } 
        else 
        { 
          Toast.makeText(getApplicationContext(), "No Response",Toast.LENGTH_LONG).show(); 
        } 
       } catch (Exception e) { 
        e.printStackTrace(); 
       } 
       } 
     }); 

} 

}을 확장합니다. 당신의 생성 클래스

와 프로젝트 에 하나의 응용 프로그램 사본 libs와에 의해 은 여기가 내가 ++ wsclient을 사용하도록 권 해드립니다합니다

Service servis = new Service(); 
    ServiceSoap soap12 = servis.getServiceSoap12(); 
    LoginParams inParams = new LoginParams(); 
    inParams.setLogin("user"); 
    inParams.setPassword("pass"); 
    inParams.setStrategy(LoginStrategy.NOHASHPASS); // even enums are supported 
    LoginState result = soap.authorize(inParams); 

    result.isLogin(); // boolean if is succesfull 
+0

SQL 쿼리를 통해 클라이언트 또는 서버에 연결할 수 있습니까? –

+0

나는 당신이 요구하는 것을 자극하지 않습니다. 이것은 클라이언트 측입니다. – Mertuarez

+0

죄송합니다. 영어를 잘 못합니다 :) 당신에게 말하고 싶습니다. 코드를 사용하여 데이터베이스를 연결할 수 있습니까? 나는 정확하게 내 질문을 설명 할 수 있기를 바랍니다 :) –