@RequestMapping(value = "loginInSSO", method = RequestMethod.GET)
public String loginInSSO(Cookyjar cookyjar, HttpServletRequest request, @Param("data")String data, HttpServletResponse response) {
HttpUtils client= HttpUtils.getInstance();
// String xml = HttpUtils.beanToXml(reqsObj, ReqsObj.class);
String xml = "";
// String xml = "<phone>123</phone><password>123</password>";

String md5Pwd = AlgorithmUtils.computeMD5("123");

// String msg = client.sendHttpPost("http://117.149.16.172:20004/xct/login.htm?phone=123&password=123", xml);
String msg = client.sendHttpPost("http://117.149.16.172:20004/xct/login.htm?phone=123&password=" + md5Pwd, xml);

logger.info("测试msg:" + msg);
// JSONObject jsonObject = JSONObject.fromObject(msg);
Msg dataObj = (Msg)JSONUtils.parse(msg);

return "redirect:" + bossIndexUrl;
}


、、、、、、、、、、、、、、、、、、、、
package com.jianwu.xct.common;

import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Created by heyingchun on 2017/8/15.
*/

public class HttpUtils {

public final static String connectionUrl="http://223.105.4.67:7100/ds/V1/api/si/siApplicationJQ";
public final static String key="0808E973";
public final static String app + bodycc);
} catch (Exception e) {
e.printStackTrace();
}
}
}

相关文章: