Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6555839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:52:09+00:00 2026-05-25T12:52:09+00:00

I have to set proxy,username and password when my computer try to connect with

  • 0

I have to set proxy,username and password when my computer try to connect with the Internet.And I set them in my Android Virtual machine and it works.(The virtual machine can access the Internet).But when i run my app,it cannot access the Internet.
Anyone help me?Thanks in advance!!

public class wsActivity extends Activity {
    private static final String mNameSpace = "http://WebXml.com.cn/";
    private static final String mMethodName = "getWeatherbyCityName";
    private static final String mUrl = "http://www.webxml.com.cn/webservices/weatherwebservice.asmx?wsdl";
    private static final String SOAP_ACTION = "http://WebXml.com.cn/getWeatherbyCityName";
    private String weatherToday = null;
    private SoapObject details;

private Button mBtnSearch;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mBtnSearch = (Button)findViewById(R.id.btn_search);
    mBtnSearch.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            getWeather("北京");
        }
    });

}

/**
 * getWeather(String cityName)
 * 
 */
public void getWeather(String cityName){
    SoapObject rpc = new SoapObject(mNameSpace, mMethodName);
    rpc.addProperty("theCityName", cityName);

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


    HttpTransportSE ht = new HttpTransportSE(mUrl);
    //AndroidHttpTransport ht = new AndroidHttpTransport(mUrl);
    ht.debug = true;
    Log.d("getWeather","path:"+ht.getPath());
    try {
        ht.call(SOAP_ACTION, envelope);
        details = (SoapObject) envelope.getResponse();
        Log.d("getWeather",details.toString());
        parseWeather(details);
        return;
    } catch (IOException e) {
        e.printStackTrace();
    } catch (XmlPullParserException e) {
        e.printStackTrace();
    }
}

/**
 * parseWeather(SoapObject details)
 * 
 */
public void parseWeather(SoapObject detail) throws UnsupportedEncodingException {
    String date = detail.getProperty(6).toString();
    weatherToday = "今天:" + date.split(" ")[0];
    weatherToday = weatherToday + "\n天气:" + date.split(" ")[1];
    weatherToday = weatherToday + "\n气温:"
            + detail.getProperty(5).toString();
    weatherToday = weatherToday + "\n风力:"
            + detail.getProperty(7).toString() + "\n";

    Toast.makeText(this, weatherToday, Toast.LENGTH_LONG).show();
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:52:09+00:00Added an answer on May 25, 2026 at 12:52 pm

    As your code shows you are using KSoap2. In KSoap2 there is the Class ServiceConnectionSE with the following constructor:

    public ServiceConnectionSE(String url) throws IOException {
        connection = (HttpURLConnection) new URL(url).openConnection();
        connection.setUseCaches(false);
        connection.setDoOutput(true);
        connection.setDoInput(true);
    }
    

    You can change the constructor of the class ServiceConnectionSE as follows. The better way though is to make a copy of the ServiceConnectionSE class (and name it e.g. ServiceProxyConnectionSE) and implement the constructor as follows:

    public ServiceProxyConnectionSE(
           String url, String user, String passwd ) throws IOException {        
    
        String s = user + ":" + passwd;
        new Base64();
        String strBase64 = "Basic " + Base64.encode( s.getBytes() );
    
        connection = (HttpURLConnection) new URL(url).openConnection();
        connection.setUseCaches(false);
        connection.setDoOutput(true);
        connection.setDoInput( true );
        connection.setRequestProperty( "Authorization", strBase64 );
    
    }
    

    PLEASE NOTE, that you will also have to create a copy of the HTTPTransportSE class (named e.g. HTTPProxyTransportSE) then and change the method getServiceConnection to the new ServiceProxyConnection class!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have set my proxy settings in emulator and I can access normal internet
I have a simple form interface set up that send username and password information
I am new to the android development . I have tried to connect internet
I have set of scripts for doing scripted installs. You can use the scripts
We have OSB services that are currently secured with a username and a password.
I have created a local store and model for remembering username and password: Store
At my company we have recently set up a TeamFoundation proxy to our TeamFoundationServer.
I have set up a simple php proxy $proxy = 'tcp://127.0.0.1:8080'; $context = array(
We have set up a system where notifications get sent to a user with
I have set a canvas' background to an image of a company logo. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.