这是我的网络服务代码
import java.util.ArrayList;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
@WebService
@SOAPBinding(style=Style.RPC)
public class ProductCatalog {
public ArrayList<String> getProductCategories()
{
ArrayList<String> categories=new ArrayList<String>();
categories.add("books");
categories.add("movies");
categories.add("music");
return categories;
}
}
I have given `@SOAPBinding(style=Style.RPC)` annotation, but this is not showing any effect in generated wsdl..
生成的 wsdl 仅包含来自外部位置的架构
<types>
<xsd:schema>
<xsd:import namespace="http://symp.com/" schemaLocation="http://rajasekhar_pc:9090/NewTestMart/ProductCatalogService?xsd=1"/>
</xsd:schema>
</types>
但是当我将 web 方法返回类型更改为 String 时,它的工作正常就像
@WebService
@SOAPBinding(style=Style.RPC)
public class ProductCatalog {
public String getProductCategories()
{
return "Hello World";
}
}
并且 wsdl 更改并且它不引用任何外部文档
<types/>
<message name="getProductCategories"/>
<message name="getProductCategoriesResponse">
<part name="return" type="xsd:string"/>
</message>
有什么方法可以获取返回类型数组列表的 rpc 样式...甚至文档 STLyle soap inded wsdl 正在返回 ArrayList 对象...我想要数据
//////////更新代码///////////
import java.util.ArrayList;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
@WebService
@SOAPBinding(style = Style.RPC)
public class PatientsList {
@WebMethod
public BeanList getpatientList()
{
BeanList bean=new BeanList();
ArrayList<String> patientList=new ArrayList<String>();
patientList.add("ajay");
patientList.add("vijay");
patientList.add("kumari");
bean.setPatientList(patientList);
//return bean;
return bean ;
}
}
import java.util.ArrayList;
public class BeanList {
private ArrayList<String> patientList;
public ArrayList<String> getPatientList() {
return patientList;
}
public void setPatientList(ArrayList<String> patientList) {
this.patientList = patientList;
}
}
即使这样
<types>
<xsd:schema>
<xsd:import namespace="http://symp.com/" schemaLocation="http://rajasekhar_pc:9090/NewTestMart/PatientsListService?xsd=1"/>
</xsd:schema>
</types>
but i want the wsdl to be in RPC style
最佳答案
使用数组而不是 ArrayList,因为 JAXB 不能将集合作为顶级对象处理,只能作为 bean 的属性。
请注意,在 JAX-WS 中,不支持将 RPC/encoded 作为消息传递模式。如果您想发送 SOAP 编码消息或创建 RPC/编码样式的 WSDL,您可以使用 JAX-RPC 或 Apache Axis V1。
关于java - @SOAPBinding(style = Style.RPC) 用于返回 ArrayList 的 Web 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29076916/