gpt4 book ai didi

soap - 如何提取 JAX-WS @RequestWrapper 属性(或完整 bean)

转载 作者:行者123 更新时间:2023-12-04 22:50:22 24 4
gpt4 key购买 nike

是否可以从 RequestWrapper 对象中提取属性(如 XML 属性值)?

在我的实现中,我想使用属性的值,但不能用@WebParam 引用它,因为它只适用于元素(我相信)

@SOAPBinding 定义为“Document/Literal/Wrapped”

WSDL(相关部分,目标属性位于 **):

<s:element name="GetStatus">
<s:complexType>
<s:element minOccurs="0" maxOccurs="1" name="Entity" type="s0:Entity"/>
**<s:attribute name="Handle" type="s:string"/>
</s:complexType>
</s:element>
<s:element name="GetStatusResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="StatusCode" type="s0:StatusCode"/>
<s:element minOccurs="0" maxOccurs="1" name="Server" type="s0:Server"/>
</s:sequence>
</s:complexType>
</s:element>

<message name="GetStatusIn">
<part name="parameters" element="s0:GetStatus"/>
</message>
<message name="GetStatusOut">
<part name="parameters" element="s0:GetStatusResponse"/>
</message>

<portType name="Service">
<operation name="GetStatus">
<input message="s0:GetStatusIn"/>
<output message="s0:GetStatusOut"/>
</operation>
</portType>

SEI抽象方法(能够用WebParam指定XML元素):

@WebMethod(operationName="GetStatus")
@RequestWrapper(localName=“GetStatus",className="com.example.GetStatus")
@ResponseWrapper(localName=“GetStatusResponse",className="com.example.GetStatusResponse")
public void getStatus(
@WebParam(name="Entity”)Entity entity,
@WebParam(name="StatusCode",mode=WebParam.Mode.OUT)Holder<StatusCode> statusCode,
@WebParam(name="Server", mode=WebParam.Mode.OUT)Holder<Server> server
);

实现:

@Override
public void getStatus(
Entity entity,
Holder<StatusCode> statusCode,
Holder<Server> server
) { ... }

很明显我可以读取@RequestWrapper bean Status(Entity 通过@WebParam)的值,但是有什么方法可以访问该值(Handle) 在 Status 中。 WebParam,据我了解,不支持属性,只支持元素。

另一种询问/寻求解决方案的方法可能是询问如何访问 RequestWrapper 引用的完整 bean,在本例中为 GetStatus

我知道如果我转换到 Document/Literal/Bare,我可以简单地让参数和返回值反射(reflect) bean,但我更愿意使用 wrapped 来解决这个问题,因为所有信息都表明这是最广泛首选的绑定(bind)。

最佳答案

为后代 self 回答。

没有。要符合包装样式,必须仅存在元素。

正在通宵审查 JAX-WS 规范

2.3.1.2 Wrapper Style

A WSDL operation qualifies for wrapper style mapping only if the following criteria are met:

(i) The operation’s input and output messages (if present) each contain only a single part

(ii) The input message part refers to a global element declaration whose localname is equal to the operation name

(iii) The output message (if present) part refers to a global element declaration

(iv) The elements referred to by the input and output message (if present) parts (henceforth referred to as wrapper elements) are both complex types defined using the xsd:sequence compositor

(v) The wrapper elements only contain child elements, they MUST not contain other structures such as wildcards (element or attribute), xsd:choice, substitution groups (element references are not permitted) or attributes; furthermore, they MUST not be nillable.

关于soap - 如何提取 JAX-WS @RequestWrapper 属性(或完整 bean),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9951099/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com