我的这个服务端是用Ruby做的,以下是我的客户端
public String getSoapInputStream(String username,String password) {
try {
//该字符串是通过《soapUI 4.5.2工具》解析的
String soapRequestData = "<soapenv:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\""
+" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" "
+" xmlns:urn=\"urn:ActionWebService\">"
+"<soapenv:Header/>"
+"<soapenv:Body>"
+"<urn:CreateWebservice soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
+"<username xsi:type=\"xsd:string\">"+username+"</username>"
+"<password xsi:type=\"xsd:string\">"+password+"</password>"
+"</urn:CreateWebservice>"
+"</soapenv:Body>"
+"</soapenv:Envelope>";
////以下地址是通过《soapUI 4.5.2工具》解析的后的地址
URL url = new URL("地址");
URLConnection conn = url.openConnection();
conn.setUseCaches(false);
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestProperty("Content-Length", Integer.toString(soapRequestData
.length()));
conn.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
conn.setRequestProperty("SOAPAction",
"http://WebXml.com.cn/getSupportCity");
OutputStream os = conn.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os, "utf-8");
osw.write(soapRequestData);
osw.flush();
osw.close();
StringBuilder sTotalString = new StringBuilder();
String sCurrentLine = "";
InputStream is = conn.getInputStream();
BufferedReader l_reader = new BufferedReader(new InputStreamReader(
is));
while ((sCurrentLine = l_reader.readLine()) != null) {
sTotalString.append(sCurrentLine);
}
System.out.println(sTotalString.toString());
return sTotalString.toString();
}catch (Exception e) {
e.printStackTrace();
returnnull;
}
}
相关推荐
换个数据库就能用的webservice 客户端代码 框架搭建的spring mvc 数据库访问是mybatis
websevice接口文档 ,供接口开发人参考!
WebSevice 中文乱码
CXF环境配置 - jackymin CXF与Spring的集成 log4j的配置使用 Spring XML配置十二个最佳实践WebService开发实例 (Xfire+Spring+Hibernate)
Delphi7 天气预报 WebSevice
flex程序调用websevice的一个完整实例,很有帮助。
cfx源代码! 希望Java websevice开发人员多多下载!
TUXEDO之SALT与WebSevice互通-学习 .
有关jave\ajax\websevice学习总结
非常好的东东,websevice的教程,明了,清晰
XmlHttpRequest对象直接访问与通过Soap协议访问WebSevice详解示例
C#调用websevice!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Java编写的wsdl接口测试小工具,精简易用
NULL 博文链接:https://arlenye.iteye.com/blog/1389047
NULL 博文链接:https://arlenye.iteye.com/blog/1389048
WebService入门案例,使用CXF框架,与Spring进行整合,包括客户端工程和服务端工程。
NULL 博文链接:https://hmw.iteye.com/blog/1322406
利用公共webservice实现天气预报功能。 其目的是:为了学习如何调用webservice。 其中利用了无刷新技术,提高用户体验。适合与像本人这样的webservice初用者。
axis1.4部署webSevice项目测试(已有所相关的jar包)+开发指南+源码+部署相关配置wsdd文件,内有说明