JAVA6 Webservice疑问
本帖最后由 xiongchangjing 于 2012-09-17 20:24:59 编辑 最近在写一个WebService项目,服务端用JAVA6自带的Webservice写,客户端用axis2访问C#的Webservice,访问得到的数据让JAVA写的服务端WebService返回给其他地方
发现服务端生成的WSDL文件很可疑,代码如下
@WebService
public class ScenicImpl{
public List<Announcement> SearchAnnouncement(int num) {
logger.info("进入访问公告查询业务方法");
List<Announcement> list = null;
try {
//访问C# WebService服务 开始
Ziuu_dataStub client = new Ziuu_dataStub(); //axis2工具自动生成的客户端
GetAnnouncement getAnnouncement = new GetAnnouncement();
getAnnouncement.setNum(num);
ArrayOfTAnnouncement arrayOfTAnnouncement = client.getAnnouncement(getAnnouncement).getGetAnnouncementResult();
//访问C# WebService服务 结束
TAnnouncement[] announcements = arrayOfTAnnouncement.getTAnnouncement();
list = new ArrayList<Announcement>();
for (TAnnouncement announcement : announcements) {
Announcement javaAnnouncement = new Announcement();
javaAnnouncement.setSystemId(announcement.getSystemId().longValue());
javaAnnouncement.setTitle(announcement.getTitle());
javaAnnouncement.setContents(announcement.getContents());
String releaseDate = DateUtil.getDateTime(announcement.getReleaseDate());
javaAnnouncement.setReleaseDate(releaseDate);
javaAnnouncement.setSource(announcement.getSource());
System.out.println(announcement.getTitle());
System.out.println(releaseDate);
list.add(javaAnnouncement);
logger.error("访问公告查询业务方法完毕");
}
} catch (Exception e) {
logger.error("访问公告查询业务方法出现异常"+e.toString());
}
return list;
}
}
public static void main(String[] args) {
String url="http://10.10.60.31:8080/ZiuuWebService/com.scenic.service.impl.ScenicImpl";
Endpoint.publish(url,new ScenicImpl());
ScenicImpl impl = new ScenicImpl();
impl.SearchAnnouncement(3);
}
<?xml version="1.0" encoding="UTF-8" ?>
- <!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6.
-->
- <!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6.
-->
- <definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://impl.service.scenic.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://impl.service.scenic.com/" name="ScenicImplService">
- <types>
- <xsd:schema>
<xsd:import namespace="http://impl.service.scenic.com/" schemaLocation="http://10.10.60.31:8080/ZiuuWebService/com.scenic.service.impl.ScenicImpl?xsd=1" />
</xsd:schema>
</types>
- <message name="SearchAnnouncement">
<part name="parameters" element="tns:SearchAnnouncement" />
</message>
- <message name="SearchAnnouncementResponse">
<part name="parameters" element="tns:SearchAnnouncementResponse" />
</message>
- <portType name="ScenicImpl">
- <operation name="SearchAnnouncement">
<input message="tns:SearchAnnouncement" />
<output message="tns:SearchAnnouncementResponse" />
</operation>
</portType>
- <binding name="ScenicImplPortBinding" type="tns:ScenicImpl">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <operation name="SearchAnnouncement">
<soap:operation soapAction="" />
- <input>
<soap:body use="literal" />
</input>
- <output>
<soap:body use="literal" />
</output>
</operation>
</binding>
- <service name="ScenicImplService">
- <port name="ScenicImplPort" binding="tns:ScenicImplPortBinding">
<soap:address location="http://10.10.60.31:8080/ZiuuWebService/com.scenic.service.impl.ScenicImpl" />
</port>
</service>
</definitions>