Author: dkulp
Date: Thu Jul 30 21:20:38 2009
New Revision: 799444
URL: http://svn.apache.org/viewvc?rev=799444&view=rev
Log:
Merged revisions 799439 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r799439 | dkulp | 2009-07-30 17:04:55 -0400 (Thu, 30 Jul 2009) | 2 lines
Allow and endpoint to specify what headers it can process itself thus
allowing other mustUnderstands to be caught before invoke
........
Modified:
cxf/branches/2.2.x-fixes/ (props changed)
cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/MustUnderstandInterceptor.java
cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHeaderTest.java
cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/outofband/header/Server.java
Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jul 30 21:20:38 2009
@@ -1 +1 @@
-/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305,787323,787366,787849,788030,788060,788187,788444,788451,788703,788752,788774,788819-788820,789013,789371,789387,789420,789527-789530,789704-789705,789788,789811,789896-789901,790074,790094,790134,790188,790294,790553,790637-790644,790868,791301,791354,791538,791753,791947,792007,792096,792183,792261-792265,792271,792604,792683-792685,792975,792985,793059,793570,794297,794396,794680,794728,794771,794778-794780,794892,795044,795104,795160,795583,795907,796022-796023,796352,796593,796741,796780,796994-796997,797117,797159,797192,797194,797231-797233,797442,797505,797517,797534,797581-797583,797587,797640,797651,797699,797882-797883,798344-798346,798363,798461,798479,798533,798551,798557,798561-798562,798570,798573,79858
4,798654,798748-798749,798891,798929-798930,799267
+/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305,787323,787366,787849,788030,788060,788187,788444,788451,788703,788752,788774,788819-788820,789013,789371,789387,789420,789527-789530,789704-789705,789788,789811,789896-789901,790074,790094,790134,790188,790294,790553,790637-790644,790868,791301,791354,791538,791753,791947,792007,792096,792183,792261-792265,792271,792604,792683-792685,792975,792985,793059,793570,794297,794396,794680,794728,794771,794778-794780,794892,795044,795104,795160,795583,795907,796022-796023,796352,796593,796741,796780,796994-796997,797117,797159,797192,797194,797231-797233,797442,797505,797517,797534,797581-797583,797587,797640,797651,797699,797882-797883,798344-798346,798363,798461,798479,798533,798551,798557,798561-798562,798570,798573,79858
4,798654,798748-798749,798891,798929-798930,799267,799439
Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/MustUnderstandInterceptor.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/MustUnderstandInterceptor.java?rev=799444&r1=799443&r2=799444&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/MustUnderstandInterceptor.java
(original)
+++
cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/MustUnderstandInterceptor.java
Thu Jul 30 21:20:38 2009
@@ -20,7 +20,10 @@
package org.apache.cxf.binding.soap.interceptor;
import java.net.URI;
+import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.ResourceBundle;
import java.util.Set;
@@ -37,6 +40,7 @@
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.headers.Header;
+import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.interceptor.Interceptor;
import org.apache.cxf.phase.Phase;
@@ -63,22 +67,62 @@
Set<Header> ultimateReceiverHeaders = new HashSet<Header>();
Set<QName> mustUnderstandQNames = new HashSet<QName>();
+ initServiceSideInfo(mustUnderstandQNames, soapMessage, serviceRoles);
buildMustUnderstandHeaders(mustUnderstandHeaders, soapMessage,
serviceRoles, ultimateReceiverHeaders);
- initServiceSideInfo(mustUnderstandQNames, soapMessage, serviceRoles);
- checkUnderstand(mustUnderstandHeaders, mustUnderstandQNames,
- notUnderstandHeaders);
+ checkUnderstand(mustUnderstandHeaders, mustUnderstandQNames,
notUnderstandHeaders);
+
if (!notUnderstandHeaders.isEmpty()) {
throw new SoapFault(new Message("MUST_UNDERSTAND", BUNDLE,
notUnderstandHeaders),
soapVersion.getMustUnderstand());
}
if (!ultimateReceiverHeaders.isEmpty() && !isRequestor(soapMessage)) {
- soapMessage.getInterceptorChain()
- .add(new
UltimateReceiverMustUnderstandInterceptor(mustUnderstandQNames));
+ checkUltimateReceiverHeaders(ultimateReceiverHeaders,
mustUnderstandQNames, soapMessage);
}
}
+ private void checkUltimateReceiverHeaders(Set<Header>
ultimateReceiverHeaders,
+ Set<QName> mustUnderstandQNames,
+ SoapMessage soapMessage) {
+ soapMessage.getInterceptorChain()
+ .add(new
UltimateReceiverMustUnderstandInterceptor(mustUnderstandQNames));
+ Object o =
soapMessage.getContextualProperty("endpoint.handles.headers");
+ if (o == null) {
+ //The default here really should be to make o = "" and process
+ //so any mustUnderstands are kill immediately. That will break
+ //existing apps though. Thus, it's a migration issue.
+ return;
+ }
+ Collection<Object> o2;
+ if (o instanceof Collection) {
+ o2 = CastUtils.cast((Collection<?>)o);
+ } else {
+ o2 = Collections.singleton(o);
+ }
+ for (Object obj : o2) {
+ QName qn;
+ if (obj instanceof QName) {
+ qn = (QName)obj;
+ } else {
+ qn = QName.valueOf((String)obj);
+ }
+ Iterator<Header> hit = ultimateReceiverHeaders.iterator();
+ while (hit.hasNext()) {
+ if (qn.equals(hit.next().getName())) {
+ hit.remove();
+ }
+ }
+ }
+ if (!ultimateReceiverHeaders.isEmpty()) {
+ Set<QName> notFound = new HashSet<QName>();
+ for (Header h : ultimateReceiverHeaders) {
+ notFound.add(h.getName());
+ }
+ throw new SoapFault(new Message("MUST_UNDERSTAND", BUNDLE,
notFound),
+ soapMessage.getVersion().getMustUnderstand());
+ }
+ }
private void initServiceSideInfo(Set<QName> mustUnderstandQNames,
SoapMessage soapMessage,
Set<URI> serviceRoles) {
Modified:
cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHeaderTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHeaderTest.java?rev=799444&r1=799443&r2=799444&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHeaderTest.java
(original)
+++
cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/outofband/header/OOBHeaderTest.java
Thu Jul 30 21:20:38 2009
@@ -34,6 +34,8 @@
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Holder;
+import javax.xml.ws.soap.SOAPFaultException;
+
import org.w3c.dom.Node;
import org.apache.cxf.BusFactory;
@@ -79,7 +81,7 @@
assertTrue("server did not launch correctly",
launchServer(Server.class, true));
}
- private void addOutOfBoundHeader(PutLastTradedPricePortType portType,
boolean invalid) {
+ private void addOutOfBoundHeader(PutLastTradedPricePortType portType,
boolean invalid, boolean mu) {
InvocationHandler handler = Proxy.getInvocationHandler(portType);
BindingProvider bp = null;
@@ -97,7 +99,7 @@
new QName(TEST_HDR_NS, TEST_HDR_REQUEST_ELEM),
ob,
new JAXBDataBinding(ob.getClass()));
- hdr.setMustUnderstand(true);
+ hdr.setMustUnderstand(mu);
List<Header> holder = new ArrayList<Header>();
holder.add(hdr);
@@ -180,18 +182,52 @@
TradePriceData priceData = new TradePriceData();
priceData.setTickerPrice(1.0f);
priceData.setTickerSymbol("CELTIX");
- Holder<TradePriceData> holder = new Holder<TradePriceData>(priceData);
-
- addOutOfBoundHeader(putLastTradedPrice, false);
- putLastTradedPrice.sayHi(holder);
- checkReturnedOOBHeader(putLastTradedPrice);
+
+ assertTrue(check(0, putLastTradedPrice, false, true, priceData));
+ assertFalse(check(1, putLastTradedPrice, false, true, priceData));
+ assertTrue(check(2, putLastTradedPrice, false, true, priceData));
+
+ assertFalse(check(0, putLastTradedPrice, true, true, priceData));
+ assertFalse(check(1, putLastTradedPrice, true, true, priceData));
+ assertFalse(check(2, putLastTradedPrice, true, true, priceData));
+
+ assertTrue(check(0, putLastTradedPrice, false, false, priceData));
+ assertTrue(check(1, putLastTradedPrice, false, false, priceData));
+ assertTrue(check(2, putLastTradedPrice, false, false, priceData));
+
+ assertTrue(check(0, putLastTradedPrice, true, false, priceData));
+ assertTrue(check(1, putLastTradedPrice, true, false, priceData));
+ assertTrue(check(2, putLastTradedPrice, true, false, priceData));
+ }
+
+ private boolean check(int i, PutLastTradedPricePortType
putLastTradedPrice,
+ boolean invalid, boolean mu,
+ TradePriceData priceData) {
+ String address = "";
+ switch (i) {
+ case 0:
+ address = "http://localhost:9107/SOAPDocLitBareService/SoapPort";
+ break;
+ case 1:
+ address =
"http://localhost:9107/SOAPDocLitBareService/SoapPortNoHeader";
+ break;
+ default:
+ address =
"http://localhost:9107/SOAPDocLitBareService/SoapPortHeader";
+ }
+ ((BindingProvider)putLastTradedPrice).getRequestContext()
+ .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
- addOutOfBoundHeader(putLastTradedPrice, true);
+ Holder<TradePriceData> holder = new Holder<TradePriceData>(priceData);
try {
+ addOutOfBoundHeader(putLastTradedPrice, invalid, mu);
putLastTradedPrice.sayHi(holder);
- fail("mustUnderstand header should not have been processed");
- } catch (Exception ex) {
- assertTrue(ex.getMessage(),
ex.getMessage().contains("MustUnderstand"));
+ checkReturnedOOBHeader(putLastTradedPrice);
+ return true;
+ } catch (SOAPFaultException ex) {
+ if (ex.getMessage().contains("MustUnderstand")) {
+ return false;
+ }
+ throw ex;
}
}
}
Modified:
cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/outofband/header/Server.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/outofband/header/Server.java?rev=799444&r1=799443&r2=799444&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/outofband/header/Server.java
(original)
+++
cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/outofband/header/Server.java
Thu Jul 30 21:20:38 2009
@@ -49,14 +49,32 @@
// Register expected Headers (namespace, element and class type
mapping)
Object implementor = new OOBHdrServiceImpl();
- String address =
"http://localhost:9107/SOAPDocLitBareService/SoapPort";
Endpoint ep = Endpoint.create(implementor);
Map<String, Object> props = new HashMap<String, Object>(2);
props.put(Endpoint.WSDL_SERVICE, new
QName("http://apache.org/hello_world_doc_lit_bare",
"SOAPService"));
props.put(Endpoint.WSDL_PORT, new
QName("http://apache.org/hello_world_doc_lit_bare", "SoapPort"));
ep.setProperties(props);
- ep.publish(address);
+ ep.publish("http://localhost:9107/SOAPDocLitBareService/SoapPort");
+
+ ep = Endpoint.create(implementor);
+ props = new HashMap<String, Object>(2);
+ props.put(Endpoint.WSDL_SERVICE, new
QName("http://apache.org/hello_world_doc_lit_bare",
+ "SOAPService"));
+ props.put(Endpoint.WSDL_PORT, new
QName("http://apache.org/hello_world_doc_lit_bare", "SoapPort"));
+ props.put("endpoint.handles.headers", "");
+ ep.setProperties(props);
+
ep.publish("http://localhost:9107/SOAPDocLitBareService/SoapPortNoHeader");
+
+ ep = Endpoint.create(implementor);
+ props = new HashMap<String, Object>(2);
+ props.put(Endpoint.WSDL_SERVICE, new
QName("http://apache.org/hello_world_doc_lit_bare",
+ "SOAPService"));
+ props.put(Endpoint.WSDL_PORT, new
QName("http://apache.org/hello_world_doc_lit_bare", "SoapPort"));
+ props.put("endpoint.handles.headers",
"{http://cxf.apache.org/outofband/Header}outofbandHeader");
+ ep.setProperties(props);
+
ep.publish("http://localhost:9107/SOAPDocLitBareService/SoapPortHeader");
+
}