2011-08-08 5 views
0

私はWebサービスを消費するアプリケーションを開発していますが、次のWebサービスをどのように使用するのですか? httpメソッドまたはksoap2?私はKsoap2を試してみましたが、このWebサービスを正しく抽出できないようですが、誰でもこれを助けることができますか?前もって感謝します。ここでAndroidでこのWebServiceを使用するには?

は、WSDLです: "http://tempuri.org/" 方法はCreateTokenです:https://integrator-ut.vegaconnection.com/Authentication.svc?wsdl

はNAME_SPACEがあることですか?そしてSOAP_ACTIONがhttp://tempuri.org/IAuthentication/CreateTokenているのですか?...

答えて

0

あなたがKSOAPを使用したくない場合は、HttpURLConnectionのを使用することができますし、InputStream

 HttpURLConnection my_httpConnection = (HttpURLConnection) new URL("https://integrator-ut.vegaconnection.com/Authentication.svc?wsdl").openConnection(); 
     my_httpConnection.setRequestMethod("POST"); 
     my_httpConnection.setDoInput(true); 
     my_httpConnection.setDoOutput(true); 
     my_httpConnection.setRequestProperty("Content-type", "text/xml; charset=utf-8"); 



     OutputStream my_outPutStream = this.my_httpConnection.getOutputStream(); 
     Writer my_writer = new OutputStreamWriter(my_outPutStream); 
     my_writer.write(YOUR_REQUEST); //YOUR_REQUEST is a String 
     my_writer.flush(); 
     my_writer.close();   

     BufferedReader my_bufferReader = new BufferedReader(new InputStreamReader(this.my_httpConnection.getInputStream())); 
     char[] buffer = new char[10000]; 
     int nbCharRead=0; 
     try 
     { 
      while((nbCharRead = my_bufferReader.read(buffer, 0, 10000)) != -1) 
      { 
       /* Your treatement : saving on a file/arraylist/etc 

      } 
     } 

あなたは

を回復したい値に基づいて文字列 YOUR_REQUESTをしなければなりません

それはのように見える

<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" ... > 
<soapenv:Header/>  
<soapenv:Body> 
... 
</soapenv:Body> 
</soapenv:Envelope> 
1

はウルWebサービスメソッドのコードを投稿してください。

**Sample web service method** 

public String Login(string userName, string pwd) throws SoapFault 
{   

    String data = ""; 

    String serviceUrl = "https://abc.com/xyz.svc"; 

    String serviceNamespace = "http://tempuri.org/"; 

    String soapAction = "http://abc.org/IAuthentication/CreateToken"; 

    String type_of_soap = "CreateToken"; 

    try 
    { 
     SoapObject Request = new SoapObject(serviceNamespace, type_of_soap); 
      //txtUserName,txtPassword these two are edit text ref variables but these are decalred before of this. 
      Request.addProperty("userName", txtUserName.getText().toString());  
      Request.addProperty("password", txtPassword.getText().toString()); 


     System.out.println("GetRestaurantDetails:"+Request.toString()); 

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

     try 
     { 
      HttpTransportSE androidHttpTransport = new HttpTransportSE(serviceUrl); 
      androidHttpTransport.call(soapAction, envelope); 
     } 
     catch(Exception e) 
     { 
      System.out.println("Webservice calling error ->"+e.toString()); 
     } 

     SoapPrimitive response = (SoapPrimitive)envelope.getResponse(); 
     data = response.toString(); 
     System.out.println("GetRestaurantDetails:"+response.toString()); 
     tv.setText(data);//this text view can be declared before this. 

    } 
    catch(Exception e) 
    { 
     System.out.println("Soap Method Error ->"+e.toString());  
    }   
    return data; 
} 
+0

[WebMethod属性] パブリックストリングログイン(文字列ユーザ名、文字列PWD) {ストリングMSG = String.Emptyを。 {Authentication.AuthenticationのAUTH =新しいAuthentication.Authentication()を試みます。 Authentication.LoginToken login = auth.CreateToken(userName、pwd); msg = "ログインに成功しました"; }キャッチ(例外EX) {MSG = ex.Message。 } 返信msg; } – jalakam

+0

どのツールがWebサービスメソッド(ksaopなど)に使用していますか?実際に私がcreateToke方法についてプットを出したいというWSDLのURLに基​​づいて – naresh

+0

... – jalakam

関連する問題