web应用位于公司内网中,公网用户可通过VPN访问应用(https),Juniper管理着VPN,WEB应用已被
Juniper改写了url,公网用户需进行两次用户验证,Juniper的验证和web应用的用户验证.现为了测试公网访问的性能,在客户端用HttpClient模拟浏览器,两次验证都已通过,HttpClient
的PostMethod.getResponseBodyAsString()已返回Web应用的首页,但是接着访问Web应用的功能
时,HttpClient又跳出到Juniper的用户验证页面. 代码如下:HttpClient client = new HttpClient();       Protocol easyhttps = new Protocol( "https", new EasySSLProtocolSocketFactory(), 443 );
       Protocol.registerProtocol( "https", easyhttps );
       
       PostMethod postMethod = new PostMethod( "https://公网ip/dana-na/auth/url_default/login.cgi" ); //这里是juniper用户验证
       
       NameValuePair pairA = new NameValuePair( "username", URIUtil
               .encodeQuery( "user" ) );
       NameValuePair pairB = new NameValuePair( "password", URIUtil
               .encodeQuery( "password" ) );
       NameValuePair pairC = new NameValuePair( "realm", URIUtil
               .encodeQuery( "Users" ) );
       NameValuePair pairD = new NameValuePair( "tz_offset", URIUtil
               .encodeQuery( "" ) );
       NameValuePair[] pair = new NameValuePair[] { pairA, pairB, pairC, pairD };
       
       postMethod.setRequestBody( pair );
       client.executeMethod( postMethod );
       postMethod.releaseConnection();postMethod = new PostMethod( "https://公网ip/Security,DanaInfo=内网ip,Port=内网端口+" );
       //这里是web应用用户验证
       pairA = new NameValuePair( "userName", URIUtil
               .encodeQuery( "webuser" ) );
       pairB = new NameValuePair( "password", URIUtil
               .encodeQuery( "webpassword" ) );
       
       pair = new NameValuePair[] { pairA, pairB };
       postMethod.setRequestBody( pair );
       client.executeMethod( postMethod );
System.out.println( postMethod.getResponseBodyAsString().) //此处返回web应用首页内容//这里访问web应用的功能
postMethod = new PostMethod( URIUtil.encodeQuery( "https://公网ip/calendar/todolist.do,DanaInfo=内网ip,Port=内网端口+" ) );
            client.executeMethod( postMethod );String locationHeader = postMethod.getResponseHeader( "location" );
System.out.println( locationHeader ) //发现返回到juniper用户登录页面
直接在IE中按上面步骤粘贴url来访问,则一切正常请高手们看看问题出在哪里,谢谢

解决方案 »

  1.   

    1432376
    JNU - Juniper网络联盟^_^
    网址:htpp://www.52network.com/
    Ftp://juniper:[email protected]
      

  2.   

    部门已解决,HttpClient client = new HttpClient();后面加:
    client.getParams().makeStrict();不过又有新问题,我在服务器端加header如下: response.addHeader( "testkey", s  );客户端死活取不回header值:
    postMethod.getResponseHeader( "testkey" ).getValue();总返回null郁闷!!
      

  3.   

    如果走内网访问,可以得到postMethod.getResponseHeader( "testkey" ).getValue();公网上通过vpn访问postMethod.getResponseHeader( "testkey" )始终为nulljuniper把header都删了?我靠!