客户端如何通过专用APN访问WebService

来源:互联网 发布:手机淘宝查看消费总额 编辑:程序博客网 时间:2024/05/22 01:36
我在程序里建立了一个专用APN连接,想让客户端通过APN访问服务器的WebService,其中一个原则,不通过手动设置系统默认的接入点来实现。
因此,在程序中,第一步,我先连接该APN网络;第二步,访问WebService。问题在于第二步的访问WebService并不通过我第一步连接的APN网络来访问网络,而是通过了系统的默认访问点,结果肯定访问不到。有没有什么办法,强制客户端通过特定的APN访问WebService访??谢谢!
代码如下(C#+OpenNetCF)

第一步:
/连接公司的APN连接
        public void ConnGPRS()
        {
            
            cenum = ConnMgr.EnumDestinations();
            try
              {
                foreach (DestinationInfo em in cenum)
                {

                    if (em.Description == "APN专网")                      
                       {
                       ConnMgr.Connect(em.Guid, true, ConnectionMode.Asynchronous);     
                    }

                }

            }
            catch (SystemException err)
            {
                MessageBox.Show(" err 700 " + err.Message);
            }
        }

第二步:
//访问WebService
 private void button1_Click(object sender, EventArgs e)
        {

            try
            {
                string type = domainUpDown1.SelectedIndex.ToString();
                ws_info.Contact ws = new PPC6.ws_info.Contact();
                ws.Url = "http://10.49.28.30/ws_info/contact.asmx";
                string strRet = ws.getContact(type, textBox1.Text.Trim());
                if (type == "0")
                {
                    tb_mobile.Text = strRet;
                    tb_name.Text = textBox1.Text.Trim();
                }
                else
                {
                    tb_mobile.Text = textBox1.Text.Trim();
                    tb_name.Text = strRet;
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show("错误:"+ex.Message);
            }
           
        }

0 0