Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Component/s: Soap Binding
-
Labels:None
-
Estimated Complexity:Unknown
Description
I have an endpoint as follows:
@WebServiceProvider(wsdlLocation = "WEB-INF/FaultService.wsdl", targetNamespace = "http://signencrypt.foo.github.com/")
@ServiceMode(Mode.MESSAGE)
@BindingType(SOAPBinding.SOAP11HTTP_BINDING)
public class FaultService implements Provider<SOAPMessage>
{
@Resource
private WebServiceContext _wsContext;
@Override
public SOAPMessage invoke(SOAPMessage request)
{
try
{
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage msg = messageFactory.createMessage();
msg.getSOAPBody().addFault(new QName("http://schemas.xmlsoap.org/soap/envelope/", "Server"),
"Reason: cos I'm hungry");
return msg;
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
}
The client fails in processing the ws-security soap message that's returned by the endpoint above:
...
Caused by: org.apache.xml.security.encryption.XMLEncryptionException: The prefix "SOAP-ENV" for element "SOAP-ENV:Fault" is not bound.
[java] Original Exception was org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 212; The prefix "SOAP-ENV" for element "SOAP-ENV:Fault" is not bound.
[java] at org.apache.xml.security.encryption.DocumentSerializer.deserialize(DocumentSerializer.java:93)
[java] at org.apache.xml.security.encryption.DocumentSerializer.deserialize(DocumentSerializer.java:49)
[java] at org.apache.xml.security.encryption.XMLCipher.decryptElement(XMLCipher.java:1685)
[java] at org.apache.xml.security.encryption.XMLCipher.decryptElementContent(XMLCipher.java:1716)
[java] at org.apache.xml.security.encryption.XMLCipher.doFinal(XMLCipher.java:990)
[java] at org.apache.ws.security.processor.ReferenceListProcessor.decryptEncryptedData(ReferenceListProcessor.java:340)
[java] ... 27 more
[java] Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 212; The prefix "SOAP-ENV" for element "SOAP-ENV:Fault" is not bound.
[java] at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:244)
It seems that when the soap fault in the endpoint is created with no explicit ns prefix for the envelope, the code in SoapOutInterceptor::writeSoapEnvelopeStart modifies the namespace prefixes and basically turns a message like
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body/></SOAP-ENV:Envelope>
into
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"/><soap:Body/></soap:Envelope>
(SOAP-ENV is the saaj impl default value for missing explicit soap envelope prefix)
This is probably causing a problem with the fault later added in the body because of the ns prefix SOAP-ENV not being bound anymore in the envelope.
The problem is avoided by explicitly setting the fault prefix in the endpoint:
msg.getSOAPPart().getEnvelope().setPrefix("fooe");
Attachments
Issue Links
- links to