2013-07-15 4 views
-1

비누 webservice에서 응답을 얻으려고하고 있지만 항상 오류가 발생합니다. 웹 서비스를 제대로 호출하는지 확인하십시오. 다음 는 android에서 비누 webservice에 액세스

<wsdl:definitions name="MobileeServiceWsd" targetNamespace="urn:MobileeServiceWsd"><wsdl:import location="http://vddp.dewa.gov.ae:50700/MobileeService/Config2/bindings?wsdl&style=document" namespace="urn:MobileeServiceWsd/Config2/document"/><wsdl:service name="MobileeService"><wsdl:port name="Config2Port_Document" binding="bns0:Config2Binding"><soap:address location="http://vddp.dewa.gov.ae:50700/MobileeService/Config2?style=document"/></wsdl:port></wsdl:service></wsdl:definitions> 

웹 서비스

내 WSDL이며, 다음은 내 코드입니다.

private static final String METHOD_NAME = "getOutstandingBalance"; 
    private static final String SOAP_ACTION = "MobileeService"; 
    private static final String NAMESPACE = "MobileeServiceWsd/Config2/document"; 
    private static final String URL = "http://vddp.dewa.gov.ae:50700/MobileeService/Config2/bindings?wsdl&style=document"; 


    public SoapObject testMethod(String METHOD_NAME, String SOAP_ACTION, String NAMESPACE, String URL) throws IOException, XmlPullParserException 
    { 
     //List<HeaderProperty> headers = new ArrayList<HeaderProperty>(); 

     SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

     SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
     envelope.dotNet = true; //for .net services 
     envelope.bodyOut = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:MobileeServiceVi\">"+ 
        "<soapenv:Header/>"+ 
        "<soapenv:Body>"+ 
         "<urn:getOutstandingBalance>"+ 
         "<urn:contractaccount>000001000104</urn:contractaccount>"+ 
         "<urn:mobileosver>ios 4.3</urn:mobileosver>"+ 
        "<urn:appver>3.3</urn:appver>"+ 
         "<urn:appidentifier>343534</urn:appidentifier>"+ 
         "</urn:getOutstandingBalance>"+ 
        "</soapenv:Body>"+ 
       "</soapenv:Envelope>"; 
     envelope.setOutputSoapObject(request); 

     HttpTransportSE httpTransport = new HttpTransportSE(URL); 

     //httpTransport.call(SOAP_ACTION, envelope, headers); 
     httpTransport.call(SOAP_ACTION, envelope); 

     return (SoapObject) envelope.getResponse(); 
    } 

답변

0
Using Ksoap2 library and write .net web service 
Sucessful Connection with Asp.net Webservice----- 
package ProductVerificationCard.in; 

import org.ksoap2.SoapEnvelope; 
import org.ksoap2.serialization.SoapObject; 
import org.ksoap2.serialization.SoapSerializationEnvelope; 
import org.ksoap2.transport.HttpTransportSE; 

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.Button; 
import android.widget.TextView; 

public class AdminLogin extends Activity { 
    /** Called when the activity is first created. */ 
    Button btn_ok; 
    TextView textView; 
    private static final String SOAP_ACTION = "http://tempuri.org/Login"; 

    private static final String OPERATION_NAME = "Login"; 

    private static final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/"; 

    private static final String SOAP_ADDRESS = "http://10.0.2.2/new/WebService.asmx"; 
    String s; 


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

     btn_ok=(Button) findViewById(R.id.btn_login); 
     textView=(TextView) findViewById(R.id.tv_error); 

     btn_ok.setOnClickListener(new OnClickListener() { 

      public void onClick(View v) { 
       SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, 
         OPERATION_NAME); 

         SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
         SoapEnvelope.VER11); 
         envelope.dotNet = true; 

         envelope.setOutputSoapObject(request); 

         HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS); 

         try 

         { 

         httpTransport.call(SOAP_ACTION, envelope); 

         Object response = envelope.getResponse(); 

         //textView.setText(response.toString()); 
         s=response.toString(); 
         if(s=="true") 
         { 
          Intent intent=new Intent(AdminLogin.this,MenuForm.class); 
           startActivity(intent); 

         } 

         else 
         { 
          textView.setText("Enter Valid Username or Password"); 
         } 
         } 

         catch (Exception exception) 

         { 

         textView.setText(exception.toString()); 

         } 
       // TODO Auto-generated method stub 
       } 
     }); 

    } 
} 
+0

이 질문의 코드에서 어떻게 다른지? – Selvin

+0

다음 링크가 나를 위해 작동했습니다. https://groups.google.com/forum/#!topic/android-developers/sNwGyt9gHso –

관련 문제