Author: dkulp
Date: Tue Apr 15 13:01:14 2008
New Revision: 648400
URL: http://svn.apache.org/viewvc?rev=648400&view=rev
Log:
[CXF-1496] Patch for mtom attachement headers from Gianfranco Boccalon applied
Update a bunch of places to set fault codes to :Client instead of :Server if
appropriate
Modified:
incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java
incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentSerializerTest.java
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
Modified:
incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java?rev=648400&r1=648399&r2=648400&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java
(original)
+++
incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java
Tue Apr 15 13:01:14 2008
@@ -133,7 +133,14 @@
}
//honor JAXBAnnotation
part.setProperty("honor.jaxb.annotations", true);
- parameters.put(part, dr.read(part, xmlReader));
+ try {
+ parameters.put(part, dr.read(part, xmlReader));
+ } catch (Fault f) {
+ if (!isRequestor(message)) {
+ f.setFaultCode(Fault.FAULT_CODE_CLIENT);
+ }
+ throw f;
+ }
}
}
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java?rev=648400&r1=648399&r2=648400&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
Tue Apr 15 13:01:14 2008
@@ -51,6 +51,25 @@
String bodyCt = (String) message.get(Message.CONTENT_TYPE);
bodyCt = bodyCt.replaceAll("\"", "\\\"");
+
+ // The bodyCt string is used enclosed within "", so if it contains the
character ", it
+ // should be adjusted, like in the following case:
+ // application/soap+xml;
action="urn:ihe:iti:2007:RetrieveDocumentSet"
+ // The attribute action is added in SoapActionOutInterceptor, when
SOAP 1.2 is used
+ // The string has to be changed in:
+ // application/soap+xml";
action="urn:ihe:iti:2007:RetrieveDocumentSet
+ // so when it is enclosed within "", the result must be:
+ // "application/soap+xml";
action="urn:ihe:iti:2007:RetrieveDocumentSet"
+ // instead of
+ // "application/soap+xml;
action="urn:ihe:iti:2007:RetrieveDocumentSet""
+ // that is wrong because when used it produces:
+ // type="application/soap+xml;
action="urn:ihe:iti:2007:RetrieveDocumentSet""
+ if ((bodyCt.indexOf('"') != -1) && (bodyCt.indexOf(';') != -1)) {
+ int pos = bodyCt.indexOf(';');
+ StringBuffer st = new StringBuffer(bodyCt.substring(0 , pos));
+ st.append("\"").append(bodyCt.substring(pos, bodyCt.length() - 1));
+ bodyCt = st.toString();
+ }
String enc = (String) message.get(Message.ENCODING);
if (enc == null) {
enc = "UTF-8";
@@ -91,9 +110,7 @@
.append(enc)
.append("; type=\"")
.append(bodyCt)
- .append("; charset=")
- .append(enc)
- .append("\"");
+ .append("\";");
writeHeaders(mimeBodyCt.toString(), BODY_ATTACHMENT_ID, writer);
out.write(writer.getBuffer().toString().getBytes(encoding));
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java?rev=648400&r1=648399&r2=648400&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java
Tue Apr 15 13:01:14 2008
@@ -134,7 +134,14 @@
Fault.FAULT_CODE_CLIENT);
}
- o = dr.read(p, xmlReader);
+ try {
+ o = dr.read(p, xmlReader);
+ } catch (Fault fault) {
+ if (!isRequestor(message)) {
+ fault.setFaultCode(Fault.FAULT_CODE_CLIENT);
+ }
+ throw fault;
+ }
if (o != null) {
parameters.put(p, o);
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java?rev=648400&r1=648399&r2=648400&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java
Tue Apr 15 13:01:14 2008
@@ -91,104 +91,111 @@
bop = getBindingOperationInfo(exchange, startQName, client);
}
- if (bop != null && bop.isUnwrappedCapable()) {
- ServiceInfo si = bop.getBinding().getService();
- // Wrapped case
- MessageInfo msgInfo = setMessage(message, bop, client, si);
-
- // Determine if there is a wrapper class
- if (msgInfo.getMessageParts().get(0).getTypeClass() != null) {
- Object wrappedObject =
dr.read(msgInfo.getMessageParts().get(0), xmlReader);
- parameters.put(msgInfo.getMessageParts().get(0),
wrappedObject);
- } else {
- // Unwrap each part individually if we don't have a wrapper
-
- bop = bop.getUnwrappedOperation();
-
- msgInfo = setMessage(message, bop, client, si);
- List<MessagePartInfo> messageParts = msgInfo.getMessageParts();
- Iterator<MessagePartInfo> itr = messageParts.iterator();
-
- // advance just past the wrapped element so we don't get
- // stuck
- if (xmlReader.getEventType() ==
XMLStreamConstants.START_ELEMENT) {
- StaxUtils.nextEvent(xmlReader);
- }
-
- // loop through each child element
- getPara(xmlReader, dr, parameters, itr, message);
- }
-
- } else {
- //Bare style
- BindingMessageInfo msgInfo = null;
-
- if (bop != null) { //for xml binding or client side
- getMessageInfo(message, bop);
- if (client) {
- msgInfo = bop.getOutput();
+ try {
+ if (bop != null && bop.isUnwrappedCapable()) {
+ ServiceInfo si = bop.getBinding().getService();
+ // Wrapped case
+ MessageInfo msgInfo = setMessage(message, bop, client, si);
+
+ // Determine if there is a wrapper class
+ if (msgInfo.getMessageParts().get(0).getTypeClass() != null) {
+ Object wrappedObject =
dr.read(msgInfo.getMessageParts().get(0), xmlReader);
+ parameters.put(msgInfo.getMessageParts().get(0),
wrappedObject);
} else {
- msgInfo = bop.getInput();
+ // Unwrap each part individually if we don't have a wrapper
+
+ bop = bop.getUnwrappedOperation();
+
+ msgInfo = setMessage(message, bop, client, si);
+ List<MessagePartInfo> messageParts =
msgInfo.getMessageParts();
+ Iterator<MessagePartInfo> itr = messageParts.iterator();
+
+ // advance just past the wrapped element so we don't get
+ // stuck
+ if (xmlReader.getEventType() ==
XMLStreamConstants.START_ELEMENT) {
+ StaxUtils.nextEvent(xmlReader);
+ }
+
+ // loop through each child element
+ getPara(xmlReader, dr, parameters, itr, message);
}
- }
-
- Collection<OperationInfo> operations = null;
- operations = new ArrayList<OperationInfo>();
- Endpoint ep = exchange.get(Endpoint.class);
- ServiceInfo si = ep.getEndpointInfo().getService();
- operations.addAll(si.getInterface().getOperations());
-
- if (!StaxUtils.toNextElement(xmlReader)) {
- // empty input
-
- // TO DO : check duplicate operation with no input
- for (OperationInfo op : operations) {
- MessageInfo bmsg = op.getInput();
- if (bmsg.getMessageParts().size() == 0) {
- BindingOperationInfo boi =
ep.getEndpointInfo().getBinding().getOperation(op);
- exchange.put(BindingOperationInfo.class, boi);
- exchange.put(OperationInfo.class, op);
- exchange.setOneWay(op.isOneWay());
+
+ } else {
+ //Bare style
+ BindingMessageInfo msgInfo = null;
+
+ if (bop != null) { //for xml binding or client side
+ getMessageInfo(message, bop);
+ if (client) {
+ msgInfo = bop.getOutput();
+ } else {
+ msgInfo = bop.getInput();
}
}
- return;
- }
-
- int paramNum = 0;
-
- do {
- QName elName = xmlReader.getName();
- Object o = null;
-
- MessagePartInfo p;
- if (!client && msgInfo != null && msgInfo.getMessageParts() !=
null
- && msgInfo.getMessageParts().size() == 0) {
- //no input messagePartInfo
+
+ Collection<OperationInfo> operations = null;
+ operations = new ArrayList<OperationInfo>();
+ Endpoint ep = exchange.get(Endpoint.class);
+ ServiceInfo si = ep.getEndpointInfo().getService();
+ operations.addAll(si.getInterface().getOperations());
+
+ if (!StaxUtils.toNextElement(xmlReader)) {
+ // empty input
+
+ // TO DO : check duplicate operation with no input
+ for (OperationInfo op : operations) {
+ MessageInfo bmsg = op.getInput();
+ if (bmsg.getMessageParts().size() == 0) {
+ BindingOperationInfo boi =
ep.getEndpointInfo().getBinding().getOperation(op);
+ exchange.put(BindingOperationInfo.class, boi);
+ exchange.put(OperationInfo.class, op);
+ exchange.setOneWay(op.isOneWay());
+ }
+ }
return;
}
- if (msgInfo != null && msgInfo.getMessageParts() != null
- && msgInfo.getMessageParts().size() > 0) {
- assert msgInfo.getMessageParts().size() > paramNum;
- p = msgInfo.getMessageParts().get(paramNum);
- } else {
- p = findMessagePart(exchange, operations, elName, client,
paramNum);
- }
-
- if (p == null) {
- throw new Fault(new
org.apache.cxf.common.i18n.Message("NO_PART_FOUND", LOG, elName),
- Fault.FAULT_CODE_CLIENT);
- }
-
- o = dr.read(p, xmlReader);
- parameters.put(p, o);
-
- paramNum++;
- } while (StaxUtils.toNextElement(xmlReader));
-
- }
-
- if (parameters.size() > 0) {
- message.setContent(List.class, parameters);
+
+ int paramNum = 0;
+
+ do {
+ QName elName = xmlReader.getName();
+ Object o = null;
+
+ MessagePartInfo p;
+ if (!client && msgInfo != null &&
msgInfo.getMessageParts() != null
+ && msgInfo.getMessageParts().size() == 0) {
+ //no input messagePartInfo
+ return;
+ }
+ if (msgInfo != null && msgInfo.getMessageParts() != null
+ && msgInfo.getMessageParts().size() > 0) {
+ assert msgInfo.getMessageParts().size() > paramNum;
+ p = msgInfo.getMessageParts().get(paramNum);
+ } else {
+ p = findMessagePart(exchange, operations, elName,
client, paramNum);
+ }
+
+ if (p == null) {
+ throw new Fault(new
org.apache.cxf.common.i18n.Message("NO_PART_FOUND", LOG, elName),
+ Fault.FAULT_CODE_CLIENT);
+ }
+
+ o = dr.read(p, xmlReader);
+ parameters.put(p, o);
+
+ paramNum++;
+ } while (StaxUtils.toNextElement(xmlReader));
+
+ }
+
+ if (parameters.size() > 0) {
+ message.setContent(List.class, parameters);
+ }
+ } catch (Fault f) {
+ if (!isRequestor(message)) {
+ f.setFaultCode(Fault.FAULT_CODE_CLIENT);
+ }
+ throw f;
}
}
Modified:
incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentSerializerTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentSerializerTest.java?rev=648400&r1=648399&r2=648400&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentSerializerTest.java
(original)
+++
incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentSerializerTest.java
Tue Apr 15 13:01:14 2008
@@ -84,7 +84,7 @@
MimeMultipart multipart = (MimeMultipart) inMsg.getContent();
MimeBodyPart part = (MimeBodyPart) multipart.getBodyPart(0);
- assertEquals("application/xop+xml; charset=UTF-8;
type=\"application/soap+xml; charset=UTF-8\"",
+ assertEquals("application/xop+xml; charset=UTF-8;
type=\"application/soap+xml\";",
part.getHeader("Content-Type")[0]);
assertEquals("binary", part.getHeader("Content-Transfer-Encoding")[0]);
assertEquals("<[EMAIL PROTECTED]>", part.getHeader("Content-ID")[0]);
@@ -147,7 +147,7 @@
MimeMultipart multipart = (MimeMultipart) inMsg.getContent();
MimeBodyPart part = (MimeBodyPart) multipart.getBodyPart(0);
- assertEquals("application/xop+xml; charset=UTF-8;
type=\"application/soap+xml; charset=UTF-8\"",
+ assertEquals("application/xop+xml; charset=UTF-8;
type=\"application/soap+xml\";",
part.getHeader("Content-Type")[0]);
assertEquals("binary", part.getHeader("Content-Transfer-Encoding")[0]);
assertEquals("<[EMAIL PROTECTED]>", part.getHeader("Content-ID")[0]);
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java?rev=648400&r1=648399&r2=648400&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
Tue Apr 15 13:01:14 2008
@@ -49,12 +49,21 @@
super(factory);
}
+ protected SOAPFaultException findSoapFaultException(Throwable ex) {
+ if (ex instanceof SOAPFaultException) {
+ return (SOAPFaultException)ex;
+ }
+ if (ex.getCause() != null) {
+ return findSoapFaultException(ex.getCause());
+ }
+ return null;
+ }
protected Fault createFault(Throwable ex, Method m, List<Object> params,
boolean checked) {
//map the JAX-WS faults
- if (ex instanceof SOAPFaultException) {
- SOAPFaultException sfe = (SOAPFaultException)ex;
+ SOAPFaultException sfe = findSoapFaultException(ex);
+ if (sfe != null) {
SoapFault fault = new SoapFault(sfe.getFault().getFaultString(),
- sfe,
+ ex,
sfe.getFault().getFaultCodeAsQName());
fault.setRole(sfe.getFault().getFaultActor());
fault.setDetail(sfe.getFault().getDetail());