0
我贴过这个问题昨天:How to go about creating SOAP webservice in Java和下面的这本书后:http://www.packtpub.com/java-7-jax-ws-web-services/book我已成功地创建了JAX-WS应用程序:传递XML数据,SOAP服务两难
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!";
}
}
一切都很好。但我需要的是服务方法(即“你好”)应改为“串”接受描述学生信息的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数据格式吗?