社区
Java
帖子详情
java 调用webservice 接口发短信
wlaqianqian34
2012-01-17 11:47:27
就给了个地址:http://61.191.40.242:9090/WebService/EntInterface.asmx
要查看接口的定义的话则在连接地址下面增加“?WSDL”,
即http://61.191.40.242:9090/WebService/EntInterface.asmx?WSDL
请问根据这个如何实现java发短信?
...全文
299
2
打赏
收藏
java 调用webservice 接口发短信
就给了个地址:http://61.191.40.242:9090/WebService/EntInterface.asmx 要查看接口的定义的话则在连接地址下面增加“?WSDL”, 即http://61.191.40.242:9090/WebService/EntInterface.asmx?WSDL 请问根据这个如何实现java发短信?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
ai523730098
2012-01-17
打赏
举报
回复
weather.xml的内容是
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getWeatherbyCityName xmlns="http://WebXml.com.cn/">
<theCityName>${city}$</theCityName>
</getWeatherbyCityName>
</soap:Body>
</soap:Envelope>
放工程目录下就行了
ai523730098
2012-01-17
打赏
举报
回复
我可以给你两个例子参考下
第一个根据城市取天气
webservice的地址:http://www.webxml.com.cn/WebServices/WeatherWebService.asmx
运行下面的代码试试,实际上就是发请求给这个地址,请求的内容是有一定规则的xml字符串而已。
调用websevice接口的时候,可以首先用soapui调试下。
也可以用工具生成java代码的,生成代码的方法有很多,网上试试
package myweather;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class MyWeather {
private static String getSoapRequest(String city) {
try {
InputStreamReader isr = new InputStreamReader(new FileInputStream("weather.xml"));
BufferedReader reader = new BufferedReader(isr);
String soap = "";
String tmp;
while ((tmp = reader.readLine()) != null) {
soap += tmp;
}
reader.close();
isr.close();
return soap.replace("${city}$", city);
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
private static InputStream getSoapInputStream(String city) throws Exception {
try {
String soap = getSoapRequest(city);
if (soap == null) {
return null;
}
URL url = new URL("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx");
URLConnection conn = url.openConnection();
conn.setUseCaches(false);
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestProperty("Content-Length", Integer.toString(soap.length()));
conn.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
conn.setRequestProperty("SOAPAction","http://WebXml.com.cn/getWeatherbyCityName");
OutputStream os = conn.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os, "utf-8");
// osw.write(new String(soap.getBytes(),"utf-8"));
osw.write(soap);
osw.flush();
osw.close();
InputStream is = conn.getInputStream();
return is;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static String getWeather(String city) {
try {
Document doc;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
InputStream is = getSoapInputStream(city);
doc = db.parse(is);
NodeList nl = doc
.getElementsByTagName("getWeatherbyCityNameResult");
Node n = nl.item(0);
// JOptionPane.showMessageDialog(null,n.getChildNodes().getLength());
for (int i = 0; i < n.getChildNodes().getLength() - 1; i++) {
String weather = n.getChildNodes().item(i).getTextContent();
System.out.print(weather);
}
is.close();
return "null";
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static void main(String[] args) throws Exception {
// System.out.println(MyWeather.getWeather("上海"));
MyWeather.getWeather("长沙");
}
}
// 将以下XML保存为weather.xml
/*
* XML:<?xml version="1.0" encoding="utf-8"?> <soap:Envelope
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
* xmlns:xsd="http://www.w3.org/2001/XMLSchema"
* xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body>
* <getWeatherbyCityName xmlns="http://WebXml.com.cn/">
* <theCityName>${city}$</theCityName> </getWeatherbyCityName> </soap:Body>
* </soap:Envelope>
*/
易语言源码易语言翻译类源码
易语言源码易语言翻译类源码
易语言源码易语言分类资源管理器源码
易语言源码易语言分类资源管理器源码
docker.1ms.run-vllm-vllm-openai-v0.23.0.tar.7z.002
1
基于共识的捆绑算法(CBBA)的多智能体多任务分配问题-远程太空船交会和维修的 RPO 规划任务研究(Matlab代码实现)
内容概要:本文研究了基于共识的捆绑算法(CBBA)在多智能体系统中的多任务分配问题,重点应用于远程太空船交会与维修的相对运动规划(RPO)任务。通过Matlab代码实现了CBBA算法,解决了多个航天器在复杂空间环境下协同执行交会、对接与维修任务时的任务分配挑战。研究突出该算法在分布式决策、冲突避免与资源优化方面的优势,详细探讨了任务打包、竞标机制与共识达成等核心环节,验证了其在无中央控制器条件下实现高效、鲁棒任务分配的有效性。; 适合人群:具备航天动力学、控制理论、多智能体系统及优化算法基础,从事航天器自主任务规划、分布式协同控制等相关领域的研究生、科研人员及工程师。; 使用场景及目标:① 实现多航天器在通信受限与信息不完整的远程空间环境下的自主任务分配;② 提升RPO任务中路径规划与资源调度的效率与安全性;③ 构建去中心化的多智能体协同框架,增强系统整体鲁棒性与可扩展性。; 阅读建议:建议结合提供的Matlab代码深入理解CBBA算法的实现逻辑,重点关注竞标权重设计、任务冲突消解与共识收敛过程,并可通过调整任务规模、通信拓扑与约束条件进行仿真实验,以全面掌握算法性能与适用边界。
Java
51,408
社区成员
86,091
社区内容
发帖
与我相关
我的任务
Java
Java相关技术讨论
复制链接
扫一扫
分享
社区描述
Java相关技术讨论
java
spring boot
spring cloud
技术论坛(原bbs)
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章