[ https://issues.apache.org/jira/browse/CXF-6908?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15286898#comment-15286898 ]
ASF GitHub Bot commented on CXF-6908: ------------------------------------- GitHub user asoldano opened a pull request: https://github.com/apache/cxf/pull/136 [CXF-6908] Fallback to getting the envelope ns prefix from the SOAP p… …art in the SAAJStreamWriter if the context can't provide it You can merge this pull request into a Git repository by running: $ git pull https://github.com/asoldano/cxf CXF-6908 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/cxf/pull/136.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #136 ---- commit 6ff15867e8f9da07ba689b3448d99511cfff1cc4 Author: Alessio Soldano <asold...@redhat.com> Date: 2016-05-17T15:52:24Z [CXF-6908] Fallback to getting the envelope ns prefix from the SOAP part in the SAAJStreamWriter if the context can't provide it ---- > Prefix "SOAP-ENV" for element "SOAP-ENV:Fault" is not bound > ----------------------------------------------------------- > > Key: CXF-6908 > URL: https://issues.apache.org/jira/browse/CXF-6908 > Project: CXF > Issue Type: Bug > Components: Soap Binding > Reporter: Alessio Soldano > > I have an endpoint as follows: > {noformat} > @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; > } > } > {noformat} > The client fails in processing the ws-security soap message that's returned > by the endpoint above: > {noformat} > ... > 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) > {noformat} > 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 > {noformat} > <SOAP-ENV:Envelope > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body/></SOAP-ENV:Envelope> > {noformat} > into > {noformat} > <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> > {noformat} > (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: > {noformat} > msg.getSOAPPart().getEnvelope().setPrefix("fooe"); > {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)