Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CXF-8762] CXF client sends the SOAPAction header without quotes #1005

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ private void setSoapAction(SoapMessage message) {
if (reqHeaders != null) {
tempReqHeaders.putAll(reqHeaders);
}
if (!tempReqHeaders.containsKey(SoapBindingConstants.SOAP_ACTION)) {
tempReqHeaders.put(SoapBindingConstants.SOAP_ACTION, Collections.singletonList(action));
}
tempReqHeaders.put(SoapBindingConstants.SOAP_ACTION, Collections.singletonList(action));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the change I am not comfortable with, as per JIRA comment [1], we should not try to correct client's request, @dkulp do you have an opinion?

[1] https://issues.apache.org/jira/browse/CXF-8762?focusedCommentId=17612109&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17612109

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed we should address it in camel-cxf, to ensure it follows the RFC in the first place

message.put(Message.PROTOCOL_HEADERS, tempReqHeaders);
} else if (message.getVersion() instanceof Soap12 && !"\"\"".equals(action)) {
String ct = (String) message.get(Message.CONTENT_TYPE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
package org.apache.cxf.binding.soap.interceptor;

import java.lang.reflect.Method;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import javax.xml.namespace.QName;

import org.apache.cxf.binding.soap.SoapBindingConstants;
import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.binding.soap.model.SoapOperationInfo;
import org.apache.cxf.helpers.CastUtils;
Expand Down Expand Up @@ -74,6 +77,23 @@ public void testRequestorOutboundSoapAction() throws Exception {
assertEquals("\"http://foo/bar/SEI/opReq\"", soapaction.get(0));
}

@Test
public void testSoapActionFromHeaders() throws Exception {
SoapMessage message = setUpMessage();
Map<String, List<String>> transportHeaders = new TreeMap<>();
// Set the header value as a simple string (not quoted) just as DefaultCxfBinding#propagateHeadersFromCamelToCxf
// does
transportHeaders.put(SoapBindingConstants.SOAP_ACTION, Collections.singletonList("http://foo/bar/SEI/opReq"));
message.put(Message.PROTOCOL_HEADERS, transportHeaders);
interceptor.handleMessage(message);
control.verify();

Map<String, List<String>> reqHeaders = CastUtils.cast((Map<?, ?>) message.get(Message.PROTOCOL_HEADERS));
List<String> soapAction = reqHeaders.get(SoapBindingConstants.SOAP_ACTION);
// test the SOAPAction value is quoted just as required by a specification
assertEquals(Collections.singletonList("\"http://foo/bar/SEI/opReq\""), soapAction);
}

private SoapMessage setUpMessage() throws Exception {

SoapMessage message = new SoapMessage(new MessageImpl());
Expand Down Expand Up @@ -111,4 +131,4 @@ private BindingOperationInfo setUpBindingOperationInfo(String nsuri,
private interface SEI {
String op();
}
}
}