【发布时间】:2014-05-03 09:27:48
【问题描述】:
我昨天发布了这个问题:How to go about creating SOAP webservice in Java 并在关注这本书之后:http://www.packtpub.com/java-7-jax-ws-web-services/book 我已经成功地创建了一个 JAX-WS 应用程序:
package hellows;
import javax.jws.*;
@WebService(portName = "HelloWSPort", serviceName = "HelloWSService", targetNamespace = "http://hellows/", endpointInterface = "hellows.HelloWS")
public class HelloWSImpl implements HelloWS {
public String hello(String name) {
// replace with your impl here
return "Hello "+name +" Welcome to Web Services!";
}
}
一切都很好。但我需要的是服务方法(即“hello”)应该而不是“string”接受描述学生详细信息的 XML 文件(我已经更改了原始文件):
<?STU version="1.0"?>
<stu>
<id sequence="1">2354282</id>
<date>2012-06-17T21:19:15</date>
<student interest="food" status="newadmission">
<id></id>
<birthyear>2012</birthyear>
<sex>Male</sex>
<address>Sonata</address>
<class>3</class>
</student>
</stu>
然后服务将处理它并返回一个 Java 对象,其中包含基于某种算法的标志“通过”/“失败”。
所以我的问题是:
- 服务方法应该如何接收这个 XML 数据?作为字符串?还是其他方式?
- 我需要在 config 文件夹中的 .wsdl 和 .xsd 文件中描述这种 XML 数据格式吗?
【问题讨论】:
标签: java web-services soap wsdl jax-ws