sun-jaxws.xml文件,和web.xml同目录下
"1.0"
2
"2.0"
"http://java.sun.com/xml/ns/jax-ws/ri/runtime"
3
"BulletinServicePort"
implementation=
"com.sk.service.BulletinService"
url-pattern=
"/BulletinServicePort"
5
package
com.sk.service;
java.util.List;
com.sk.dao.IBulletinDao; |
com.sk.dao.impl.BulletinDaoImpl; |
<a href="http://my.oschina.net/u/142217" = "referer" target= "_blank" > @WebService </a>
|
public class BulletinService {
|
new
BulletinDaoImpl();
@WebMethod
public
String find() {
List<Gpw_Bulletin_Info> list = bulletinDao.findAll(); |
JSONArray jsonArray = JSONArray(list);
|
return
jsonArray.toString();
25 | } |
27 | } |
@javax
.jws.WebService(targetNamespace =
"http://service.sk.com/"
,serviceName =
"BulletinServiceService"
"BulletinServicePort"
)
com.sk.service.BulletinService bulletinService = com.sk.service.BulletinService();
|
bulletinService.find(); |
} |
然后,Client端(Android代码):(Config.java、SOAPUtil.java、dbconfig.properties子三个文件完成Android客户端的WebServices部署)
02 |
03 | java.io.IOException; |
05 |
07 | private static Properties prop = Properties();
|
{
09 | try {
|
catch
(IOException e) {
13 | // Todo Auto-generated catch block |
15 | } |
17 |
19 | static final String WSDL_HTTP = prop.getProperty( "WSDL_HTTP" );
|
21 | } |
org.ksoap2.serialization.soapSerializationEnvelope; |
org.xmlpull.v1.XmlPullParserException; |
SOAPUtil { |
String service,
String webMethod,Object[] params){
SoapObject(
for(
int
i=
0
;i<params.length;i++){
"params"
arams[i].toString());
request.addProperty("arg" +i,params[i]);
|
SoapSerializationEnvelope envelope = SoapSerializationEnvelope(SoapEnvelope.VER11);
|
23 | HttpTransportSE ht = HttpTransportSE(Config.WSDL_HTTP+service);
|
25 | ht.call(null 26
|
if (envelope.getResponse() != ) {
|
27 | envelope.getResponse();
|
31 | (XmlPullParserException e) { |
;
35 | 36 | 37 | } |
//192.168.0.91\:8080/SK_Java_Service/
this
.jsonAdapter();
2 | // 加载适配器
|
3 | listadapter adapter = listadapter(ListActivity. 4
|
5 | list_LV.setAdapter(adapter); |
List<Gpw_Bulletin_Info> jsonAdapter() {
03 |
"BulletinServicePort?wsdl"
"find"
05
Object[] {});
06
07 | Log.i("TAG" "data=" + data);
|
) {
09 | { |
JSONArray json =
JSONArray(data);
11 | 12 | for i = ; i < json.length(); i++) {
|
13 | Gpw_Bulletin_Info info = Gpw_Bulletin_Info();
|
.getInt(
"bulletinid"
));
17 | info.setTitle(((JSONObject) json.get(i)).getString("title" ));
|
19 | .getString("htmlcontent" 20
|
info.setStartdate(((JSONObject) json.get(i)) |
21 | "startdate"22
|
23 | list.add(info); |
25 | (JSONException e) { |
27 | } |
{
29 | Toast.makeText(getApplicationContext(),monospace!important; border:0px!important; color:blue!important; outline:0px!important; float:none!important; vertical-align:baseline!important; position:static!important; left:auto!important; top:auto!important; right:auto!important; bottom:auto!important; height:auto!important; width:auto!important; line-height:1.1em!important; font-size:10pt!important; min-height:inherit!important">"暂无数据!"30
|
.show(); |
31 | 32 | list; |
33 | } |
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。