[xgws-dev] CVS Update: codes/xsul/java/tests/xsul/ws_addressing
Aleksander Andrzej Slominski
xgws-dev_at_extreme.indiana.edu
Sat Apr 29 23:23:02 2006
aslom 06/04/29 23:22:04
Modified: xsul/java/doc changes.html
xsul/java/modules/common/xsul XsulVersion.java
xsul/java/modules/ws_addressing/xsul/ws_addressing
WsAddressing.java WsaEndpointReference.java
WsaInvoker.java WsaMessageInformationHeaders.java
WsaRelatesTo.java
xsul/java/modules/ws_addressing_converter/xsul/ws_addressing
NamespaceConverter.java WsaConverter.java
xsul/java/modules/xhandler_wsa_convert/xsul/xhandler_wsa_convert
ClientWsaConversionHandler.java
ServerWsaConversionHandler.java
xsul/java/modules/xwsif_dynamic_invoker/xsul/dii
XsulDynamicInvoker.java
xsul/java/tests/xsul/msg_box TestMsgBox.java
xsul/java/tests/xsul/util TestUtil.java
xsul/java/tests/xsul/ws_addressing
TestEndpointReference.java TestWsaConversion.java
TestWsaOperations.java
Log:
improved WSA 1.0 support - more unit tests (detals in doc/changes)
Revision Changes Path
1.44 +14 -6 codes/xsul/java/doc/changes.html
Index: changes.html
===================================================================
RCS file: /l/extreme/cvs/codes/xsul/java/doc/changes.html,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -t -w -r1.43 -r1.44
--- changes.html 19 Apr 2006 17:38:14 -0000 1.43
+++ changes.html 30 Apr 2006 03:22:02 -0000 1.44
@@ -14,18 +14,26 @@
<ul>
-<li>2006-04-19: modules/xhandler_wsa_convert
-WsAddressingConverterHandler
+<li>2006-04-29: updated and tested support for WS-Addressing 1.0
+(basics work but mre testing required in future)
+For backward compatibility WsaEndpointReference and WsaMessageInformationHeaders allows
+to specufy WSA namespace to use when constructing WSA content.
</li>
-<li>2006-04-19: modules/xhandler_drop_repeated_wsa_msg
-DropDuplicateMessageHandler
+<li>2006-04-29: modules/ws_adressing_detect_duplicates
+WsaDetectDuplicateMessageId.seenMessageId() unit tested with TestDetectMessageIdDuplicates
+</li>
+
+<li>2006-04-29: modules/ws_adressing_detect_duplicates
+WsaConverter.convert() unit tested with TestWsaConversion
</li>
-<li>2006-04-19: modules/ws_adressing_detect_duplicates
+<li>2006-04-19: modules/xhandler_wsa_convert
+WsAddressingConverterHandler
</li>
-<li>2006-04-19: modules/
+<li>2006-04-19: modules/xhandler_drop_repeated_wsa_msg
+DropDuplicateMessageHandler
</li>
<li>2006-04-18: modules/xwsif_provider_xsul_soap_gsi
1.71 +6 -6 codes/xsul/java/modules/common/xsul/XsulVersion.java
Index: XsulVersion.java
===================================================================
RCS file: /l/extreme/cvs/codes/xsul/java/modules/common/xsul/XsulVersion.java,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -b -t -w -r1.70 -r1.71
--- XsulVersion.java 21 Apr 2006 20:05:31 -0000 1.70
+++ XsulVersion.java 30 Apr 2006 03:22:02 -0000 1.71
@@ -1,18 +1,18 @@
/* -*- mode: Java; c-basic-offset: 4; indent-tabs-mode: nil; -*- //------100-columns-wide------>|*/
-/* Copyright (c) 2002-2005 Extreme! Lab, Indiana University. All rights reserved.
+/* Copyright (c) 2002-2006 Extreme! Lab, Indiana University. All rights reserved.
* This software is open source. See the bottom of this file for the licence.
- * $Id: XsulVersion.java,v 1.70 2006/04/21 20:05:31 aslom Exp $ */
+ * $Id: XsulVersion.java,v 1.71 2006/04/30 03:22:02 aslom Exp $ */
package xsul;
/**
* One place to put version number.
*
- * @version $Revision: 1.70 $
+ * @version $Revision: 1.71 $
* @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
*/
public class XsulVersion {
- public final static String SPEC_VERSION = "2.5.2";
- private final static String BUILD = "-RC1"; //"_SPECIAL_EDITION";//"_b4";
+ public final static String SPEC_VERSION = "2.5.3";
+ private final static String BUILD = "_p1"; //"_SPECIAL_EDITION";//"_b4";
private final static String PROJECT_NAME = "XSUL";
public final static String IMPL_VERSION = SPEC_VERSION+BUILD;
@@ -173,7 +173,7 @@
/*
* Indiana University Extreme! Lab Software License, Version 1.2
*
- * Copyright (c) 2002-2005 The Trustees of Indiana University.
+ * Copyright (c) 2002-2006 The Trustees of Indiana University.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
1.13 +43 -19 codes/xsul/java/modules/ws_addressing/xsul/ws_addressing/WsAddressing.java
Index: WsAddressing.java
===================================================================
RCS file: /l/extreme/cvs/codes/xsul/java/modules/ws_addressing/xsul/ws_addressing/WsAddressing.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -t -w -r1.12 -r1.13
--- WsAddressing.java 19 Apr 2006 17:38:14 -0000 1.12
+++ WsAddressing.java 30 Apr 2006 03:22:03 -0000 1.13
@@ -4,7 +4,7 @@
*
* This software is open source. See the bottom of this file for the licence.
*
- * $Id: WsAddressing.java,v 1.12 2006/04/19 17:38:14 aslom Exp $
+ * $Id: WsAddressing.java,v 1.13 2006/04/30 03:22:03 aslom Exp $
*/
package xsul.ws_addressing;
@@ -20,42 +20,44 @@
* <a href="http://www-106.ibm.com/developerworks/webservices/library/ws-add/">WS-Addressing</a>
* and this class contains some shared constants.
*
- * @version $Revision: 1.12 $
+ * @version $Revision: 1.13 $
* @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
*/
public class WsAddressing {
private final static XmlInfosetBuilder builder = XmlConstants.BUILDER;
// "final" WSA 1.0 version from http://www.w3.org/2002/ws/addr/
+ // http://www.w3.org/TR/2006/PR-ws-addr-soap-20060321/
public final static XmlNamespace NS_2005 = builder.newNamespace(
- "wa", "http://www.w3.org/2005/08/addressing");
- public final static XmlNamespace NS_WSA_10 = NS_2005;
+ "wsa", "http://www.w3.org/2005/08/addressing");
+ public final static XmlNamespace NS_WSA = NS_2005; // final and default version of WS-Addtressing
+ public final static XmlNamespace NS_WSA_1_0 = NS_WSA;
+
+ public final static XmlNamespace NS_WSDL_WSA = builder.newNamespace(
+ "wsaw", "http://www.w3.org/2005/03/addressing/wsdl");
+
+ //SPEC: http://www.w3.org/Submission/ws-addressing/
public final static XmlNamespace NS_2004_08 = builder.newNamespace(
"wa48", "http://schemas.xmlsoap.org/ws/2004/08/addressing");
public final static XmlNamespace NS_2004_03 = builder.newNamespace(
"wa43", "http://schemas.xmlsoap.org/ws/2004/03/addressing");
//"wsa4", "http://schemas.xmlsoap.org/ws/2004/03/addressing");
//"wsa", "http://schemas.xmlsoap.org/ws/2003/03/addressing");
- public final static XmlNamespace POLICY_NS = builder.newNamespace(
- "wsp", "http://schemas.xmlsoap.org/ws/2002/12/policy");
-
- public final static URI URI_UNSPECIFIED_MESSAGE_ID = URI.create(
- "http://schemas.xmlsoap.org/ws/2004/08/addressing/id/unspecified");
- //http://www.w3.org/2005/08/addressing/anonymous
+ public final static XmlNamespace POLICY_NS_2002_12 = builder.newNamespace(
+ "wsp", "http://schemas.xmlsoap.org/ws/2002/12/policy");
public final static URI URI_ROLE_NONE = URI.create(
"http://www.w3.org/2005/08/addressing/none");
+
public final static URI URI_ROLE_ANONYMOUS = URI.create(
"http://www.w3.org/2005/08/addressing/anonymous");
- //"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous");
- //"http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous");
- //"http://schemas.xmlsoap.org/ws/2003/03/addressing/role/anonymous");
- //public final static URI ROLE_ANONYMOUS_URI =
- // URI.create(WsAddressing.ROLE_ANONYMOUS_NS.getNamespaceName());
- //public final static XmlNamespace FAULT_ACTION_NS = builder.newNamespace(
- // "http://schemas.xmlsoap.org/ws/2003/03/addressing/fault");
+ public final static URI URI_ROLE_ANONYMOUS_2004_08 = URI.create(
+ "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous");
+ public final static URI URI_ROLE_ANONYMOUS_2004_03 = URI.create(
+ "http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous");
+ //"http://schemas.xmlsoap.org/ws/2003/03/addressing/role/anonymous");
public final static URI URI_ACTION_FAULT_2004 = URI.create(
"http://schemas.xmlsoap.org/ws/2004/08/addressing/fault");
@@ -64,6 +66,11 @@
public final static URI URI_ACTION_FAULT_2005 = URI.create(
"http://www.w3.org/2005/08/addressing/fault"); // Web Services Addressing 1.0 fault
+ public final static URI URI_ACTION_FAULT= URI_ACTION_FAULT_2005;
+
+ public final static URI URI_ACTION_SOAP_FAULT = URI.create(
+ "http://www.w3.org/2005/08/addressing/soap/fault"); // Web Services Addressing 1.0 fault
+
// private final static QName RESPONSE_REPLY_RELATIONSHIP_2004_03 = new QName(
// NS_2004_03.getNamespaceName(), "Reply");
private final static QName RESPONSE_REPLY_RELATIONSHIP_2004_08 = new QName(
@@ -72,11 +79,28 @@
private final static QName RESPONSE_REPLY_RELATIONSHIP_2005 = new QName(
NS_2005.getNamespaceName(), "Reply");
+ public final static QName FAULT_INVALID_ADRESS = createQName(NS_2005, "InvalidAddress");
+ public final static QName FAULT_INVALID_EPR = createQName(NS_2005, "InvalidEPR");
+ public final static QName FAULT_INVALID_CARDINALITY = createQName(NS_2005, "InvalidCardinality");
+ public final static QName FAULT_MISSING_ADDRESS_IN_EPR = createQName(NS_2005, "MissingAddressInEPR");
+ public final static QName FAULT_DUPLICATE_MESSAGE_ID = createQName(NS_2005, "DuplicateMessageID");
+ public final static QName FAULT_ACTION_MISMATCH = createQName(NS_2005, "ActionMismatch");
+ public final static QName FAULT_ONLY_ANON_ADDR_SUPPORTED = createQName(NS_2005, "OnlyAnonymousAddressSupported");
+ public final static QName FAULT_ONLY_NON_ANON_ADDR_SUPPORTED = createQName(NS_2005, "OnlyNonAnonymousAddressSupported");
+
+ public final static URI URI_UNSPECIFIED_MESSAGE_ID_2004_08 = URI.create(
+ "http://schemas.xmlsoap.org/ws/2004/08/addressing/id/unspecified");
+
+
//private static XmlNamespace defaultNs = NS_2004_08;
private static XmlNamespace defaultNs = NS_2005;
//private static QName defaultResponseReplyRel = RESPONSE_REPLY_RELATIONSHIP_2004_08;
private static QName defaultResponseReplyRel = RESPONSE_REPLY_RELATIONSHIP_2005;
+ private static QName createQName(XmlNamespace ns, String ncname) {
+ return new QName(ns.getNamespaceName(), ncname, ns.getPrefix());
+ }
+
public static XmlNamespace getDefaultNs() {
return defaultNs;
}
1.16 +82 -27 codes/xsul/java/modules/ws_addressing/xsul/ws_addressing/WsaEndpointReference.java
Index: WsaEndpointReference.java
===================================================================
RCS file: /l/extreme/cvs/codes/xsul/java/modules/ws_addressing/xsul/ws_addressing/WsaEndpointReference.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -t -w -r1.15 -r1.16
--- WsaEndpointReference.java 19 Apr 2006 17:38:14 -0000 1.15
+++ WsaEndpointReference.java 30 Apr 2006 03:22:03 -0000 1.16
@@ -4,7 +4,7 @@
*
* This software is open source. See the bottom of this file for the licence.
*
- * $Id: WsaEndpointReference.java,v 1.15 2006/04/19 17:38:14 aslom Exp $
+ * $Id: WsaEndpointReference.java,v 1.16 2006/04/30 03:22:03 aslom Exp $
*/
package xsul.ws_addressing;
@@ -23,27 +23,24 @@
import xsul.XmlConstants;
import xsul.util.XsulUtil;
-/*WsaEndpointReference extends WsaEndpointReferenceReadOnly {
+/* IDEA: WsaEndpointReference extends WsaEndpointReferenceReadOnly {
target.setReadOnly(false)
//pass through setReadOnly
}
*/
-
//<wsa:EndpointReference>
// <wsa:Address>xs:anyURI</wsa:Address>
-// <wsa:ReferenceProperties> ... </wsa:ReferenceProperties> ?
-// <wsa:PortType>xs:QName</wsa:PortType> ?
-// <wsa:ServiceName PortName="xs:NCName"?>xs:QName</wsa:ServiceName> ?
-// <wsp:Policy/> *
-//</wsa:EndpointReference>
+// <wsa:ReferenceParameters>xs:any*</wsa:ReferenceParameters> ?
+// <wsa:Metadata>xs:any*</wsa:Metadata>?
+//</wsa:EndpointReference>//</wsa:EndpointReference>
/**
* Implementation of
- * <a href="http://www-106.ibm.com/developerworks/webservices/library/ws-add/#informationmodelforendpointreferences">Endpoint Reference</a>
- * from Web Services Addressing (WS-Addressing)
+ * <a href="http://www.w3.org/TR/2006/PR-ws-addr-core-20060321/#eprs">Endpoint Reference</a>
+ * from Web Services Addressing 1.0 (WS-Addressing)
*
- * @version $Revision: 1.15 $
+ * @version $Revision: 1.16 $
* @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
*/
public class WsaEndpointReference extends XmlElementAdapter implements DataValidation
@@ -51,11 +48,13 @@
private final static MLogger logger = MLogger.getLogger();
private final static XmlInfosetBuilder builder = XmlConstants.BUILDER;
- //private final static XmlNamespace wa = WsAddressing.NS;
private XmlNamespace wa; // = WsAddressing.NS;
- private final static XmlNamespace wsp = WsAddressing.POLICY_NS;
+ private final static XmlNamespace wsp = WsAddressing.POLICY_NS_2002_12;
public final static String NAME = "EndpointReference";
+ private final static String ADDRESS_EL = "Address";
+ private final static String METADATA_EL = "Metadata";
+ private final static String REFERENCE_PARAMETERS_EL = "ReferenceParameters";
public WsaEndpointReference(URI address) {
this(WsAddressing.getDefaultNs(), address);
@@ -70,14 +69,35 @@
public WsaEndpointReference(XmlElement target) {
super(target);
- //this.wa = target.getNamespace(); //HACKish
- this.wa = WsAddressing.getDefaultNs();
+ XmlNamespace ns = null;
+ // XmlNamespace ns = target.getNamespace();
+ // if(! (ns.equals(WsAddressing.NS_2005)) //HACKish
+ // || (ns.equals(WsAddressing.NS_2004_08))
+ // || (ns.equals(WsAddressing.NS_2004_03)) ) {
+ // ns = null; //failed
+ // }
+ // if(ns == null) {
+ { // try to guess namespace based on presence of required "Address" element
+ XmlElement addressEl = element(null, ADDRESS_EL);
+ if(addressEl != null) {
+ ns = addressEl.getNamespace();
+ }
+ }
+ if(ns != null) {
+ this.wa = ns;
+ } else {
+ WsAddressing.getDefaultNs();
+ }
validateData();
}
+ public XmlNamespace getWsAddressingVersion() {
+ return wa;
+ }
+
//bloc requireChildrenModel
public URI getAddress() {
- XmlElement el = element(wa, "Address");
+ XmlElement el = element(wa, ADDRESS_EL);
if(el == null) {
return null;
}
@@ -93,34 +113,61 @@
}
public void setAddress(URI uri) {
- XmlElement el = element(wa, "Address", true);
+ XmlElement el = element(wa, ADDRESS_EL, true);
el.removeAllChildren();
el.addChild(uri.toString());
}
- public XmlElement getReferenceProperties() {
- return element(wa, "ReferenceProperties", true);
+
+ public XmlElement getReferenceParameters() {
+ return element(wa, REFERENCE_PARAMETERS_EL, true);
}
- public XmlElement getReferenceProperty(XmlNamespace ns, String name) {
+ public XmlElement getReferenceParametersFor(XmlNamespace ns, String name) {
return getReferenceProperties().element(ns, name);
}
- public XmlElement getReferenceParameters() {
- return element(wa, "ReferenceParameters", true);
+ public XmlElement getMetadata() {
+ return element(wa, METADATA_EL , true);
+ }
+
+ public XmlElement getMetadataFor(XmlNamespace ns, String name) {
+ return getMetadata().element(ns, name);
}
- public XmlElement getReferenceParameters(XmlNamespace ns, String name) {
+ // ------------------ OLD STUFF: to be removed soon! ----
+
+ /**
+ * No longer supoprted in WSA 1.0. *
+ * @deprecated
+ */
+ public XmlElement getReferenceProperties() {
+ return element(wa, "ReferenceProperties", true);
+ }
+
+ /**
+ * No longer supoprted in WSA 1.0. *
+ * @deprecated
+ */
+ public XmlElement getReferenceProperty(XmlNamespace ns, String name) {
return getReferenceProperties().element(ns, name);
}
// public List/*<XmlElement>*/ getPolicy() {
// return elements(wsp,"Policy");
// }
+ /**
+ * No longer supported in WSA 1.0. *
+ * @deprecated
+ */
public Iterable getPolicy() {
return elements(wsp, "Policy");
}
+ /**
+ * No longer supported in WSA 1.0. *
+ * @deprecated
+ */
public QName getPortType() {
XmlElement el = element(wa, "PortType");
if(el != null) {
@@ -130,6 +177,10 @@
}
}
+ /**
+ * No longer supported in WSA 1.0. *
+ * @deprecated
+ */
public QName getServiceName() {
// <wsa:ServiceName PortName="xs:NCName"?>xs:QName</wsa:ServiceName> ?
XmlElement el = element(wa,"ServiceName");
@@ -140,6 +191,10 @@
}
}
+ /**
+ * No longer supported in WSA 1.0. *
+ * @deprecated
+ */
public String getServicePortName() {
// <wsa:ServiceName PortName="xs:NCName"?>xs:QName</wsa:ServiceName> ?
XmlElement el = element(wa,"ServiceName");
@@ -157,13 +212,13 @@
throw new DataValidationException("wsa:Address is required in "+this);
}
// // selected portType one and it is QName!
- getPortType();
+ //getPortType();
// check only one PortType
// elements(wsa,"PortType").size() < 2
//service port max one
// elements(wsa,"ServiceName").size() < 2
- getServiceName();
- getServicePortName();
+ //getServiceName();
+ //getServicePortName();
}
public String toString() {
1.12 +24 -23 codes/xsul/java/modules/ws_addressing/xsul/ws_addressing/WsaInvoker.java
Index: WsaInvoker.java
===================================================================
RCS file: /l/extreme/cvs/codes/xsul/java/modules/ws_addressing/xsul/ws_addressing/WsaInvoker.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -t -w -r1.11 -r1.12
--- WsaInvoker.java 20 Feb 2006 08:35:40 -0000 1.11
+++ WsaInvoker.java 30 Apr 2006 03:22:03 -0000 1.12
@@ -4,7 +4,7 @@
*
* This software is open source. See the bottom of this file for the licence.
*
- * $Id: WsaInvoker.java,v 1.11 2006/02/20 08:35:40 aslom Exp $
+ * $Id: WsaInvoker.java,v 1.12 2006/04/30 03:22:03 aslom Exp $
*/
package xsul.ws_addressing;
@@ -19,6 +19,7 @@
import org.xmlpull.v1.builder.XmlDocument;
import org.xmlpull.v1.builder.XmlElement;
import org.xmlpull.v1.builder.XmlInfosetBuilder;
+import org.xmlpull.v1.builder.XmlNamespace;
import xsul.MLogger;
import xsul.XmlConstants;
import xsul.invoker.DynamicInfosetInvoker;
@@ -34,7 +35,7 @@
* will use WSA processing node to indicate where to send replies.
* <br />NOTE: this is class is not multi-thread safe and MUST be proected if used concurently!
*
- * @version $Revision: 1.11 $
+ * @version $Revision: 1.12 $
* @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
*/
public class WsaInvoker implements MessageInvoker
@@ -59,6 +60,7 @@
};
protected WsaEndpointReference targetEPR;
+ protected XmlNamespace targetWsa;
protected URI defaultAction;
protected URI messageId;
@@ -75,6 +77,14 @@
//setDefaultFroom(node.buildFromAddress())
}
+ public void setTargetWsa(XmlNamespace targetWsa) {
+ this.targetWsa = targetWsa;
+ }
+
+ public XmlNamespace getTargetWsa() {
+ return targetWsa;
+ }
+
public void setUseHttpKeepAlive(boolean useHttpKeepAlive) {
this.useHttpKeepAlive = useHttpKeepAlive;
if(invoker instanceof HttpDynamicInfosetInvoker) {
@@ -199,13 +209,12 @@
XmlDocument doc = wrapInSoapEnvelopeIfNecessary(message);
//System.err.println(getClass().getName()+" "+xsul.util.Util.safeXmlToString(doc.getDocumentElement()));
- WsaMessageInformationHeaders wmih = new WsaMessageInformationHeaders(doc);
+ WsaMessageInformationHeaders wmih = new WsaMessageInformationHeaders(targetWsa, doc);
if(targetEPR != null) {
// explode targetER into SOAP headers
wmih.explodeEndpointReference(targetEPR);
}
-
if(wmih.getMessageId() == null) {
if(messageId != null) {
wmih.setMessageId(messageId);
@@ -234,6 +243,17 @@
// }
}
+ //PROBLEM:required WSDL to create default wsa:Action as defined in 3.3.2 Default Action Pattern
+ // [target namespace]/[port type name]/[input|output name]
+ //String wsaAction = "";
+ // extract wsa:Action and use as SoapAction
+ if(wmih.getAction() == null) {
+ if(defaultAction== null) {
+ throw new DynamicInfosetInvokerException("WS-Addressing action is required");
+ }
+ wmih.setAction(defaultAction);
+ }
+
XmlDocument responseDoc = sendXml(doc);
if(responseDoc != null) {
@@ -353,16 +373,6 @@
//wmih.setTo()
throw new DynamicInfosetInvokerException("WS-Addressing destination is required");
}
- //PROBLEM:required WSDL to create default wsa:Action as defined in 3.3.2 Default Action Pattern
- // [target namespace]/[port type name]/[input|output name]
- //String wsaAction = "";
- // extract wsa:Action and use as SoapAction
- if(wmih.getAction() == null) {
- if(defaultAction== null) {
- throw new DynamicInfosetInvokerException("WS-Addressing action is required");
- }
- wmih.setAction(defaultAction);
- }
DynamicInfosetInvoker xmlInvoker = lookupInvokerForDestination(wmih);
if(xmlInvoker == null) {
throw new DynamicInfosetInvokerException(
@@ -375,15 +385,6 @@
}
-/*
- <wsa:RelatesTo RelationshipType="..."?>xs:anyURI</wsa:RelatesTo>
- <wsa:To>xs:anyURI</wsa:To>
- <wsa:Action>xs:anyURI</wsa:Action>
- <wsa:From>endpoint-reference</wsa:From>
- <wsa:ReplyTo>endpoint-reference</wsa:ReplyTo>
- <wsa:FaultTo>endpoint-reference</wsa:FaultTo>
- <wsa:Recipient>endpoint-reference</wsa:Recipient>
- */
/*
1.15 +51 -21 codes/xsul/java/modules/ws_addressing/xsul/ws_addressing/WsaMessageInformationHeaders.java
Index: WsaMessageInformationHeaders.java
===================================================================
RCS file: /l/extreme/cvs/codes/xsul/java/modules/ws_addressing/xsul/ws_addressing/WsaMessageInformationHeaders.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -t -w -r1.14 -r1.15
--- WsaMessageInformationHeaders.java 6 Dec 2005 00:56:35 -0000 1.14
+++ WsaMessageInformationHeaders.java 30 Apr 2006 03:22:03 -0000 1.15
@@ -4,7 +4,7 @@
*
* This software is open source. See the bottom of this file for the licence.
*
- * $Id: WsaMessageInformationHeaders.java,v 1.14 2005/12/06 00:56:35 aslom Exp $
+ * $Id: WsaMessageInformationHeaders.java,v 1.15 2006/04/30 03:22:03 aslom Exp $
*/
package xsul.ws_addressing;
@@ -28,13 +28,14 @@
//Good article about chnages 2003->2004
//http://msdn.microsoft.com/webservices/default.aspx?pull=/library/en-us/dnwebsrv/html/wsaddressdelta.asp
-//<wsa:To>xs:anyURI</wsa:To>
+//<wsa:To>xs:anyURI</wsa:To> ? (changed ot optional in 1.0)
//<wsa:Action>xs:anyURI</wsa:Action>
-//<wsa:MessageID>xs:anyURI</wsa:MessageID>?
-//<wsa:RelatesTo RelationshipType="..."?>xs:anyURI</wsa:RelatesTo>*
//<wsa:From>endpoint-reference</wsa:From>?
//<wsa:ReplyTo>endpoint-reference</wsa:ReplyTo>?
//<wsa:FaultTo>endpoint-reference</wsa:FaultTo>?
+//<wsa:MessageID>xs:anyURI</wsa:MessageID>?
+//<wsa:RelatesTo RelationshipType="xs:anyURI"?>xs:anyURI</wsa:RelatesTo> *
+//<xs:any* wsa:IsReferenceParameter='true'>*</a> from each element child of <wsa:ReferenceParameters>xs:any*</wsa:ReferenceParameters> ?
//REMOVED in 2004: <wsa:Recipient>endpoint-reference</wsa:Recipient>?
/**
@@ -42,7 +43,7 @@
* <a href="http://www-106.ibm.com/developerworks/webservices/library/ws-add/#informationmodelforendpointreferences">Endpoint Reference</a>
* from Web Services Addressing 2004 (WS-Addressing)
*
- * @version $Revision: 1.14 $
+ * @version $Revision: 1.15 $
* @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
*/
public class WsaMessageInformationHeaders implements DataValidation, XmlSerializable
@@ -52,12 +53,18 @@
private final static MLogger logger = MLogger.getLogger();
private final static XmlInfosetBuilder builder = XmlConstants.BUILDER;
- private final static XmlNamespace wsa = WsAddressing.getDefaultNs();
- private final static XmlNamespace wsp = WsAddressing.POLICY_NS;
+ //private final static XmlNamespace wsa = WsAddressing.getDefaultNs();
+ private final static XmlNamespace wsp = WsAddressing.POLICY_NS_2002_12;
private XmlElement soapHeaderElement;
+ private boolean standardWsa;
+ private XmlNamespace wsa;
public WsaMessageInformationHeaders(XmlElement soapHeadersOrEnvelope) {
+ this(null, soapHeadersOrEnvelope);
+ }
+
+ public WsaMessageInformationHeaders(XmlNamespace targetWsa, XmlElement soapHeadersOrEnvelope) {
if(soapHeadersOrEnvelope == null) throw new IllegalArgumentException();
String name = soapHeadersOrEnvelope.getName();
XmlElement soapHeaders;
@@ -77,7 +84,22 @@
throw new XsulException("expected Header element to reference WS-Addressing Headers not "+name);
}
this.soapHeaderElement = soapHeaders;
- //attach WSA_NS is possible
+
+ if(targetWsa != null) {
+ wsa = targetWsa;
+ } else {
+ // try to guess namespace based on presence of required "Action" element (required header in WSA)
+ XmlElement addressEl = soapHeaders.element(null, ACTION_EL);
+ if(addressEl != null) {
+ wsa = addressEl.getNamespace();
+ } else {
+ wsa = WsAddressing.getDefaultNs();
+
+ }
+ }
+ assert this.wsa != null;
+ standardWsa = wsa.equals(WsAddressing.NS_WSA);
+ //attach WS-Addressing namespace declaration to Envelope or Header if possible
if(soapHeaderElement.getParent() instanceof XmlElement) {
soapHeadersOrEnvelope = (XmlElement) soapHeaderElement.getParent();
}
@@ -94,6 +116,10 @@
//validateData();
}
+ public WsaMessageInformationHeaders(XmlNamespace targetWsa, XmlDocument doc) {
+ this(targetWsa, doc.getDocumentElement());
+ }
+
public WsaMessageInformationHeaders(XmlDocument doc) {
this(doc.getDocumentElement());
}
@@ -301,26 +327,30 @@
//bind destination
setTo(epr.getAddress());
- //copy reference properties as headers
- {
- XmlElement refProps = epr.getReferenceProperties();
- explodeChildren(refProps);
- }
{
XmlElement refParams = epr.getReferenceParameters();
- explodeChildren(refParams);
+ explodeChildren(refParams, standardWsa);
+ }
+ //copy reference properties as headers for pre-WSA 1.0
+ if(!standardWsa) {
+ XmlElement refProps = epr.getReferenceProperties();
+ explodeChildren(refProps, standardWsa);
}
}
- private void explodeChildren(XmlElement refProps) throws XsulException {
- for(Iterator i = refProps.requiredElementContent().iterator(); i.hasNext(); ) { //JDK15
- XmlElement prop = (XmlElement) i.next();
+ private void explodeChildren(XmlElement refParams, boolean addFlag) throws XsulException {
+ for(Iterator i = refParams.requiredElementContent().iterator(); i.hasNext(); ) { //JDK15
+ XmlElement param = (XmlElement) i.next();
try {
- //TODO: check if in-scope namespaces are cloned
- XmlElement propClone = (XmlElement) prop.clone();
+ //TODO: should check if in-scope namespaces are cloned?
+ XmlElement propClone = (XmlElement) param.clone();
+ if(addFlag) {
+ //wsa:IsReferenceParameter='true'
+ propClone.addAttribute(WsAddressing.NS_WSA, "IsReferenceParameter", "true");
+ }
soapHeaderElement.addElement(propClone);
} catch (CloneNotSupportedException e) {
- throw new XsulException("could not clone property:"+prop);
+ throw new XsulException("could not clone property:"+param);
}
}
}
1.8 +3 -3 codes/xsul/java/modules/ws_addressing/xsul/ws_addressing/WsaRelatesTo.java
Index: WsaRelatesTo.java
===================================================================
RCS file: /l/extreme/cvs/codes/xsul/java/modules/ws_addressing/xsul/ws_addressing/WsaRelatesTo.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -t -w -r1.7 -r1.8
--- WsaRelatesTo.java 18 Apr 2006 18:03:47 -0000 1.7
+++ WsaRelatesTo.java 30 Apr 2006 03:22:03 -0000 1.8
@@ -4,7 +4,7 @@
*
* This software is open source. See the bottom of this file for the licence.
*
- * $Id: WsaRelatesTo.java,v 1.7 2006/04/18 18:03:47 aslom Exp $
+ * $Id: WsaRelatesTo.java,v 1.8 2006/04/30 03:22:03 aslom Exp $
*/
package xsul.ws_addressing;
@@ -40,7 +40,7 @@
* element
* from Web Services Addressing (WS-Addressing) used in WSA MessageHeaders
*
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
* @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
*/
public class WsaRelatesTo extends XmlElementAdapter implements DataValidation
@@ -49,7 +49,7 @@
private final static XmlInfosetBuilder builder = XmlConstants.BUILDER;
private final static XmlNamespace wsa = WsAddressing.getDefaultNs();
- private final static XmlNamespace wsp = WsAddressing.POLICY_NS;
+ private final static XmlNamespace wsp = WsAddressing.POLICY_NS_2002_12;
public WsaRelatesTo(URI relationship) {
super(builder.newFragment(wsa, "RelatesTo"));
1.2 +52 -47 codes/xsul/java/modules/ws_addressing_converter/xsul/ws_addressing/NamespaceConverter.java
Index: NamespaceConverter.java
===================================================================
RCS file: /l/extreme/cvs/codes/xsul/java/modules/ws_addressing_converter/xsul/ws_addressing/NamespaceConverter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -t -w -r1.1 -r1.2
--- NamespaceConverter.java 19 Apr 2006 15:04:36 -0000 1.1
+++ NamespaceConverter.java 30 Apr 2006 03:22:03 -0000 1.2
@@ -1,7 +1,7 @@
/* -*- mode: Java; c-basic-offset: 4; indent-tabs-mode: nil; -*- //------100-columns-wide------>|*/
/* Copyright (c) 2006 Extreme! Lab, Indiana University. All rights reserved.
* This software is open source. See the bottom of this file for the licence.
- * $Id: NamespaceConverter.java,v 1.1 2006/04/19 15:04:36 aslom Exp $ */
+ * $Id: NamespaceConverter.java,v 1.2 2006/04/30 03:22:03 aslom Exp $ */
package xsul.ws_addressing;
@@ -16,57 +16,44 @@
import xsul.XsulException;
/**
- * Convert namespaace declarations and preserve prefixes.
+ * Convert namespace declarations and preserve prefixes to maintain QName mappings.
*
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
* @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
*/
public class NamespaceConverter {
private final static XmlInfosetBuilder builder = XmlConstants.BUILDER;
- private String[] sourceNamespaces;
- private XmlNamespace targetNamespace;
- private XmlNamespace firstConvertedNamespace;
+ protected String[] sourceNamespaces;
+ protected XmlNamespace targetNamespace;
+ protected XmlNamespace firstConvertedNamespace;
public NamespaceConverter(String[] sourceNamespaces, XmlNamespace targetNamespace) {
this.sourceNamespaces = sourceNamespaces;
this.targetNamespace = targetNamespace;
}
- private XmlNamespace shouldConvert(XmlNamespace elNs) {
- String targetUri = targetNamespace.getNamespaceName();
- String elUri = elNs.getNamespaceName();
- for (int i = 0; i < sourceNamespaces.length; i++){
- String recUri = sourceNamespaces[i];
- if(elUri.equals(recUri)){
- if(elUri.equals(targetUri)) {
- return null;
- } else {
- // found -- now need ot make sur eprefix is preserved
- String targetPrefix = targetNamespace.getPrefix();
- String elPrefix = elNs.getPrefix();
- if(targetPrefix.equals(elPrefix)) {
- return targetNamespace;
- } else {
- if(elPrefix != null) {
- return builder.newNamespace(elPrefix, targetUri);
- } else {
- return builder.newNamespace(targetUri); //CHECKME
- }
- }
+ public XmlNamespace convertElement(XmlElement el) {
+ firstConvertedNamespace = null;
+ convertTree(el);
+ return firstConvertedNamespace;
}
+
+ protected void convertTree(XmlElement el) {
+
+ convertElementWithoutChildren(el);
+
+ if(el.hasChildren()) { // walk tree revursively
+ for(Iterator i = el.children(); i.hasNext(); ) {
+ Object child = i.next();
+ if(child instanceof XmlElement) {
+ convertTree((XmlElement) child);
}
}
- return null;
}
- public XmlNamespace convert(XmlElement el) {
- firstConvertedNamespace = null;
- convertTree(el);
- return firstConvertedNamespace;
}
- private void convertTree(XmlElement el) {
-
+ protected void convertElementWithoutChildren(XmlElement el) {
convertElementNamespace(el);
if(el.hasNamespaceDeclarations()) {
@@ -76,19 +63,9 @@
if(el.hasAttributes()) {
convertAttributeNamespaces(el);
}
-
- if(el.hasChildren()) { // walk tree revursively
- for(Iterator i = el.children(); i.hasNext(); ) {
- Object child = i.next();
- if(child instanceof XmlElement) {
- convertTree(el);
- }
- }
- }
-
}
- private void convertAttributeNamespaces(XmlElement el) {
+ protected void convertAttributeNamespaces(XmlElement el) {
// not exactly supper efficient ...
List attributesToChange = new ArrayList();
for(Iterator i = el.attributes(); i.hasNext(); ) {
@@ -110,7 +87,7 @@
}
}
- private void convertNamespaceDeclarations(XmlElement el) {
+ protected void convertNamespaceDeclarations(XmlElement el) {
// not exactly supper efficient
List nsToAdd = new ArrayList();
List nsToPreserve = new ArrayList();
@@ -137,7 +114,7 @@
}
}
- private void convertElementNamespace(XmlElement el) {
+ protected void convertElementNamespace(XmlElement el) {
XmlNamespace elNs = el.getNamespace();
XmlNamespace n = shouldConvert(elNs);
if(n != null) {
@@ -147,6 +124,34 @@
}
}
}
+
+ protected XmlNamespace shouldConvert(XmlNamespace elNs) {
+ String targetUri = targetNamespace.getNamespaceName();
+ String elUri = elNs.getNamespaceName();
+ for (int i = 0; i < sourceNamespaces.length; i++){
+ String recUri = sourceNamespaces[i];
+ if(elUri.equals(recUri)){
+ if(elUri.equals(targetUri)) {
+ return null;
+ } else {
+ // found -- now need ot make sur eprefix is preserved
+ String targetPrefix = targetNamespace.getPrefix();
+ String elPrefix = elNs.getPrefix();
+ if(targetPrefix.equals(elPrefix)) {
+ return targetNamespace;
+ } else {
+ if(elPrefix != null) {
+ return builder.newNamespace(elPrefix, targetUri);
+ } else {
+ return builder.newNamespace(targetUri); //CHECKME
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
}
1.5 +21 -14 codes/xsul/java/modules/ws_addressing_converter/xsul/ws_addressing/WsaConverter.java
Index: WsaConverter.java
===================================================================
RCS file: /l/extreme/cvs/codes/xsul/java/modules/ws_addressing_converter/xsul/ws_addressing/WsaConverter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -t -w -r1.4 -r1.5
--- WsaConverter.java 21 Apr 2006 15:45:44 -0000 1.4
+++ WsaConverter.java 30 Apr 2006 03:22:03 -0000 1.5
@@ -1,14 +1,10 @@
/* -*- mode: Java; c-basic-offset: 4; indent-tabs-mode: nil; -*- //------100-columns-wide------>|*/
/* Copyright (c) 2006 Extreme! Lab, Indiana University. All rights reserved.
* This software is open source. See the bottom of this file for the licence.
- * $Id: WsaConverter.java,v 1.4 2006/04/21 15:45:44 aslom Exp $ */
+ * $Id: WsaConverter.java,v 1.5 2006/04/30 03:22:03 aslom Exp $ */
package xsul.ws_addressing;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.xmlpull.v1.builder.XmlAttribute;
import org.xmlpull.v1.builder.XmlElement;
import org.xmlpull.v1.builder.XmlInfosetBuilder;
import org.xmlpull.v1.builder.XmlNamespace;
@@ -18,13 +14,13 @@
/**
* Convert between version of WS-Addressing.
*
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
* @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
*/
-public class WsaConverter {
+public class WsaConverter extends NamespaceConverter {
private final static XmlInfosetBuilder builder = XmlConstants.BUILDER;
public final static XmlNamespace CONVERTER_EL_NS = builder.newNamespace(
- "http://www.extreme.indiana.edu/xgws/xsul/2006/", "xwsa");
+ "xwsa", "http://www.extreme.indiana.edu/xgws/xsul/2006/");
public final static String CONVERTER_EL_NAME = "message-wsa-namespace";
public final static String CONVERTER_PREFIX_ATTR = "prefix";
private final static String[] recognizedWsaNamespaces = new String[] {
@@ -33,6 +29,10 @@
WsAddressing.NS_2004_03.getNamespaceName(),
};
+ protected WsaConverter(String[] sourceNamespaces, XmlNamespace targetNamespace) {
+ super(sourceNamespaces, targetNamespace);
+ }
+
public static XmlNamespace getOldNamespaceFromContext(XmlElement context) {
if(context == null) {
return null;
@@ -64,19 +64,26 @@
el.addChild(targetNs.getNamespaceName());
}
- public static XmlNamespace convertTo(XmlElement soapEnvelopeOrHeader, XmlNamespace targetNamespace) {
+ public static XmlNamespace convert(XmlElement soapEnvelopeOrHeader) {
+ return convert(soapEnvelopeOrHeader, WsAddressing.NS_WSA);
+ }
+
+ public static XmlNamespace convert(XmlElement soapEnvelopeOrHeader, XmlNamespace targetNamespace) {
+ WsaConverter converter = new WsaConverter(recognizedWsaNamespaces, targetNamespace);
+ //XmlElement headers = (XmlElement) soapEnv.requiredElementContent().iterator().next();
if(soapEnvelopeOrHeader == null) throw new IllegalArgumentException();
XmlElement header = soapEnvelopeOrHeader;
- if(header.getName().equals("Envelope")) {
+ if(soapEnvelopeOrHeader.getName().equals("Envelope")) {
header = soapEnvelopeOrHeader.element(null, "Header");
- if(header == null) { // no SOAP::Header --> no way to detect duplicates
+ if(header == null) { // no SOAP::Header --> nothing to do ...
return null;
}
+ // convert namespace declarations in the envelope
+ converter.convertNamespaceDeclarations(soapEnvelopeOrHeader);
} else if(!header.getName().equals("Header")) {
throw new IllegalArgumentException("element passed must be SOAP Envelope or Header");
}
- NamespaceConverter converter = new NamespaceConverter(recognizedWsaNamespaces, targetNamespace);
- XmlNamespace origWsaNamespace = converter.convert(header);
+ XmlNamespace origWsaNamespace = converter.convertElement(header);
return origWsaNamespace;
}
}
1.2 +3 -3 codes/xsul/java/modules/xhandler_wsa_convert/xsul/xhandler_wsa_convert/ClientWsaConversionHandler.java
Index: ClientWsaConversionHandler.java
===================================================================
RCS file: /l/extreme/cvs/codes/xsul/java/modules/xhandler_wsa_convert/xsul/xhandler_wsa_convert/ClientWsaConversionHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -t -w -r1.1 -r1.2
--- ClientWsaConversionHandler.java 19 Apr 2006 17:37:28 -0000 1.1
+++ ClientWsaConversionHandler.java 30 Apr 2006 03:22:03 -0000 1.2
@@ -1,7 +1,7 @@
/* -*- mode: Java; c-basic-offset: 4; indent-tabs-mode: nil; -*- //------100-columns-wide------>|*/
/* Copyright (c) 2006 Extreme! Lab, Indiana University. All rights reserved.
* This software is open source. See the bottom of this file for the licence.
- * $Id: ClientWsaConversionHandler.java,v 1.1 2006/04/19 17:37:28 aslom Exp $ */
+ * $Id: ClientWsaConversionHandler.java,v 1.2 2006/04/30 03:22:03 aslom Exp $ */
package xsul.xhandler_wsa_convert;
@@ -22,7 +22,7 @@
* whatever WS-Addressing (WSA) version is passed in te handler constructor for outgoing messages and
* convert incoming messages from whatever WSA version to WSA 1.0.
*
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
* @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
*/
public class ClientWsaConversionHandler extends BaseHandler {
@@ -39,14 +39,14 @@
MessageContext context)
throws DynamicInfosetInvokerException
{
- WsaConverter.convertTo(soapEnvelope, targetWsaNamespace);
+ WsaConverter.convert(soapEnvelope, targetWsaNamespace);
return false; // false indicates that processing is not finoshed -- contunue
}
public boolean processOutgoingXml(XmlElement soapEnvelope, MessageContext context)
throws DynamicInfosetInvokerException
{
- WsaConverter.convertTo(soapEnvelope, WsAddressing.NS_WSA_10);
+ WsaConverter.convert(soapEnvelope, WsAddressing.NS_WSA_1_0);
return false; // false indicates that processing is not finoshed -- contunue
}
1.3 +4 -4 codes/xsul/java/modules/xhandler_wsa_convert/xsul/xhandler_wsa_convert/ServerWsaConversionHandler.java
Index: ServerWsaConversionHandler.java
===================================================================
RCS file: /l/extreme/cvs/codes/xsul/java/modules/xhandler_wsa_convert/xsul/xhandler_wsa_convert/ServerWsaConversionHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -t -w -r1.2 -r1.3
--- ServerWsaConversionHandler.java 19 Apr 2006 17:38:15 -0000 1.2
+++ ServerWsaConversionHandler.java 30 Apr 2006 03:22:03 -0000 1.3
@@ -1,7 +1,7 @@
/* -*- mode: Java; c-basic-offset: 4; indent-tabs-mode: nil; -*- //------100-columns-wide------>|*/
/* Copyright (c) 2006 Extreme! Lab, Indiana University. All rights reserved.
* This software is open source. See the bottom of this file for the licence.
- * $Id: ServerWsaConversionHandler.java,v 1.2 2006/04/19 17:38:15 aslom Exp $ */
+ * $Id: ServerWsaConversionHandler.java,v 1.3 2006/04/30 03:22:03 aslom Exp $ */
package xsul.xhandler_wsa_convert;
@@ -23,7 +23,7 @@
* to WSA 1.0, the original version is stored in context and used for outgoing
* message convert it from WSA 1.0 to that version.
*
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
* @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
*/
public class ServerWsaConversionHandler extends BaseHandler {
@@ -38,7 +38,7 @@
MessageContext context)
throws DynamicInfosetInvokerException
{
- XmlNamespace versionOfMessageWsaNs = WsaConverter.convertTo(soapEnvelope, WsAddressing.NS_WSA_10);
+ XmlNamespace versionOfMessageWsaNs = WsaConverter.convert(soapEnvelope, WsAddressing.NS_WSA_1_0);
if(versionOfMessageWsaNs != null) {
WsaConverter.setOldNamespaceInContext(context, versionOfMessageWsaNs);
}
@@ -48,7 +48,7 @@
public boolean processOutgoingXml(XmlElement soapEnvelope, MessageContext context) throws DynamicInfosetInvokerException {
XmlNamespace versionOfMessageWsaNs = WsaConverter.getOldNamespaceFromContext(context);
if(versionOfMessageWsaNs != null) {
- WsaConverter.convertTo(soapEnvelope, versionOfMessageWsaNs);
+ WsaConverter.convert(soapEnvelope, versionOfMessageWsaNs);
}
return false; // false indicates that processing is not finoshed -- contunue
}
1.4 +2 -2 codes/xsul/java/modules/xwsif_dynamic_invoker/xsul/dii/XsulDynamicInvoker.java
Index: XsulDynamicInvoker.java
===================================================================
RCS file: /l/extreme/cvs/codes/xsul/java/modules/xwsif_dynamic_invoker/xsul/dii/XsulDynamicInvoker.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -t -w -r1.3 -r1.4
--- XsulDynamicInvoker.java 20 Feb 2006 08:35:41 -0000 1.3
+++ XsulDynamicInvoker.java 30 Apr 2006 03:22:04 -0000 1.4
@@ -4,7 +4,7 @@
*
* This software is open source. See the bottom of this file for the licence.
*
- * $Id: XsulDynamicInvoker.java,v 1.3 2006/02/20 08:35:41 aslom Exp $
+ * $Id: XsulDynamicInvoker.java,v 1.4 2006/04/30 03:22:04 aslom Exp $
*/
package xsul.dii;
@@ -118,7 +118,7 @@
//System.out.println("invoking Google WS with query '"+query+"' using WSDL from "+wsdlLoc);
System.err.println("invoking operation '"+opName+"' using WSDL from "+wsdlLoc);
-
+ //MLogger.setCmdNames(":ALL");
WsdlDefinitions def = WsdlResolver.getInstance().loadWsdl(base, new URI(wsdlLoc));
WSIFServiceFactory wsf = WSIFServiceFactory.newInstance();
1.11 +3 -5 codes/xsul/java/tests/xsul/msg_box/TestMsgBox.java
Index: TestMsgBox.java
===================================================================
RCS file: /l/extreme/cvs/codes/xsul/java/tests/xsul/msg_box/TestMsgBox.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -t -w -r1.10 -r1.11
--- TestMsgBox.java 23 Jan 2005 10:09:56 -0000 1.10
+++ TestMsgBox.java 30 Apr 2006 03:22:04 -0000 1.11
@@ -4,7 +4,7 @@
*
* This software is open source. See the bottom of this file for the licence.
*
- * $Id: TestMsgBox.java,v 1.10 2005/01/23 10:09:56 aslom Exp $
+ * $Id: TestMsgBox.java,v 1.11 2006/04/30 03:22:04 aslom Exp $
*/
package xsul.msg_box;
@@ -30,7 +30,7 @@
/**
* Tests simple interaction with WS-MsgBox.
*
- * @version $Revision: 1.10 $
+ * @version $Revision: 1.11 $
* @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
*/
public class TestMsgBox extends XsulTestCase {
@@ -85,7 +85,7 @@
}
//wait for message to arrive to msg boox service
- Thread.currentThread().sleep(200L);
+ Thread.currentThread().sleep(500L);
{
// retrieve message(s) from mailbox
@@ -122,8 +122,6 @@
msgBoxServer.start();
messageBoxLocation = msgBoxServer.getLocation();
- //TypeHandlerRegistry registry = CommonTypeHandlerRegistry.getInstance();
-
//
// This is super generic echo service tah can support RPC, one-way messaging,
// and request-response with messaging and sending redirected response
1.6 +34 -2 codes/xsul/java/tests/xsul/util/TestUtil.java
Index: TestUtil.java
===================================================================
RCS file: /l/extreme/cvs/codes/xsul/java/tests/xsul/util/TestUtil.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -t -w -r1.5 -r1.6
--- TestUtil.java 18 Apr 2006 18:13:14 -0000 1.5
+++ TestUtil.java 30 Apr 2006 03:22:04 -0000 1.6
@@ -4,7 +4,7 @@
*
* This software is open source. See the bottom of this file for the licence.
*
- * $Id: TestUtil.java,v 1.5 2006/04/18 18:13:14 aslom Exp $
+ * $Id: TestUtil.java,v 1.6 2006/04/30 03:22:04 aslom Exp $
*/
package xsul.util;
@@ -22,7 +22,7 @@
/**
* Tests for utility methods shared by all clases in package.
*
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
* @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
*/
public class TestUtil extends XsulTestCase {
@@ -68,4 +68,36 @@
pp.next();
//System.out.println(getClasS()+" "+pp.getPositionDescription());
}
+
+ private final String XML = "<fileConsumed wor:topic=\"somerandomtopic\"\n"+
+ "xmlns=\"http://lead.extreme.indiana.edu/namespaces/2005/06/workflow_tracking\"\n"+
+ "xmlns:wor=\"http://lead.extreme.indiana.edu/namespaces/2005/06/workflow_tracking\">\n"+
+ " <workflowID>wf100201</workflowID>\n"+
+ " <nodeID>N1</nodeID>\n"+
+ " <wfTimeStep>1</wfTimeStep>\n"+
+ " <serviceID>{http://foobar.org}FuBar1</serviceID>\n"+
+ " <timestamp>2006-04-21T10:03:49.906+05:30</timestamp>\n"+
+ " <file>\n"+
+ " <fileUUID>leadId-001</fileUUID>\n"+
+ " <localFilePath>/6+data/tmp/foo.dat</localFilePath>\n"+
+ " <fileSizeBytes>0</fileSizeBytes>\n"+
+ " <timestamp>2006-04-21T10:03:49.921+05:30</timestamp>\n"+
+ " </file>\n"+
+ " <file>\n"+
+ " <fileUUID>leadId-002</fileUUID>\n"+
+ " <localFilePath>/etc/app/config/foo.cfg</localFilePath>\n"+
+ " <fileSizeBytes>0\n"+
+ "</fileSizeBytes>\n"+
+ " <timestamp>2006-04-21T10:03:49.921+05:30</timestamp>\n"+
+ " </file>\n"+
+ "</fileConsumed>\n";
+
+ public void testParsingRegression() throws Exception {
+ //System.err.println(getClass()+" before builder="+XML);
+ XmlElement messageEl = builder.parseFragmentFromReader(new StringReader(XML));
+ final String XML2 = builder.serializeToString(messageEl);
+ //System.err.println(getClass()+"after Builder="+XML2);
+ XmlElement el2 = builder.parseFragmentFromReader(new StringReader(XML2));
+
+ }
}
1.9 +100 -31 codes/xsul/java/tests/xsul/ws_addressing/TestEndpointReference.java
Index: TestEndpointReference.java
===================================================================
RCS file: /l/extreme/cvs/codes/xsul/java/tests/xsul/ws_addressing/TestEndpointReference.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -t -w -r1.8 -r1.9
--- TestEndpointReference.java 21 Apr 2006 20:05:32 -0000 1.8
+++ TestEndpointReference.java 30 Apr 2006 03:22:04 -0000 1.9
@@ -4,7 +4,7 @@
*
* This software is open source. See the bottom of this file for the licence.
*
- * $Id: TestEndpointReference.java,v 1.8 2006/04/21 20:05:32 aslom Exp $
+ * $Id: TestEndpointReference.java,v 1.9 2006/04/30 03:22:04 aslom Exp $
*/
package xsul.ws_addressing;
@@ -24,7 +24,7 @@
/**
* Tests for handling of WSA EndpointReferences.
*
- * @version $Revision: 1.8 $
+ * @version $Revision: 1.9 $
* @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
*/
public class TestEndpointReference extends XsulTestCase {
@@ -41,9 +41,10 @@
public void testEnpointReference() throws Exception
{
+ {
WsaEndpointReference ep = new WsaEndpointReference(new URI("http://test"));
//System.out.println(getClass()+" equals="+ep.getAddress().equals(new URI("http://test")));
-
+ }
{
WsaEndpointReference sep = new WsaEndpointReference(
builder.parseFragmentFromReader(new StringReader(SIMPLE_ENDPOINT_REF)));
@@ -52,8 +53,22 @@
}
{
+ WsaEndpointReference sep = new WsaEndpointReference(
+ builder.parseFragmentFromReader(new StringReader(SOAP_ENDPOINT_REF)));
+ describeEp(sep);
+ sep.validateData();
+ }
+
+ {
+ WsaEndpointReference sep = new WsaEndpointReference(
+ builder.parseFragmentFromReader(new StringReader(SIMPLE_ENDPOINT_REF_2004)));
+ describeEp(sep);
+ sep.validateData();
+ }
+
+ {
WsaEndpointReference fep = new WsaEndpointReference(
- builder.parseFragmentFromReader(new StringReader(FABRIKAM_ENDPOINT_REF)));
+ builder.parseFragmentFromReader(new StringReader(FABRIKAM_ENDPOINT_REF_2004_08)));
URI address = fep.getAddress();
assertEquals(FABRIKAM_ADDRESS, address.toString());
final QName portTypeQname = QName.valueOf("{"+NS_FABRIKAM.getNamespaceName()+"}"+FABRIKAM_PT);
@@ -65,23 +80,48 @@
{
WsaEndpointReference firstEp = new WsaEndpointReference(
- builder.parseFragmentFromReader(new StringReader(SAMPLE_ENDPOINT_REF)));
+ builder.parseFragmentFromReader(new StringReader(SAMPLE_ENDPOINT_REF_2004_08)));
describeEp(firstEp);
firstEp.validateData();
}
{
WsaEndpointReference secondEp = new WsaEndpointReference(
- builder.parseFragmentFromReader(new StringReader(SAMPLE_ENDPOINT_REF2)));
+ builder.parseFragmentFromReader(new StringReader(SAMPLE_ENDPOINT_REF2_2004_08)));
describeEp(secondEp);
secondEp.validateData();
}
}
private static void describeEp(WsaEndpointReference ep) {
- final boolean PRINT = true; //enable to print EPR descriptions (good for debugging)
- if(PRINT) System.out.println("\nEndpoint Reference "+ep.getName());
+ final boolean PRINT = false; //enable to print EPR descriptions (good for debugging)
+ if(PRINT) System.out.println("\n"+TestEndpointReference.class.getName());
+ if(PRINT) System.out.println("Endpoint Reference "+ep.getName());
if(PRINT) System.out.println("address URI="+ep.getAddress());
+ {
+ XmlElement params = ep.getReferenceParameters();
+ if(params != null) {
+ for(Iterator i = params.requiredElementContent().iterator(); i.hasNext(); ) {
+ Object o = i.next();
+ if(PRINT) System.out.println("reference parameter="+builder.serializeToString(o));
+ }
+ } else {
+ if(PRINT) System.out.println("no reference parameters");
+ }
+ }
+ {
+ XmlElement meta = ep.getMetadata();
+ if(meta != null) {
+ for(Iterator i = meta.requiredElementContent().iterator(); i.hasNext(); ) {
+ Object o = i.next();
+ if(PRINT) System.out.println("metadata="+builder.serializeToString(o));
+ }
+ } else {
+ if(PRINT) System.out.println("no metadata");
+ }
+ }
+ // deprecated -- to be deleted ...
+ if(! WsAddressing.NS_WSA.equals( ep.getWsAddressingVersion() )) {
XmlElement props = ep.getReferenceProperties();
if(props != null) {
for(Iterator i = props.requiredElementContent().iterator(); i.hasNext(); ) {
@@ -91,17 +131,46 @@
} else {
if(PRINT) System.out.println("no reference properties");
}
+
if(PRINT) System.out.println("selected port-type="+ep.getPortType());
if(PRINT) System.out.println("service name="+ep.getServiceName());
if(PRINT) System.out.println("service-port name="+ep.getServicePortName());
+ {
int pos = 1;
for(Iterator i = ep.getPolicy().iterator(); i.hasNext(); ++pos) {
XmlElement policy = (XmlElement) i.next();
if(PRINT) System.out.println("policy["+pos+"]="+builder.serializeToString(policy));
}
}
+ }
+ }
final private static String SIMPLE_ENDPOINT_REF =
+ "<wsa:EndpointReference xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">\n"+
+ " <wsa:Address>http://example.com/fabrikam/acct</wsa:Address>\n"+
+ "</wsa:EndpointReference>";
+
+
+ final private static String SOAP_ENDPOINT_REF =
+ "<wsa:EndpointReference\n"+
+ " xmlns:wsa=\"http://www.w3.org/2005/08/addressing\"\n"+
+ " xmlns:wsaw=\"http://www.w3.org/2005/03/addressing/wsdl\"\n"+
+ " xmlns:fabrikam=\"http://example.com/fabrikam\"\n"+
+ " xmlns:wsdli=\"http://www.w3.org/2006/01/wsdl-instance\"\n"+
+ " wsdli:wsdlLocation=\"http://example.com/fabrikam\n"+
+ " http://example.com/fabrikam/fabrikam.wsdl\">\n"+
+ " <wsa:Address>http://example.com/fabrikam/acct</wsa:Address>\n"+
+ " <wsa:Metadata>\n"+
+ " <wsaw:InterfaceName>fabrikam:Inventory</wsaw:InterfaceName>\n"+
+ " </wsa:Metadata>\n"+
+ " <wsa:ReferenceParameters>\n"+
+ " <fabrikam:CustomerKey>123456789</fabrikam:CustomerKey>\n"+
+ " <fabrikam:ShoppingCart>ABCDEFG</fabrikam:ShoppingCart>\n"+
+ " </wsa:ReferenceParameters>\n"+
+ "</wsa:EndpointReference>";
+
+ // --- deprecated -- tested only for backward compatibility
+ final private static String SIMPLE_ENDPOINT_REF_2004 =
"<SimpleReference"+
" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">"+
"<wsa:Address>http://www.producer.org/ProducerEndpoint</wsa:Address>"+
@@ -112,16 +181,16 @@
final private static String FABRIKAM_ADDRESS = "http://www.fabrikam123.example/acct";
final private static String FABRIKAM_PT = "InventoryPortType";
- final private static String FABRIKAM_ENDPOINT_REF =
- "<wsa:EndpointReference xmlns:wsa=\"http://www.w3.org/2005/08/addressing\""+
+ final private static String FABRIKAM_ENDPOINT_REF_2004_08 =
+ "<wsa:EndpointReference xmlns:wsa=\"http://www.w3.org/2004/08/addressing\""+
"xmlns:fabrikam=\""+NS_FABRIKAM.getNamespaceName()+"\">"+
" <wsa:Address>"+FABRIKAM_ADDRESS+"</wsa:Address>"+
" <wsa:PortType>fabrikam:"+FABRIKAM_PT+"</wsa:PortType>"+
"</wsa:EndpointReference>";
- final private static String SAMPLE_ENDPOINT_REF =
+ final private static String SAMPLE_ENDPOINT_REF_2004_08 =
"<wsnt:ProducerReference"+
- " xmlns:wsa=\"http://www.w3.org/2005/08/addressing\""+
+ " xmlns:wsa=\"http://www.w3.org/2004/08/addressing\""+
" xmlns:wsnt=\"http://www.ibm.com/xmlns/stdwip/web-services/WS-Notification\""+
" xmlns:npex=\"http://www.producer.org/RefProp\">"+
"<wsa:Address>http://www.producer.org/ProducerEndpoint</wsa:Address>"+
@@ -131,9 +200,9 @@
"</wsa:ReferenceProperties>\n"+
"</wsnt:ProducerReference>";
- final private static String SAMPLE_ENDPOINT_REF2 =
+ final private static String SAMPLE_ENDPOINT_REF2_2004_08 =
"<wsa:FilledEndpointReference"+
- " xmlns:wsa=\"http://www.w3.org/2005/08/addressing\""+
+ " xmlns:wsa=\"http://www.w3.org/2004/08/addressing\""+
" xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2002/12/policy\""+
" xmlns:npex=\"http://www.producer.org/RefProp\">"+
"<wsp:Policy><wsp:TextEncoding wsp:Usage=\"wsp:Required\" Encoding=\"utf-8\"/></wsp:Policy>"+
1.3 +9 -4 codes/xsul/java/tests/xsul/ws_addressing/TestWsaConversion.java
Index: TestWsaConversion.java
===================================================================
RCS file: /l/extreme/cvs/codes/xsul/java/tests/xsul/ws_addressing/TestWsaConversion.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -t -w -r1.2 -r1.3
--- TestWsaConversion.java 21 Apr 2006 15:45:44 -0000 1.2
+++ TestWsaConversion.java 30 Apr 2006 03:22:04 -0000 1.3
@@ -4,7 +4,7 @@
*
* This software is open source. See the bottom of this file for the licence.
*
- * $Id: TestWsaConversion.java,v 1.2 2006/04/21 15:45:44 aslom Exp $
+ * $Id: TestWsaConversion.java,v 1.3 2006/04/30 03:22:04 aslom Exp $
*/
package xsul.ws_addressing;
@@ -15,11 +15,13 @@
import org.xmlpull.v1.builder.XmlInfosetBuilder;
import xsul.XmlConstants;
import xsul.XsulTestCase;
+import xsul.XsulVersion;
+import xsul.util.XsulUtil;
/**
* Tests for converting between different versions of WS-Addressing (mostly to and from WSA 1.0)
*
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
* @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
*/
public class TestWsaConversion extends XsulTestCase {
@@ -36,9 +38,12 @@
public void testWsaCoversion() throws Exception
{
- WsaDetectDuplicateMessageId detector = new WsaDetectDuplicateMessageId();
+ XsulVersion.requireVersion("2.5.3");
XmlElement soapEnv = builder.parseFragmentFromReader(new StringReader(MSG_2005));
- XmlElement headers = (XmlElement) soapEnv.requiredElementContent().iterator().next();
+ WsaConverter.convert(soapEnv, WsAddressing.NS_2004_08);
+ //System.err.println(getClass()+" headers="+XsulUtil.safeXmlToString(soapEnv));
+ WsaConverter.convert(soapEnv);
+ //System.err.println(getClass()+" headers="+XsulUtil.safeXmlToString(soapEnv));
}
final private static String MSG_2005 =
1.2 +56 -48 codes/xsul/java/tests/xsul/ws_addressing/TestWsaOperations.java
Index: TestWsaOperations.java
===================================================================
RCS file: /l/extreme/cvs/codes/xsul/java/tests/xsul/ws_addressing/TestWsaOperations.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -t -w -r1.1 -r1.2
--- TestWsaOperations.java 16 Apr 2004 20:53:12 -0000 1.1
+++ TestWsaOperations.java 30 Apr 2006 03:22:04 -0000 1.2
@@ -4,7 +4,7 @@
*
* This software is open source. See the bottom of this file for the licence.
*
- * $Id: TestWsaOperations.java,v 1.1 2004/04/16 20:53:12 aslom Exp $
+ * $Id: TestWsaOperations.java,v 1.2 2006/04/30 03:22:04 aslom Exp $
*/
package xsul.ws_addressing;
@@ -21,6 +21,7 @@
import xsul.XmlConstants;
import xsul.XsulException;
import xsul.XsulTestCase;
+import xsul.XsulVersion;
import xsul.common_type_handler.CommonTypeHandlerRegistry;
import xsul.processor.soap_over_http.SoapHttpDynamicInfosetProcessor;
import xsul.soap.SoapUtil;
@@ -32,7 +33,7 @@
/**
* Tests for utility methods shared by all clases in package.
*
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
* @author <a href="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
*/
public class TestWsaOperations extends XsulTestCase {
@@ -58,6 +59,47 @@
super(name);
}
+ protected void tearDown() {
+ customizedProcessor.stop();
+ customizedProcessor.shutdown();
+ }
+
+ public void testRefProperties2005() throws Exception {
+ testRefProperties(WsAddressing.NS_WSA);
+ }
+
+ public void testRefProperties2004() throws Exception {
+ testRefProperties(WsAddressing.NS_2004_08);
+ }
+
+ private void testRefProperties(XmlNamespace wsa) throws Exception
+ {
+ XsulVersion.requireVersion("2.5.3");
+
+ //setAction("http://www.ibm.com/xmlns/stdwip/web-services/WSBaseNotification/PauseSubscription");
+
+ WsaEndpointReference epr = new WsaEndpointReference(wsa, new URI(location));
+ //setTo s12:mustUnderstand="1">
+
+ XmlElement refParams = builder.parseFragmentFromReader(
+ new StringReader(EXAMPLE_REF_PROPERTY));
+ epr.getReferenceParameters().addElement(refParams);
+
+ XmlElement message = builder.newFragment(
+ "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification", "PauseSubscription");
+
+ WsaInvoker invoker = new WsaInvoker();
+ invoker.setTargetWsa(wsa);
+ invoker.setTargetEPR(epr);
+ invoker.setDefaultAction(new URI("http://www.ibm.com/Action"));
+ assertNotNull(invoker.getDefaultAction());
+ invoker.invokeMessage(message);
+
+ }
+
+ // public void testRefPropertiesFromXml() throws Exception {
+ // }
+
protected void setUp() throws IOException {
TypeHandlerRegistry registry = CommonTypeHandlerRegistry.getInstance();
@@ -67,13 +109,13 @@
// concert envelope to String
// System.err.println(getClass().getName()+" received envelope="
// +builder.serializeToString(envelope));
- logger.finest("received envelope="+builder.serializeToString(envelope));
+ if(logger.isFinestEnabled()) logger.finest("received envelope="+builder.serializeToString(envelope));
// this XML string could be convertedto DOM ot whatever API one preferes (like JDOM, DOM4J, ...)
- XmlElement soapHeader = envelope.element(null, "Header");
- if(soapHeader == null) {
- throw new XsulException("SOAP message must have headers");
- }
+// XmlElement soapHeader = envelope.element(null, "Header");
+// if(soapHeader == null) {
+// throw new XsulException("SOAP message must have headers");
+// }
WsaMessageInformationHeaders wsah = new WsaMessageInformationHeaders(envelope);
//System.err.println(getClass().getName()+" message destinaiton="+wsah.getTo());
assertEquals(location, wsah.getTo().toString());
@@ -96,10 +138,12 @@
}
public XmlElement processMessage(XmlElement message) {
- //System.err.println(getClass().getName()+
- logger.finest("received "+builder.serializeToString(message));
- XmlElement resp = null; //send no repsonse - one way
- return resp;
+ String msg = "received "+builder.serializeToString(message);
+ //System.err.println(getClass().getName()+" "+msg);
+ logger.finest(msg);
+ //XmlElement resp = null;
+ //return resp;
+ return null; //null means send no repsonse - one way
}
};
//customizedProcessor.setServerPort(port);
@@ -111,43 +155,7 @@
location = customizedProcessor.getServer().getLocation();
//System.err.println(getClass().getName()+" started on "+location);
- logger.finest("started on "+location);
- }
-
- protected void tearDown() {
- customizedProcessor.stop();
- customizedProcessor.shutdown();
- }
-
-
-
- public void testRefProperties() throws Exception
- {
-
- //setAction("http://www.ibm.com/xmlns/stdwip/web-services/WSBaseNotification/PauseSubscription");
-
- WsaEndpointReference epr = new WsaEndpointReference(new URI(location));
- //setTo s12:mustUnderstand="1">
-
- XmlElement refProp = builder.parseFragmentFromReader(
- new StringReader(EXAMPLE_REF_PROPERTY));
- epr.getReferenceProperties().addElement(refProp);
-
- XmlElement message = builder.newFragment(
- "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification", "PauseSubscription");
-
- WsaInvoker invoker = new WsaInvoker();
- invoker.setTargetEPR(epr);
- invoker.setDefaultAction(new URI("http://www.ibm.com/Action"));
- assertNotNull(invoker.getDefaultAction());
- invoker.invokeMessage(message);
-
- }
-
- public void testRefPropertiesFromXml() throws Exception
- {
-
-
+ if(logger.isFinestEnabled()) logger.finest("started on "+location);
}
}