我怎样才能从axis2肥皂响应中省略字段?
我有一个 Axis2 Web 服务,它请求某些对象的状态。 这些对象可以存在于服务器上,也可以不存在。
Web服务是用POJO实现的,wsdl是用java2wsdl工具生成的。
假设 SOAP 响应的相关部分如下所示:
细绳 整数 整数 细绳 ......
我想做的是这样的: - 当在对象列表中找到该对象时,我希望所有字段都有一个值并将其发送到客户端。 - 当在对象列表中找不到对象时,我只希望 objectName 和 objectStatus 字段具有值并将其发送到客户端。 SOAP 消息中应该缺少其他对象属性值。
我怎样才能做到这一点?
谢谢。
I have an Axis2 Web Service that requests the status of some objects. The objects can either exist on the server, or not exist.
The web service is implemented with POJOs, and the wsdl is generated with java2wsdl tool.
Lets say the relevant part of the SOAP response looks like this:
String
int
int
String
......
What I want to do is this:
- when the object is found in the list of objects, I want all the fields to have a value and be sent to the client.
- when the object in not found in the list of objects, I only want the objectName and objectStatus fields to have values and be sent to the client. The other object properties values should be missing from the SOAP message.
How can I do that?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会向响应添加一个
boolean
标志,例如isObjectPresent
。 然后,您的客户可以查看此标志以确定该对象是否“存在”。 您未在响应对象中设置的任何值都将设置其默认值(int = 0,String =“”),但这样您可以向客户端发出信号,不要注意这些字段。I would add a
boolean
flag to the Response, something likeisObjectPresent
. Your clients can then take a look at this flag to determine if the object "is present" or not. Any values you do not set in the response object will have their default values set (int = 0, String = ""), but this way you can signal to the client not to pay attention to those fields.