3

Is it possible to extract an attribute (as in XML attribute value) from a RequestWrapper object?

In my implementation, I'd like to use the value of the attribute, but can't reference it with @WebParam, as that is only for elements (I believe)

@SOAPBinding is defined "Document/Literal/Wrapped"

WSDL (relevant sections, target attribute at **):

<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 abstract method (able to specify XML elements with WebParam):

@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
);

Implementation:

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

It’s obvious how I can read the value of the @RequestWrapper bean Status (Entity via @WebParam), but is there any way to access the value (Handle) within Status. WebParam, as far as I understand, does not support attributes, only elements.

An alternate way to ask/seek solution might be asking how to access the full bean being referenced by RequestWrapper, in this case GetStatus.

I know if I transition to Document/Literal/Bare I can simply have the parameters and return value reflect the bean, but I'd prefer to solve this using wrapped as all information points to this being the most widely preferred binding.

brianmckenna
  • 61
  • 1
  • 4

2 Answers2

3

Self-answered for posterity.

No. To qualify as wrapped style, only elements must be present.

Was reviewing the JAX-WS specification overnight

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.

brianmckenna
  • 61
  • 1
  • 4
0

Non-elements can be present too, as long as they are contained inside an javax.xml.ws.Holder object.

Vitaly Olegovitch
  • 3,509
  • 6
  • 33
  • 49