2012-07-18 19 views
9

मेरे डबल्यूएसडीएल है:नामस्थान, साबुन कार्रवाई और यूआरएल मेरे एंड्रॉइड ऐप के लिए डब्ल्यूसीएफ वेब सेवा तक पहुंचने के लिए क्या होना चाहिए? जैसे

<?xml version="1.0" encoding="utf-8"?> 
    <wsdl:definitions name="ABCWcfService" targetNamespace="http://www.ABC.com/ABCWcfService" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://www.ABC.com/ABCWcfService" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> 
     <wsdl:types> 
     <xsd:schema targetNamespace="http://www.ABC.com/ABCWcfService/Imports"> 
      <xsd:import schemaLocation="http://desktop/ABCWcfService/ABCWcfService.svc?xsd=xsd0" namespace="http://www.ABC.com/ABCWcfService"/> 
      <xsd:import schemaLocation="http://desktop/ABCWcfService/ABCWcfService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/> 
     </xsd:schema> 
     </wsdl:types> 
     <wsdl:message name="IABCWcfService_GetWhatsOnData_InputMessage"> 
     <wsdl:part name="parameters" element="tns:GetWhatsOnData"/> 
     </wsdl:message> 
     <wsdl:message name="IABCWcfService_GetWhatsOnData_OutputMessage"> 
     <wsdl:part name="parameters" element="tns:GetWhatsOnDataResponse"/> 
     </wsdl:message> 
     <wsdl:portType name="IABCWcfService"> 
     <wsdl:operation name="GetWhatsOnData"> 
      <wsdl:input wsaw:Action="http://www.ABC.com/ABCWcfService/IABCWcfService/GetWhatsOnData" message="tns:IABCWcfService_GetWhatsOnData_InputMessage"/> 
      <wsdl:output wsaw:Action="http://www.ABC.com/ABCWcfService/IABCWcfService/GetWhatsOnDataResponse" message="tns:IABCWcfService_GetWhatsOnData_OutputMessage"/> 
     </wsdl:operation> 
     </wsdl:portType> 
     <wsdl:binding name="BasicHttpBinding_IABCWcfService" type="tns:IABCWcfService"> 
     <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> 
     <wsdl:operation name="GetWhatsOnData"> 
      <soap:operation soapAction="http://www.ABC.com/ABCWcfService/IABCWcfService/GetWhatsOnData" style="document"/> 
      <wsdl:input> 
      <soap:body use="literal"/> 
      </wsdl:input> 
      <wsdl:output> 
      <soap:body use="literal"/> 
      </wsdl:output> 
     </wsdl:operation> 
     </wsdl:binding> 
     <wsdl:service name="ABCWcfService"> 
     <wsdl:port name="BasicHttpBinding_IABCWcfService" binding="tns:BasicHttpBinding_IABCWcfService"> 
      <soap:address location="http://desktop/ABCWcfService/ABCWcfService.svc"/> 
     </wsdl:port> 
     </wsdl:service> 
    </wsdl:definitions> 

मैं क्या मैं अपने SOAP_ACTION, पद्वति, NAMESPACE और यूआरएल के लिए रखना चाहिए सोच रहा हूँ? मुझे लगता है:

SOAP_ACTION = "http://www.ABC.com/ABCWcfService/IABCWcfService/GetWhatsOnData" 
METHOD_NAME = "GetWhatsOnData" 
NAMESPACE = "http://www.ABC.com/ABCWcfService" 
URL = "http://desktop/ABCWcfService/ABCWcfService.svc" 

लेकिन यह मेरी कोड में काम नहीं कर लगता है:

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
envelope.dotNet = true; 
envelope.setOutputSoapObject(request); 
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 
androidHttpTransport.call(SOAP_ACTION, envelope); 
SoapObject result = (SoapObject) envelope.getResponse(); 

यह लाइन androidHttpTransport.call (SOAP_ACTION, लिफाफा) में अपवाद में चला जाता है; अपवाद ऑब्जेक्ट ई मूल्य शून्य है।

मैं मैनिफ़ेस्ट फ़ाइल में

<uses-permission android:name="android.permission.INTERNET"></uses-permission> 

जोड़ने

किसी को भी मुझे बता सकते हैं कि क्या गलत है?

बहुत बहुत धन्यवाद।

+0

क्या डब्ल्यूसीएफ वेब सेवा दोनों के साथ कोई अच्छा ट्यूटोरियल या कोड नमूना भी संदर्भ के लिए ksoap2 एक्सेस क्लाइंट है? –

+0

आपको इस मुद्दे के लिए समाधान मिला है? –

+0

पहले नामस्थान के बाद/बाद में जोड़ें और –

उत्तर

0

आप WCFTestClient का उपयोग कर सकते हैं और नीचे XML टैब पर क्लिक कर सकते हैं। आप जो जानकारी देख रहे हैं उसे ढूंढ सकते हैं (एसओएपी यूआरएल और एक्शन)। मुझे उम्मीद है कि इससे सहायता मिलेगी।

0

अच्छी तरह से im इस

[OperationContract] 
    [WebInvoke(Method = "GET", 
       RequestFormat = WebMessageFormat.Json, 
       ResponseFormat = WebMessageFormat.Json, 
       UriTemplate = "/Login?ID={ID}&PASSWORD={PASSWORD}")] 
    System.IO.Stream ValidarLogin(int ID, string PASSWORD); 

की तरह और एंड्रॉयड ग्राहक में यह कर

class MiTareaAsincrona extends AsyncTask<Void, Integer, String> { 
    ProgressDialog dialog=null; 


protected void onPreExecute() { 
    dialog = new ProgressDialog(MainScreen.this); 
    dialog.setMessage("Verificando sus datos.. "); 
    dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); 
    // dialog.setMax(100); 
    dialog.setCancelable(false); 
    dialog.show(); 

    } 


    @Override 
    protected String doInBackground(Void... params) { 


     final EditText text1 = (EditText) findViewById(R.id.editText1); 
     final EditText text2 = (EditText) findViewById(R.id.editText2); 
    String Cedula= text1.getText().toString(); 
    String Password = text2.getText().toString(); 


    final String URL = "https://MYURL.COM/NGLOGIN/NGLogin.svc/Login?ID="+Cedula+"&PASSWORD="+Password; 

    if(!Cedula.equals("") || !Password.equals("")){ 

       try { 
         key=ValidarLogin(URL); 


        } catch (ClientProtocolException e) { 
          // TODO Auto-generated catch block 
         e.printStackTrace(); 
        } catch (IOException e) { 
         // TODO Auto-generated catch block 
         e.printStackTrace(); 

         key="noinet"; 
        } catch (JSONException e) { 
         // TODO Auto-generated catch block 
         e.printStackTrace(); 
        } 

    // this.cancel(true); 
    } 

    return key; 

    } 




    @Override 
    protected void onPostExecute(String result) { 
     String a= result.toString(); 
     Boolean aa= " ".equals(result); 

     if(!result.equals("false") & !result.equals("noinet")){ 
      dialog.dismiss(); 
     finalizo=true; 
     if(finalizo){ 
       Intent intent = new Intent(getApplicationContext(), MainMenu.class); 
       intent.putExtra("llave", key); 
       startActivity(intent);} 

ValidarLogin (यूआरएल) कोड:

public String ValidarLogin (String URL) throws ClientProtocolException, IOException, JSONException 
    { 

     Security.addProvider(new BouncyCastleProvider()); 

     HttpClient client = new MyHttpsClient(getApplicationContext()); 

     HttpGet get = new HttpGet(URL); 
     HttpResponse response = client.execute(get); 

     int status = response.getStatusLine().getStatusCode(); 

     if(status == 200) //sucess 
     { 
      HttpEntity e = response.getEntity(); 
      String key = EntityUtils.toString(e); 
     // get.abort(); 
     /*/ char[] arreglo = key.toCharArray(); 
     char[] arreglo2= new char[arreglo.length-2]; 

     for(int x=1; x<arreglo.length-1;x++){ 

      arreglo2[x-1] = arreglo[x]; 

     } 

     /*/ 

      if(!key.equals("")){return key;} 
      return "false"; 

     } 

      return "false"; 


    } 

WCF एक 1 या कुछ भी नहीं depeding रिटर्न यदि उपयोगकर्ता और पासवर्ड ठीक है ..

उम्मीद है कि यह आपको