2012-06-02 214 views
-1

給予所有stackoverflow成員。需要Android HTTP POST幫助

即時通訊新的Android開發,誰能告訴我如何發佈數據在網站上或給我一個採樣器?

我想將哈希值發佈到在線破解程序中,然後將字符串解析爲字符串。

edit_box = enter the hash 

sendbutton =發送哈希 text_view = resuld

http://xdecrypt.com/# 感謝

編輯:我看看@活頭,發現這個resuld http://xdecrypt.com/ajax/liste.php?hash=759fdfa1a99563aa6309bb6ae27537c564547f62

在這裏,我們可以添加散列到Url和結果是。

document.getElementById('hashresult').value="";document.getElementById('hashresult').value+="759fdfa1a99563aa6309bb6ae27537c564547f62(MySQL)=amande1975 "; 

現在我想讀這個字符串任何人都可以幫忙嗎?

我想顯示Hashtype MySQL和密碼amande1975。 並將其顯示爲text_view,在ui上。

再次感謝。

編輯:2它的工作,但如何現在拆分字符串?任何人都可以幫忙?

  try { 
      String webPage = "http://xdecrypt.com/ajax/liste.php?hash="+hashedit.getText().toString(); 
      URL url = new URL(webPage); 
      URLConnection urlConnection = url.openConnection(); 
      InputStream is = urlConnection.getInputStream(); 
      InputStreamReader isr = new InputStreamReader(is); 

      int numCharsRead; 
      char[] charArray = new char[1024]; 
      StringBuffer sb = new StringBuffer(); 
      while ((numCharsRead = isr.read(charArray)) > 0) { 
       sb.append(charArray, 0, numCharsRead); 
      } 
      String result = sb.toString(); 

      System.out.println("*** BEGIN ***"); 
      System.out.println(result); 
      System.out.println("*** END ***"); 

      TextView tv2 = (TextView) findViewById(R.id.textView2); 
      tv2.setText("HashResuld="+sb.toString()); 

EDIT3:其作品;)再次

感謝任何幫助;)

回答

0

我做的研究公平一點之前ksoap2有能力做web服務的URL和數據傳輸我相信它可以使用其他http功能。

http://ksoap2.sourceforge.net/

下載ksoap2並導入到您的項目,並創建業務接入層,例如:

import java.util.ArrayList; 
import java.util.List; 

import org.ksoap2.serialization.PropertyInfo; 
import org.ksoap2.serialization.SoapObject; 
import org.ksoap2.serialization.SoapPrimitive; 

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


public class ServiceAccess { 

private static String Namespace; 
private static String MethodName; 
private static String URL; 
private SoapSerializationEnvelope Envelope; 
private SoapObject SoapRequest; 
private SoapPrimitive Response; 
private List<PropertyInfo> methodParamList; 

public ServiceAccess(String webserviceUrl, String methodName) throws Exception 
{ 
    setUrl(webserviceUrl); 
    setMethodName(methodName); 
    setNamespace("http://tempuri.org/"); 
    SoapRequest = new SoapObject(this.getNamespace(), this.getMethodName()); 
    methodParamList = new ArrayList<PropertyInfo>(); 
} 
protected String getUrl() 
{ 
    return URL; 
} 
protected void setUrl(String url) 
{ 
    URL = url; 
} 
protected String getMethodName() 
{ 
    return MethodName; 
} 
protected void setMethodName(String methodName) 
{ 
    MethodName = methodName; 
} 
protected String getNamespace() 
{ 
    return Namespace; 
} 
protected void setNamespace(String namespace) 
{ 
    Namespace = namespace; 
} 
protected String SoapAction() 
{ 
    String SOAP_ACTION = this.getNamespace() + this.getMethodName(); 
    return SOAP_ACTION; 
} 
protected void CreateSoapRequest() throws Exception 
{ 
    try 
    { 
     if(methodParamList.size()>0){ 
      for(PropertyInfo propInfo : methodParamList) 
      { 
     SoapRequest.addProperty(propInfo.getName(), propInfo.getValue()); 
      } 
     } 
    }catch(Exception ex){ 
     throw ex; 
    } 

} 
public <T> void addMethodParameters(String paramName, T val) 
{ 
    PropertyInfo prop = new PropertyInfo(); 
    prop.setName(paramName); 
    prop.setValue(val); 
    prop.setType(val.getClass()); 
    methodParamList.add(prop); 
} 
protected SoapSerializationEnvelope createEnvelope() throws Exception 
{ 
    this.CreateSoapRequest(); 
    try{ 

     Envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
     Envelope.dotNet = true; 
     Envelope.setOutputSoapObject(SoapRequest); 

    }catch(Exception ex){ 
     throw ex; 
    } 
    return Envelope; 
} 
public String getResponse() throws Exception 
{ 
    try{ 

     this.createEnvelope(); 

     HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 

      androidHttpTransport.call(this.SoapAction(), Envelope); 

      Response = (SoapPrimitive) Envelope.getResponse(); 

    }catch(Exception ex){ 
     throw ex; 
    } 
    return Response.toString(); 
} 

} 

你可以用它圍繞調整使用網頁的各種URL,而不是Web服務的URL。