Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 通过CXF发送邮件_Java_Spring_Cxf_Apache Servicemix - Fatal编程技术网

Java 通过CXF发送邮件

Java 通过CXF发送邮件,java,spring,cxf,apache-servicemix,Java,Spring,Cxf,Apache Servicemix,我正在基于CXF构建webservice,现在我正在通过代码将变量发送到某个URL中: url = new URL(urlSSO + "/user"); connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type","application/x-www-form-urlencoded")

我正在基于CXF构建webservice,现在我正在通过代码将变量发送到某个URL中:

url = new URL(urlSSO + "/user");
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type","application/x-www-form-urlencoded");

connection.setRequestProperty("Content-Length","" + Integer.toString(urlParameters.getBytes().length));
connection.setRequestProperty("Content-Language", "en-EN");

connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);

// Send request
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();

// Get Response
InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
StringBuffer response = new StringBuffer();
while ((line = rd.readLine()) != null) {
    response.append(line);
    response.append('\r');
}
rd.close();

userInfo = response.toString();
if (userInfo != null) {
    //do something
} else {
    // some problem with user
    return "home";
}
但我想知道是否有更简单的方法可以使用CXF实现这一点

我是说,也许CXF有内置的东西


我认为这段代码可能需要很多时间才能从其他servlet发送和获取响应。。。这个CXF Web服务将放在servicemix上,因此我需要一些非常快速的东西来发送变量

,使用CXF您可以创建REST服务(JAX-RS)或Web服务(JAX-WS)。如果不明确需要JAX-WS,我建议您使用JAX-RS。使用REST服务,使用JAXB以JSON或XML的形式发送数据比
application/x-www-form-urlencoded
form更容易。我不知道您对问题的答案有何期待。这是访问web服务的客户端代码吗?如果是这样,请阅读此-。