metro-jax-ws
metro-jax-ws copied to clipboard
JAXWS marshals null WebParam headers with xsi:nil=true
JAXWS wsimport generate code as follows:
A Header class
@XmlRootElement(name = "MyCustomHeader" ) public class MyCustomHeader
{ ... }
A PortType class with the following method:
@WebMethod(operationName = "AnOperation", action = "AnAction") @WebResult(name = "OperationReply", targetNamespace = "http://example.com", partName = "reply") public OperationReply anOperation( @WebParam(name = "OperationRequest", targetNamespace = "http://example.com", partName = "request") OperationRequest operationrequest, @WebParam(name = "MyCustomHeader", targetNamespace = "http://example.com", header = true, mode = WebParam.Mode.INOUT, partName = "header") Holder<MyCustomHeader> header);
Calling the method as follows:
port.anOperation(operationRequest, null);
Marshalls an XML with the MyCustomHeader as null.
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Header> <ns1:MyCustomHeader ... xsi:nil="true"/> </S:Header> ... </S:Envelope>
Any other Web Services framework discards headers passed as null values to the operation.
JAXWS should discard headers which are null.
A workaround is to implement a SOAPHandler to remove the null headers and add it to the handle chain of the port.
Environment
Java SDK 1.6.0_26 Windows XP SP3 JAXWS 2.2.6
Affected Versions
[2.2.6]
Source: https://github.com/javaee/metro-jax-ws/issues/1079 Author: glassfishrobot