ArrayOfXXX类超出数组类型的soap输入参数 [英] ArrayOfXXX class out of soap input param of array type
问题描述
我有一个输入参数为Array的方法。
I have a method with input param as Array. When I generate stub out of it creates List type.
但是我想知道如何围绕数组类型创建包装类。对于类 Apple
,应该创建 ArrayOfApple
。
But I want to know how to create a wrapper class around array type e.g. for class Apple
it should create ArrayOfApple
.
是
注意:我正在使用 JAXWS
使用 Apache CXF
实现
Note: I am using JAXWS
with Apache CXF
implementation
下面是示例代码:
EmployeeService.java
:
@WebService(endpointInterface="com.test.EmployeeService")
@SOAPBinding(style=Style.DOCUMENT)
public class EmployeeService {
public String updateEmpRoles(@WebParam(name="EmpRoles")EmpRole[] empRoles) {
return "SUCCESS";
}
}
EmpRole.java
:
@XmlType(name="EmpRole")
public class EmpRole {
private String empRole;
public String getEmpRole() {
return empRole;
}
public void setEmpRole(String empRole) {
this.empRole = empRole;
}
}
发布后,wsdl的生成方式如下-
After publishing, wsdl is getting generated as below -
但是我期望WSDL应该创建 ArrayOfEmpRole
,它应该包装 List< EmpRole>
。
But what I expect is WSDL should create ArrayOfEmpRole
and it should wrap List<EmpRole>
.
简而言之,请帮忙
简而言之,在下面的链接中,我想要Björn不需要的东西。 (在他的情况下,它是自动创建ArrayOfXXX的,这就是我需要的)- SOAP方法中的数组通过JAX-WS生成的参数吗?
In short - I want something that Björn doesn't want in below link. (In his case, it's automatically creating ArrayOfXXX, this is what I need) - Arrays in SOAP method Parameters generated via JAX-WS?
推荐答案
我将从代码中切换首先使用合约优先方法,这意味着从WSDL开始并使用wsdl2java从中生成存根。这样,您可以确保WSDL看起来像您想要的方式。
I would switch from Code first to a Contract first approach which means start with the WSDL and generate a stub using wsdl2java from it. This way you can ensure that the WSDL looks like the way you want.
如果您要坚持当前的方法,最简单的方法就是使用包装器。介绍另一堂课。
If you want to stick to the current approach, the easiest way to achieve a wrapper is probably to introduce another class.
这篇关于ArrayOfXXX类超出数组类型的soap输入参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!