就是说服务端要做一个统一的中转站。

解决方案 »

  1.   

    当然可以,但要看你是传递字节流、字符还是SOAP,我这里有个收发字节流的例子:    @Test
        public void testClient()
        {
            String rspXml = "";
            final HttpClient httpClient = new HttpClient();
            final String url = "http://localhost:8080/SimulateBSS/httpServ.do?model=Simple";
            
            String str = "<servlet><servlet-name>tychoLoader</servlet-name><servlet-class>org.junesky.tycho.servlet.TychoLoaderServlet</servlet-class><cdatatest><![CDATA[function matchwo(a,b){if(a<b&&a<0)then{return 1;}else{return 0;}}]]></catatest><load-on-startup>3</load-on-startup></servlet>";
            final String charset = "UTF-8";
            final PostMethod method = new PostMethod(url);
            //httpClient.getParams().setConnectionManagerTimeout(connTimeOut);
            //method.getParams().setSoTimeout(invokeTimeOut);
            httpClient.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, charset);        try {
                RequestEntity entity = new ByteArrayRequestEntity(str.getBytes(charset));
                method.setRequestEntity(entity);
                httpClient.executeMethod(method);
                rspXml = method.getResponseBodyAsString();
                //rspXml = java.net.URLDecoder.decode(rspXml, "UTF-8");
                System.out.println(rspXml);
            } catch (final HttpException e) {
                //throw new BaseException("15", e, new Object[] { url, connTimeOut, invokeTimeOut, charset, data });
            } catch (final IOException e) {
                //throw new BaseException("16", e, new Object[] { url, connTimeOut, invokeTimeOut, charset, data });
            } finally {
                method.releaseConnection();
            }
      

  2.   

    不过只有httpclient还不够,它不能作为服务器端,如果要提供服务
    对于HTTP POST类服务,你要用SERVLET,
    对于SOAP 类服务,你要用hessian,axis2等
      

  3.   

    小项目足够了,瓶颈不在HTTPCLIENT和AXIS2框架或者SERVLET上,而在于你用的WEB容器和服务器、数据库。