[jboss-svn-commits] JBL Code SVN: r17822 - labs/jbosstm/workspace/adinn/XTSGF/WSTX/classes/com/arjuna/mwlabs/wst/at.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Jan 14 11:51:50 EST 2008
Author: adinn
Date: 2008-01-14 11:51:50 -0500 (Mon, 14 Jan 2008)
New Revision: 17822
Modified:
labs/jbosstm/workspace/adinn/XTSGF/WSTX/classes/com/arjuna/mwlabs/wst/at/ContextFactoryWSImple.java
Log:
modified so that the W3CEndpoiintReference WSDL metadata is supplied by hand but to no avail since the metadata is ignored when the W3CEndpoiintReference is processed under getPort()
Modified: labs/jbosstm/workspace/adinn/XTSGF/WSTX/classes/com/arjuna/mwlabs/wst/at/ContextFactoryWSImple.java
===================================================================
--- labs/jbosstm/workspace/adinn/XTSGF/WSTX/classes/com/arjuna/mwlabs/wst/at/ContextFactoryWSImple.java 2008-01-14 16:47:07 UTC (rev 17821)
+++ labs/jbosstm/workspace/adinn/XTSGF/WSTX/classes/com/arjuna/mwlabs/wst/at/ContextFactoryWSImple.java 2008-01-14 16:51:50 UTC (rev 17822)
@@ -44,6 +44,7 @@
import com.arjuna.mwlabs.wst.at.participants.CleanupSynchronizationWS;
import com.arjuna.webservices.ServiceRegistryWS;
import com.arjuna.webservices.wsarj.InstanceIdentifierWS;
+import com.arjuna.webservices.wsarj.ArjunaConstants;
import com.arjuna.webservices.wsat.AtomicTransactionWSConstants;
import com.arjuna.webservices.wscoor.CoordinationConstantsWS;
import com.arjuna.wsc.ContextFactoryWS;
@@ -52,9 +53,14 @@
import org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext;
import org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType;
import org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires;
+import org.w3c.dom.Element;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
public class ContextFactoryWSImple implements ContextFactoryWS, LocalFactory
{
@@ -170,6 +176,14 @@
builder.address(registrationCoordinatorURI);
builder.wsdlDocumentLocation(registrationCoordinatorURI + "?wsdl");
InstanceIdentifierWS.setEndpointInstanceIdentifier(builder, arjunaContext.getTransactionIdentifier());
+ // here's another attempt to fix the missing functionality -- we can try supplying metadata by hand
+ // using the format dictated by the Web Services Metadata Exchange Specification (MEX). Unfortunately,
+ // this also fails to work. the metadata is indeed successfully transferred to the client in the
+ // W3CEndpointreference. Unfortunately when teh spi.Provider code converts it to a local (Sun)
+ // WSEndpointReference instance under W3CEndpointReference.getPort() it throws away the metadata
+ // element supplied here, installs its own empty Metadata object then complains because there is no
+ // WSDL metadata!
+ addMetadataWSDLRef(builder, registrationCoordinatorURI + "?wsdl");
W3CEndpointReference registrationCoordinator = builder.build();
coordinationContext.setRegistrationService(registrationCoordinator) ;
@@ -279,4 +293,67 @@
private CoordinatorManager _coordManager;
private RegistrarWSImple _theRegistrar;
+ /**
+ * create a metadata element idenitfying the WSDL for a given web service by reference via the supplied URL
+ * @param wsdlURL a URL identifying the location of the WSDL for an endpoint identified by a W3C endpoint reference
+ * @return a xmlsoap metadata exchange format metadata element defining the WSDL by reference
+ */
+ private static Element createWSDLMetadataReferenceElement(final String wsdlURL)
+ {
+ /*
+ * the format for a metadata wsdl reference element is as follows:
+ *
+ * <mex:Metadata xmlns:mex="http://schemas.xmlsoap.org/ws/2004/09/mex">
+ * <mex:MetadataSection Dialect="http://schemas.xmlsoap.org/ws/2004/09/mex">
+ * <mex:Location>
+ * >>wsdl URL String<<
+ * </mex:Location>
+ * </mex:MetadataSection>
+ * </mex:Metadata>
+ */
+ try {
+ SOAPFactory factory = getFactory();
+ SOAPElement metadataElement = factory.createElement(METADATA_ELEMENT_NAME);
+ SOAPElement metadataSectionElement = metadataElement.addChildElement(METADATA_SECTION_ELEMENT_NAME);
+ metadataSectionElement.addAttribute(METADATA_DIALECT_ATTRIBUTE_NAME, METADATA_NAMESPACE);
+ SOAPElement locationElement = metadataSectionElement.addChildElement(METADATA_LOCATION_ELEMENT_NAME);
+ locationElement.addTextNode(wsdlURL);
+ return metadataElement;
+ } catch (SOAPException se) {
+ // TODO log error here (should never happen)
+ return null;
+ }
+ }
+
+ private static void addMetadataWSDLRef(W3CEndpointReferenceBuilder builder, String wsdlURL)
+ {
+ builder.metadata(createWSDLMetadataReferenceElement(wsdlURL));
+ }
+
+ static final String METADATA_PREFIX = "mex";
+ static final String METADATA_NAMESPACE = "http://schemas.xmlsoap.org/ws/2004/09/mex";
+
+ static final String METADATA_ELEMENT_STRING = "Metadata";
+ static final String METADATA_SECTION_ELEMENT_STRING = "MetadataSection";
+ static final String METADATA_DIALECT_ATTRIBUTE_STRING = "Dialect";
+ static final String METADATA_LOCATION_ELEMENT_STRING = "Location";
+
+ static Name METADATA_ELEMENT_NAME = null;
+ static Name METADATA_SECTION_ELEMENT_NAME = null;
+ static Name METADATA_DIALECT_ATTRIBUTE_NAME = null;
+ static Name METADATA_LOCATION_ELEMENT_NAME = null;
+
+ static SOAPFactory factory = null;
+
+ static synchronized SOAPFactory getFactory() throws SOAPException
+ {
+ if (factory == null) {
+ factory = SOAPFactory.newInstance();
+ METADATA_ELEMENT_NAME = factory.createName(METADATA_ELEMENT_STRING, METADATA_PREFIX, METADATA_NAMESPACE);
+ METADATA_SECTION_ELEMENT_NAME = factory.createName(METADATA_SECTION_ELEMENT_STRING, METADATA_PREFIX, METADATA_NAMESPACE);
+ METADATA_DIALECT_ATTRIBUTE_NAME = factory.createName(METADATA_DIALECT_ATTRIBUTE_STRING, METADATA_PREFIX, METADATA_NAMESPACE);
+ METADATA_LOCATION_ELEMENT_NAME = factory.createName(METADATA_LOCATION_ELEMENT_STRING, METADATA_PREFIX, METADATA_NAMESPACE);
+ }
+ return factory;
+ }
}
\ No newline at end of file
More information about the jboss-svn-commits
mailing list