JBossWS SVN: r5151 - stack/cxf/trunk/ant-import.
by jbossws-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2007-11-29 12:47:29 -0500 (Thu, 29 Nov 2007)
New Revision: 5151
Modified:
stack/cxf/trunk/ant-import/build-thirdparty.xml
Log:
Add messages
Modified: stack/cxf/trunk/ant-import/build-thirdparty.xml
===================================================================
--- stack/cxf/trunk/ant-import/build-thirdparty.xml 2007-11-29 17:40:14 UTC (rev 5150)
+++ stack/cxf/trunk/ant-import/build-thirdparty.xml 2007-11-29 17:47:29 UTC (rev 5151)
@@ -117,6 +117,7 @@
<target name="cxf-checkout" depends="cxf-checkout-required" if="cxf.checkout.required">
<delete dir="${apache.cxf.dir}"/>
+ <echo message="svn checkout -r${cxf.svn.rev} ${cxf.svn.url}"/>
<exec dir="${cxf.dir}" executable="svn" failonerror="true">
<arg value="checkout"/>
<arg value="-r${cxf.svn.rev}"/>
@@ -140,6 +141,7 @@
</target>
<target name="cxf-update" depends="cxf-update-required" if="cxf.update.required">
+ <echo message="svn update -r${cxf.svn.rev} ${cxf.svn.url}"/>
<exec dir="${apache.cxf.dir}" executable="svn" failonerror="true">
<arg value="update"/>
<arg value="-r${cxf.svn.rev}"/>
17 years, 3 months
JBossWS SVN: r5150 - in stack/cxf/trunk: ant-import and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2007-11-29 12:40:14 -0500 (Thu, 29 Nov 2007)
New Revision: 5150
Modified:
stack/cxf/trunk/ant-import/build-thirdparty.xml
stack/cxf/trunk/version.properties
Log:
Add support for cxf svn url change
Modified: stack/cxf/trunk/ant-import/build-thirdparty.xml
===================================================================
--- stack/cxf/trunk/ant-import/build-thirdparty.xml 2007-11-29 16:07:46 UTC (rev 5149)
+++ stack/cxf/trunk/ant-import/build-thirdparty.xml 2007-11-29 17:40:14 UTC (rev 5150)
@@ -95,7 +95,28 @@
</target>
<!-- SVN checkout the Apache CXF sources -->
- <target name="cxf-checkout" depends="thirdparty-init" unless="apache.cxf.available">
+ <target name="cxf-checkout-dir" depends="thirdparty-init" unless="apache.cxf.available">
+ <property name="cxf.checkout.required" value="true"/>
+ <echo message="cxf.checkout.required=${cxf.checkout.required}"/>
+ </target>
+
+ <target name="cxf-checkout-required" depends="cxf-checkout-dir" if="apache.cxf.available">
+ <exec dir="${apache.cxf.dir}" executable="svn" failonerror="true" output="${apache.cxf.dir}/svn-info.xml">
+ <arg line="info"/>
+ <arg line="--xml"/>
+ </exec>
+ <xmlproperty file="${apache.cxf.dir}/svn-info.xml"/>
+ <property name="cxf.entry.url" value="${info.entry.url}"/>
+ <condition property="cxf.checkout.required">
+ <not>
+ <equals arg1="${cxf.entry.url}" arg2="${cxf.svn.url}"/>
+ </not>
+ </condition>
+ <echo message="cxf.checkout.required=${cxf.checkout.required}"/>
+ </target>
+
+ <target name="cxf-checkout" depends="cxf-checkout-required" if="cxf.checkout.required">
+ <delete dir="${apache.cxf.dir}"/>
<exec dir="${cxf.dir}" executable="svn" failonerror="true">
<arg value="checkout"/>
<arg value="-r${cxf.svn.rev}"/>
@@ -105,7 +126,20 @@
</target>
<!-- SVN update the Apache CXF sources -->
- <target name="cxf-update" depends="thirdparty-init" if="apache.cxf.available">
+ <target name="cxf-update-required" depends="thirdparty-init" if="apache.cxf.available">
+ <exec dir="${apache.cxf.dir}" executable="svn" failonerror="true" output="${apache.cxf.dir}/svn-info.xml">
+ <arg line="info"/>
+ <arg line="--xml"/>
+ </exec>
+ <xmlproperty file="${apache.cxf.dir}/svn-info.xml"/>
+ <property name="cxf.entry.url" value="${info.entry.url}"/>
+ <condition property="cxf.update.required">
+ <equals arg1="${cxf.entry.url}" arg2="${cxf.svn.url}"/>
+ </condition>
+ <echo message="cxf.update.required=${cxf.update.required}"/>
+ </target>
+
+ <target name="cxf-update" depends="cxf-update-required" if="cxf.update.required">
<exec dir="${apache.cxf.dir}" executable="svn" failonerror="true">
<arg value="update"/>
<arg value="-r${cxf.svn.rev}"/>
@@ -113,18 +147,18 @@
</target>
<!-- SVN get commit revision -->
- <target name="cxf-commit-revision" depends="cxf-update,cxf-checkout">
+ <target name="cxf-svn-info" depends="cxf-update,cxf-checkout">
<exec dir="${apache.cxf.dir}" executable="svn" failonerror="true" output="${apache.cxf.dir}/svn-info.xml">
<arg line="info"/>
<arg line="--xml"/>
</exec>
<xmlproperty file="${apache.cxf.dir}/svn-info.xml"/>
- <property name="cxf.commit.revision" value="${info.entry.commit(revision)}"/>
- <available property="cxf.build.available" file="${apache.cxf.dir}/build-${cxf.commit.revision}.rev"/>
+ <property name="cxf.entry.commit.revision" value="${info.entry.commit(revision)}"/>
+ <available property="cxf.build.available" file="${apache.cxf.dir}/build-${cxf.entry.commit.revision}.rev"/>
</target>
<!-- Build using maven -->
- <target name="cxf-maven-build" depends="cxf-commit-revision" unless="cxf.build.available">
+ <target name="cxf-maven-build" depends="cxf-svn-info" unless="cxf.build.available">
<exec dir="${apache.cxf.dir}" executable="mvn" failonerror="true">
<arg value="clean"/>
<arg value="install"/>
@@ -134,7 +168,7 @@
<arg line="info"/>
<arg line="--xml"/>
</exec>
- <touch file="${apache.cxf.dir}/build-${cxf.commit.revision}.rev"/>
+ <touch file="${apache.cxf.dir}/build-${cxf.entry.commit.revision}.rev"/>
</target>
<!-- Copy the cxf jars -->
Modified: stack/cxf/trunk/version.properties
===================================================================
--- stack/cxf/trunk/version.properties 2007-11-29 16:07:46 UTC (rev 5149)
+++ stack/cxf/trunk/version.properties 2007-11-29 17:40:14 UTC (rev 5150)
@@ -14,7 +14,8 @@
implementation.vendor.id=http://www.jboss.org
# Apache CXF version
-cxf.svn.url=http://svn.apache.org/repos/asf/incubator/cxf/trunk
+#cxf.svn.url=http://svn.apache.org/repos/asf/incubator/cxf/trunk
+cxf.svn.url=http://svn.apache.org/repos/asf/incubator/cxf/tags/cxf-2.0.3-incubator
cxf.svn.rev=HEAD
# Apache CXF versions
17 years, 3 months
JBossWS SVN: r5149 - in stack/native/trunk/src: test/resources/jaxws/wsrm/emulator/reqres/config and 1 other directories.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2007-11-29 11:07:46 -0500 (Thu, 29 Nov 2007)
New Revision: 5149
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java
stack/native/trunk/src/test/resources/jaxws/wsrm/emulator/reqres/config/req-res-service-config.xml
stack/native/trunk/src/test/resources/jaxws/wsrm/emulator/reqres/resources/echoResponse.xml
Log:
reparing exchanged messages
Modified: stack/native/trunk/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java 2007-11-29 13:53:45 UTC (rev 5148)
+++ stack/native/trunk/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java 2007-11-29 16:07:46 UTC (rev 5149)
@@ -537,7 +537,6 @@
candidateSequence.setOutboundId(outboundId);
candidateSequence.setBehavior(createSequenceResponse.getIncompleteSequenceBehavior());
candidateSequence.setDuration(RMHelper.durationToLong(createSequenceResponse.getExpires()));
- createSequenceResponse.getIncompleteSequenceBehavior();
return this.wsrmSequence = candidateSequence;
}
catch (Exception e)
Modified: stack/native/trunk/src/test/resources/jaxws/wsrm/emulator/reqres/config/req-res-service-config.xml
===================================================================
--- stack/native/trunk/src/test/resources/jaxws/wsrm/emulator/reqres/config/req-res-service-config.xml 2007-11-29 13:53:45 UTC (rev 5148)
+++ stack/native/trunk/src/test/resources/jaxws/wsrm/emulator/reqres/config/req-res-service-config.xml 2007-11-29 16:07:46 UTC (rev 5149)
@@ -25,7 +25,7 @@
<set property="res.wsa.to" value="${req.wsa.replyto}"/>
<set property="res.wsa.action" value="http://docs.oasis-open.org/ws-rx/wsrm/200702/CreateSequenceResponse"/>
<set property="res.wsa.relatesto" value="${req.wsa.messageid}"/>
- <set property="res.wsrm.sequenceid" value="http://sequence/id/456"/>
+ <set property="res.wsrm.sequenceid" value="http://sequence/id/outbound/123"/>
</response>
</view>
@@ -46,8 +46,7 @@
<set property="res.wsa.action" value="http://docs.oasis-open.org/ws-rx/wsrm/200702/SequenceAcknowledgement"/>
<set property="res.wsa.relatesto" value="${req.wsa.messageid}"/>
<set property="res.wsrm.sequenceid" value="${req.wsrm.sequenceid}"/>
- <set property="res.wsrm.ack.lower" value="${req.wsrm.messagenumber}"/>
- <set property="res.wsrm.ack.upper" value="${req.wsrm.messagenumber}"/>
+ <set property="res.wsrm.messagenumber" value="${req.wsrm.messagenumber}"/>
</response>
</view>
Modified: stack/native/trunk/src/test/resources/jaxws/wsrm/emulator/reqres/resources/echoResponse.xml
===================================================================
--- stack/native/trunk/src/test/resources/jaxws/wsrm/emulator/reqres/resources/echoResponse.xml 2007-11-29 13:53:45 UTC (rev 5148)
+++ stack/native/trunk/src/test/resources/jaxws/wsrm/emulator/reqres/resources/echoResponse.xml 2007-11-29 16:07:46 UTC (rev 5149)
@@ -8,8 +8,15 @@
<wsa:Action env:mustUnderstand="1">${res.wsa.action}</wsa:Action>
<wsrm:SequenceAcknowledgement>
<wsrm:Identifier>${res.wsrm.sequenceid}</wsrm:Identifier>
- <wsrm:AcknowledgementRange Upper='${res.wsrm.ack.upper}' Lower='${res.wsrm.ack.lower}'/>
+ <wsrm:AcknowledgementRange Upper='${res.wsrm.messagenumber}' Lower='${res.wsrm.messagenumber}'/>
</wsrm:SequenceAcknowledgement>
+ <wsrm:AckRequested>
+ <wsrm:Identifier>http://sequence/id/inbound/456</wsrm:Identifier>
+ </wsrm:AckRequested>
+ <wsrm:Sequence env:mustUnderstand="1">
+ <wsrm:Identifier>http://sequence/id/inbound/456</wsrm:Identifier>
+ <wsrm:MessageNumber>${res.wsrm.messagenumber}</wsrm:MessageNumber>
+ </wsrm:Sequence>
</env:Header>
<env:Body>
<ns1:echoResponse xmlns:ns1='http://org.jboss.ws/jaxws/wsrm'>
17 years, 3 months
JBossWS SVN: r5148 - in stack/native/trunk/src: main/java/org/jboss/ws/extensions/wsrm and 8 other directories.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2007-11-29 08:53:45 -0500 (Thu, 29 Nov 2007)
New Revision: 5148
Added:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/RMHelper.java
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMSequenceImpl.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/api/RMSequence.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/serialization/RMCreateSequenceResponseSerializer.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/serialization/RMCreateSequenceSerializer.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spec200502/RMCreateSequenceImpl.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spec200502/RMCreateSequenceResponseImpl.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spec200702/RMCreateSequenceImpl.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spec200702/RMCreateSequenceResponseImpl.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spi/protocol/RMCreateSequence.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spi/protocol/RMCreateSequenceResponse.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/wsrm/deserialization/RMDeSerializationTestCase.java
stack/native/trunk/src/test/resources/jaxws/wsrm/emulator/common/resources/createSequenceResponse.xml
Log:
refactoring - duration will be javax.xml.datatype.Duration instead of String
Modified: stack/native/trunk/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java 2007-11-29 12:35:27 UTC (rev 5147)
+++ stack/native/trunk/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java 2007-11-29 13:53:45 UTC (rev 5148)
@@ -75,6 +75,7 @@
import org.jboss.ws.extensions.wsrm.api.RMException;
import org.jboss.ws.extensions.wsrm.api.RMSequence;
import org.jboss.ws.extensions.wsrm.api.RMSequenceType;
+import org.jboss.ws.extensions.wsrm.common.RMHelper;
import org.jboss.ws.extensions.wsrm.spi.RMProvider;
import org.jboss.ws.extensions.wsrm.spi.protocol.RMCreateSequenceResponse;
import org.jboss.ws.metadata.config.Configurable;
@@ -534,6 +535,9 @@
String outboundId = createSequenceResponse.getIdentifier();
candidateSequence.setClient(this);
candidateSequence.setOutboundId(outboundId);
+ candidateSequence.setBehavior(createSequenceResponse.getIncompleteSequenceBehavior());
+ candidateSequence.setDuration(RMHelper.durationToLong(createSequenceResponse.getExpires()));
+ createSequenceResponse.getIncompleteSequenceBehavior();
return this.wsrmSequence = candidateSequence;
}
catch (Exception e)
Modified: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMSequenceImpl.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMSequenceImpl.java 2007-11-29 12:35:27 UTC (rev 5147)
+++ stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMSequenceImpl.java 2007-11-29 13:53:45 UTC (rev 5148)
@@ -48,6 +48,7 @@
import org.jboss.ws.extensions.wsrm.config.RMConfig;
import org.jboss.ws.extensions.wsrm.spi.RMConstants;
import org.jboss.ws.extensions.wsrm.spi.RMProvider;
+import org.jboss.ws.extensions.wsrm.spi.protocol.RMIncompleteSequenceBehavior;
import org.jboss.ws.extensions.wsrm.transport.RMUnassignedMessageListener;
/**
@@ -64,11 +65,14 @@
private static final Logger logger = Logger.getLogger(RMSequenceImpl.class);
private static final RMConstants wsrmConstants = RMProvider.get().getConstants();
- private final String incomingSequenceId = "http://sequence/id/123"; // TODO: use generator
private final RMConfig wsrmConfig;
private final RMSequenceType sequenceType;
private final RMAddressingType addrType;
+ private RMIncompleteSequenceBehavior behavior = RMIncompleteSequenceBehavior.NO_DISCARD;
+ private String incomingSequenceId;
private String outgoingSequenceId;
+ private long duration = -1;
+ private long creationTime;
private URI backPort;
private ClientImpl client;
// object states variables
@@ -82,6 +86,7 @@
{
// we can't use objectLock in the method - possible deadlock
this.countOfUnassignedMessagesAvailable.addAndGet(1);
+ logger.debug("Expected sequence expiration in " + ((System.currentTimeMillis() - this.creationTime) / 1000) + "seconds");
logger.debug("Unassigned message available in callback handler");
}
@@ -131,6 +136,20 @@
}
}
+ public final void setDuration(long duration)
+ {
+ if (duration > 0)
+ {
+ this.creationTime = System.currentTimeMillis();
+ this.duration = duration;
+ }
+ }
+
+ public final long getDuration()
+ {
+ return -1L;
+ }
+
public final URI getBackPort()
{
return (this.addrType == RMAddressingType.ADDRESSABLE) ? this.backPort : null;
@@ -250,6 +269,22 @@
{
sendMessage(RMConstant.SEQUENCE_ACKNOWLEDGEMENT_WSA_ACTION, wsrmConstants.getSequenceAcknowledgementQName());
}
+
+ public final void setBehavior(RMIncompleteSequenceBehavior behavior)
+ {
+ this.objectLock.lock();
+ try
+ {
+ if (behavior != null)
+ {
+ this.behavior = behavior;
+ }
+ }
+ finally
+ {
+ this.objectLock.unlock();
+ }
+ }
public final boolean isCompleted()
{
Modified: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/api/RMSequence.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/api/RMSequence.java 2007-11-29 12:35:27 UTC (rev 5147)
+++ stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/api/RMSequence.java 2007-11-29 13:53:45 UTC (rev 5148)
@@ -25,12 +25,13 @@
public interface RMSequence
{
- String getOutboundId() throws RMException;
- String getInboundId() throws RMException;
- void discard() throws RMException;
- boolean isDiscarded() throws RMException;
- void close() throws RMException;
- boolean isClosed() throws RMException;
- boolean isCompleted() throws RMException;
- boolean isCompleted(int timeAmount, TimeUnit timeUnit) throws RMException;
+ String getOutboundId();
+ String getInboundId();
+ void discard();
+ long getDuration();
+ boolean isDiscarded();
+ void close();
+ boolean isClosed();
+ boolean isCompleted();
+ boolean isCompleted(int timeAmount, TimeUnit timeUnit);
}
Added: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/RMHelper.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/RMHelper.java (rev 0)
+++ stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/RMHelper.java 2007-11-29 13:53:45 UTC (rev 5148)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.extensions.wsrm.common;
+
+import java.util.Date;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.Duration;
+
+import org.jboss.ws.extensions.wsrm.api.RMException;
+
+/**
+ * RM utility library
+ *
+ * @author richard.opalka(a)jboss.com
+ *
+ * @since Nov 29, 2007
+ */
+public final class RMHelper
+{
+
+ private RMHelper()
+ {
+ // no instances allowed
+ }
+
+ private static final DatatypeFactory factory;
+
+ static
+ {
+ try
+ {
+ factory = DatatypeFactory.newInstance();
+ }
+ catch (DatatypeConfigurationException dce)
+ {
+ throw new RMException(dce.getMessage(), dce);
+ }
+ }
+
+ public static Duration stringToDuration(String s)
+ {
+ return factory.newDuration(s);
+ }
+
+ public static String durationToString(Duration d)
+ {
+ return d.toString();
+ }
+
+ public static long durationToLong(Duration d)
+ {
+ if (d == null)
+ return -1L;
+
+ return d.getTimeInMillis(new Date());
+ }
+
+}
Property changes on: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/RMHelper.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/serialization/RMCreateSequenceResponseSerializer.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/serialization/RMCreateSequenceResponseSerializer.java 2007-11-29 12:35:27 UTC (rev 5147)
+++ stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/serialization/RMCreateSequenceResponseSerializer.java 2007-11-29 13:53:45 UTC (rev 5148)
@@ -35,6 +35,7 @@
import javax.xml.ws.addressing.AddressingConstants;
import org.jboss.ws.extensions.wsrm.api.RMException;
+import org.jboss.ws.extensions.wsrm.common.RMHelper;
import org.jboss.ws.extensions.wsrm.spi.RMConstants;
import org.jboss.ws.extensions.wsrm.spi.RMProvider;
import org.jboss.ws.extensions.wsrm.spi.protocol.RMCreateSequenceResponse;
@@ -94,7 +95,7 @@
if (expiresElement != null)
{
String duration = getRequiredTextContent(expiresElement, expiresQName);
- o.setExpires(duration);
+ o.setExpires(RMHelper.stringToDuration(duration));
}
// read optional wsrm:IncompleteSequenceBehavior element
@@ -165,7 +166,7 @@
{
// write optional wsrm:Expires element
QName expiresQName = wsrmConstants.getExpiresQName();
- createSequenceResponseElement.addChildElement(expiresQName).setValue(o.getExpires());
+ createSequenceResponseElement.addChildElement(expiresQName).setValue(RMHelper.durationToString(o.getExpires()));
}
if (o.getIncompleteSequenceBehavior() != null)
Modified: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/serialization/RMCreateSequenceSerializer.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/serialization/RMCreateSequenceSerializer.java 2007-11-29 12:35:27 UTC (rev 5147)
+++ stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/serialization/RMCreateSequenceSerializer.java 2007-11-29 13:53:45 UTC (rev 5148)
@@ -25,6 +25,8 @@
import static org.jboss.ws.extensions.wsrm.common.serialization.RMSerializationHelper.getRequiredElement;
import static org.jboss.ws.extensions.wsrm.common.serialization.RMSerializationHelper.getRequiredTextContent;
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPElement;
@@ -35,6 +37,7 @@
import javax.xml.ws.addressing.AddressingConstants;
import org.jboss.ws.extensions.wsrm.api.RMException;
+import org.jboss.ws.extensions.wsrm.common.RMHelper;
import org.jboss.ws.extensions.wsrm.spi.RMConstants;
import org.jboss.ws.extensions.wsrm.spi.RMProvider;
import org.jboss.ws.extensions.wsrm.spi.protocol.RMCreateSequence;
@@ -96,7 +99,7 @@
if (expiresElement != null)
{
String duration = getRequiredTextContent(expiresElement, expiresQName);
- o.setExpires(duration);
+ o.setExpires(RMHelper.stringToDuration(duration));
}
// read optional wsrm:Offer element
@@ -186,7 +189,7 @@
{
// write optional wsrm:Expires element
QName expiresQName = wsrmConstants.getExpiresQName();
- createSequenceElement.addChildElement(expiresQName).setValue(o.getExpires());
+ createSequenceElement.addChildElement(expiresQName).setValue(RMHelper.durationToString(o.getExpires()));
}
if (o.getOffer() != null)
Modified: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spec200502/RMCreateSequenceImpl.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spec200502/RMCreateSequenceImpl.java 2007-11-29 12:35:27 UTC (rev 5147)
+++ stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spec200502/RMCreateSequenceImpl.java 2007-11-29 13:53:45 UTC (rev 5148)
@@ -21,6 +21,8 @@
*/
package org.jboss.ws.extensions.wsrm.spec200502;
+import javax.xml.datatype.Duration;
+
import org.jboss.ws.extensions.wsrm.api.RMException;
import org.jboss.ws.extensions.wsrm.common.serialization.RMAbstractSerializable;
import org.jboss.ws.extensions.wsrm.spi.RMProvider;
@@ -38,7 +40,7 @@
private static final RMProvider PROVIDER = RMProviderImpl.getInstance();
// internal fields
private String acksTo;
- private String expires;
+ private Duration expires;
private Offer offer;
RMCreateSequenceImpl()
@@ -57,7 +59,7 @@
/*
* @see org.jboss.ws.extensions.wsrm.spi.protocol.CreateSequence#getExpires()
*/
- public String getExpires()
+ public Duration getExpires()
{
return this.expires;
}
@@ -94,9 +96,9 @@
/*
* @see org.jboss.ws.extensions.wsrm.spi.protocol.CreateSequence#setExpires(java.lang.String)
*/
- public void setExpires(String duration)
+ public void setExpires(Duration duration)
{
- if ((duration == null) || (duration.trim().equals("")))
+ if ((duration == null) || (duration.toString().equals("")))
throw new IllegalArgumentException("Duration cannot be null nor empty string");
if (this.expires != null)
throw new UnsupportedOperationException("Value already set, cannot be overriden");
Modified: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spec200502/RMCreateSequenceResponseImpl.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spec200502/RMCreateSequenceResponseImpl.java 2007-11-29 12:35:27 UTC (rev 5147)
+++ stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spec200502/RMCreateSequenceResponseImpl.java 2007-11-29 13:53:45 UTC (rev 5148)
@@ -21,6 +21,8 @@
*/
package org.jboss.ws.extensions.wsrm.spec200502;
+import javax.xml.datatype.Duration;
+
import org.jboss.ws.extensions.wsrm.api.RMException;
import org.jboss.ws.extensions.wsrm.common.serialization.RMAbstractSerializable;
import org.jboss.ws.extensions.wsrm.spi.RMProvider;
@@ -38,7 +40,7 @@
private static final RMProvider PROVIDER = RMProviderImpl.getInstance();
// internal fields
private String identifier;
- private String expires;
+ private Duration expires;
private Accept accept;
RMCreateSequenceResponseImpl()
@@ -57,7 +59,7 @@
/*
* @see org.jboss.ws.extensions.wsrm.spi.protocol.CreateSequenceResponse#getDuration()
*/
- public String getExpires()
+ public Duration getExpires()
{
return this.expires;
}
@@ -106,9 +108,9 @@
/*
* @see org.jboss.ws.extensions.wsrm.spi.protocol.CreateSequenceResponse#setExpires(java.lang.String)
*/
- public void setExpires(String duration)
+ public void setExpires(Duration duration)
{
- if ((duration == null) || (duration.trim().equals("")))
+ if ((duration == null) || (duration.toString().equals("")))
throw new IllegalArgumentException("Duration cannot be null nor empty string");
if (this.expires != null)
throw new UnsupportedOperationException("Value already set, cannot be overriden");
Modified: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spec200702/RMCreateSequenceImpl.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spec200702/RMCreateSequenceImpl.java 2007-11-29 12:35:27 UTC (rev 5147)
+++ stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spec200702/RMCreateSequenceImpl.java 2007-11-29 13:53:45 UTC (rev 5148)
@@ -21,6 +21,8 @@
*/
package org.jboss.ws.extensions.wsrm.spec200702;
+import javax.xml.datatype.Duration;
+
import org.jboss.ws.extensions.wsrm.api.RMException;
import org.jboss.ws.extensions.wsrm.common.serialization.RMAbstractSerializable;
import org.jboss.ws.extensions.wsrm.spi.RMProvider;
@@ -38,7 +40,7 @@
private static final RMProvider PROVIDER = RMProviderImpl.getInstance();
// internal fields
private String acksTo;
- private String expires;
+ private Duration expires;
private Offer offer;
RMCreateSequenceImpl()
@@ -57,7 +59,7 @@
/*
* @see org.jboss.ws.extensions.wsrm.spi.protocol.CreateSequence#getExpires()
*/
- public String getExpires()
+ public Duration getExpires()
{
return this.expires;
}
@@ -94,9 +96,9 @@
/*
* @see org.jboss.ws.extensions.wsrm.spi.protocol.CreateSequence#setExpires(java.lang.String)
*/
- public void setExpires(String duration)
+ public void setExpires(Duration duration)
{
- if ((duration == null) || (duration.trim().equals("")))
+ if ((duration == null) || (duration.toString().equals("")))
throw new IllegalArgumentException("Duration cannot be null nor empty string");
if (this.expires != null)
throw new UnsupportedOperationException("Value already set, cannot be overriden");
Modified: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spec200702/RMCreateSequenceResponseImpl.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spec200702/RMCreateSequenceResponseImpl.java 2007-11-29 12:35:27 UTC (rev 5147)
+++ stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spec200702/RMCreateSequenceResponseImpl.java 2007-11-29 13:53:45 UTC (rev 5148)
@@ -21,6 +21,8 @@
*/
package org.jboss.ws.extensions.wsrm.spec200702;
+import javax.xml.datatype.Duration;
+
import org.jboss.ws.extensions.wsrm.api.RMException;
import org.jboss.ws.extensions.wsrm.common.serialization.RMAbstractSerializable;
import org.jboss.ws.extensions.wsrm.spi.RMProvider;
@@ -38,7 +40,7 @@
private static final RMProvider PROVIDER = RMProviderImpl.getInstance();
// internal fields
private String identifier;
- private String expires;
+ private Duration expires;
private Accept accept;
private RMIncompleteSequenceBehavior incompleteSequenceBehavior;
@@ -58,7 +60,7 @@
/*
* @see org.jboss.ws.extensions.wsrm.spi.protocol.CreateSequenceResponse#getDuration()
*/
- public String getExpires()
+ public Duration getExpires()
{
return this.expires;
}
@@ -107,9 +109,9 @@
/*
* @see org.jboss.ws.extensions.wsrm.spi.protocol.CreateSequenceResponse#setExpires(java.lang.String)
*/
- public void setExpires(String duration)
+ public void setExpires(Duration duration)
{
- if ((duration == null) || (duration.trim().equals("")))
+ if ((duration == null) || (duration.toString().equals("")))
throw new IllegalArgumentException("Duration cannot be null nor empty string");
if (this.expires != null)
throw new UnsupportedOperationException("Value already set, cannot be overriden");
Modified: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spi/protocol/RMCreateSequence.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spi/protocol/RMCreateSequence.java 2007-11-29 12:35:27 UTC (rev 5147)
+++ stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spi/protocol/RMCreateSequence.java 2007-11-29 13:53:45 UTC (rev 5148)
@@ -21,6 +21,8 @@
*/
package org.jboss.ws.extensions.wsrm.spi.protocol;
+import javax.xml.datatype.Duration;
+
/**
* <p><b>CreateSequence</b> element requests creation of a new Sequence between the RM Source that sends it, and the
* RM Destination to which it is sent. The RM Source MUST NOT send this element as a header
@@ -76,13 +78,13 @@
* the element indicates an implied value of <b>"PT0S"</b>.
* @param duration
*/
- void setExpires(String duration);
+ void setExpires(Duration duration);
/**
* Getter
* @return duration
*/
- String getExpires();
+ Duration getExpires();
/**
* Factory method
Modified: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spi/protocol/RMCreateSequenceResponse.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spi/protocol/RMCreateSequenceResponse.java 2007-11-29 12:35:27 UTC (rev 5147)
+++ stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/spi/protocol/RMCreateSequenceResponse.java 2007-11-29 13:53:45 UTC (rev 5148)
@@ -21,6 +21,8 @@
*/
package org.jboss.ws.extensions.wsrm.spi.protocol;
+import javax.xml.datatype.Duration;
+
/**
* <p><b>CreateSequenceResponse</b> element is sent in the body of the response message in response to a <b>CreateSequence</b>
* request message. It indicates that the RM Destination has created a new Sequence at the
@@ -72,13 +74,13 @@
* the corresponding <b>CreateSequence</b> message.
* @param duration
*/
- void setExpires(String duration);
+ void setExpires(Duration duration);
/**
* Getter
* @return sequence duration
*/
- String getExpires();
+ Duration getExpires();
/**
* This element, if present, specifies the behavior that the destination will exhibit upon the closure or
Modified: stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/wsrm/deserialization/RMDeSerializationTestCase.java
===================================================================
--- stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/wsrm/deserialization/RMDeSerializationTestCase.java 2007-11-29 12:35:27 UTC (rev 5147)
+++ stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/wsrm/deserialization/RMDeSerializationTestCase.java 2007-11-29 13:53:45 UTC (rev 5148)
@@ -26,6 +26,7 @@
import javax.xml.soap.SOAPMessage;
+import org.jboss.ws.extensions.wsrm.common.RMHelper;
import org.jboss.ws.extensions.wsrm.spi.RMProvider;
import org.jboss.ws.extensions.wsrm.spi.RMMessageFactory;
import org.jboss.ws.extensions.wsrm.spi.protocol.RMAckRequested;
@@ -363,7 +364,7 @@
createSequenceMessage.deserializeFrom(toSOAPMessage(CREATE_SEQUENCE_MESSAGE));
// perform assertion
assertEquals(createSequenceMessage.getAcksTo(), "http://Business456.com/serviceA/789");
- assertEquals(createSequenceMessage.getExpires(), "PT0S");
+ assertEquals(createSequenceMessage.getExpires(), RMHelper.stringToDuration("PT0S"));
RMCreateSequence.Offer offer = createSequenceMessage.getOffer();
assertEquals(offer.getIdentifier(), "http://Business456.com/RM/ABC");
assertEquals(offer.getEndpoint(), "http://Business456.com/serviceA/ASDF");
@@ -376,7 +377,7 @@
RMCreateSequence createSequenceMessage = WSRM_200702_FACTORY.newCreateSequence();
// construct message
createSequenceMessage.setAcksTo("http://Business456.com/serviceA/789");
- createSequenceMessage.setExpires("PT0S");
+ createSequenceMessage.setExpires(RMHelper.stringToDuration("PT0S"));
RMCreateSequence.Offer offer = createSequenceMessage.newOffer();
offer.setIdentifier("http://Business456.com/RM/ABC");
offer.setEndpoint("http://Business456.com/serviceA/ASDF");
@@ -393,7 +394,7 @@
createSequenceResponseMessage.deserializeFrom(toSOAPMessage(CREATE_SEQUENCE_RESPONSE_MESSAGE));
// perform assertion
assertEquals(createSequenceResponseMessage.getIdentifier(), "http://Business456.com/RM/ABC");
- assertEquals(createSequenceResponseMessage.getExpires(), "PT0S");
+ assertEquals(createSequenceResponseMessage.getExpires(), RMHelper.stringToDuration("PT0S"));
assertEquals(createSequenceResponseMessage.getIncompleteSequenceBehavior(), RMIncompleteSequenceBehavior.DISCARD_FOLLOWING_FIRST_GAP);
RMCreateSequenceResponse.Accept accept = createSequenceResponseMessage.getAccept();
assertEquals(accept.getAcksTo(), "http://Business456.com/serviceA/ASDF");
@@ -404,7 +405,7 @@
RMCreateSequenceResponse createSequenceResponse = WSRM_200702_FACTORY.newCreateSequenceResponse();
// construct message
createSequenceResponse.setIdentifier("http://Business456.com/RM/ABC");
- createSequenceResponse.setExpires("PT0S");
+ createSequenceResponse.setExpires(RMHelper.stringToDuration("PT0S"));
createSequenceResponse.setIncompleteSequenceBehavior(RMIncompleteSequenceBehavior.DISCARD_FOLLOWING_FIRST_GAP);
RMCreateSequenceResponse.Accept accept = createSequenceResponse.newAccept();
accept.setAcksTo("http://Business456.com/serviceA/ASDF");
Modified: stack/native/trunk/src/test/resources/jaxws/wsrm/emulator/common/resources/createSequenceResponse.xml
===================================================================
--- stack/native/trunk/src/test/resources/jaxws/wsrm/emulator/common/resources/createSequenceResponse.xml 2007-11-29 12:35:27 UTC (rev 5147)
+++ stack/native/trunk/src/test/resources/jaxws/wsrm/emulator/common/resources/createSequenceResponse.xml 2007-11-29 13:53:45 UTC (rev 5148)
@@ -10,6 +10,8 @@
<env:Body>
<wsrm11:CreateSequenceResponse>
<wsrm11:Identifier>${res.wsrm.sequenceid}</wsrm11:Identifier>
+ <wsrm11:Expires>PT10S</wsrm11:Expires>
+ <wsrm11:IncompleteSequenceBehavior>DiscardEntireSequence</wsrm11:IncompleteSequenceBehavior>
</wsrm11:CreateSequenceResponse>
</env:Body>
</env:Envelope>
17 years, 3 months
JBossWS SVN: r5147 - legacy/branches/jbossws-1.2.1.GA_CP01_JBPAPP-459/jbossws-core/src/java/org/jboss/ws/tools/wsdl.
by jbossws-commits@lists.jboss.org
Author: mageshbk(a)jboss.com
Date: 2007-11-29 07:35:27 -0500 (Thu, 29 Nov 2007)
New Revision: 5147
Added:
legacy/branches/jbossws-1.2.1.GA_CP01_JBPAPP-459/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLFactoryImpl.java
legacy/branches/jbossws-1.2.1.GA_CP01_JBPAPP-459/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLReaderImpl.java
Modified:
legacy/branches/jbossws-1.2.1.GA_CP01_JBPAPP-459/jbossws-core/src/java/org/jboss/ws/tools/wsdl/WSDLDefinitionsFactory.java
Log:
[JBPAPP-459] Patch for [JBAPP-460 WSDLDefinitionsFactory doesn't resolve schema references locally]
Added: legacy/branches/jbossws-1.2.1.GA_CP01_JBPAPP-459/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLFactoryImpl.java
===================================================================
--- legacy/branches/jbossws-1.2.1.GA_CP01_JBPAPP-459/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLFactoryImpl.java (rev 0)
+++ legacy/branches/jbossws-1.2.1.GA_CP01_JBPAPP-459/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLFactoryImpl.java 2007-11-29 12:35:27 UTC (rev 5147)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.tools.wsdl;
+
+import com.ibm.wsdl.DefinitionImpl;
+import com.ibm.wsdl.extensions.PopulatedExtensionRegistry;
+import com.ibm.wsdl.xml.WSDLWriterImpl;
+
+import javax.wsdl.Definition;
+import javax.wsdl.extensions.ExtensionRegistry;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.wsdl.xml.WSDLWriter;
+
+/**
+ * A fork of the original wsdl4j 1.6.2 package
+ * that delegates to the {@link JBossWSDLReaderImpl}.
+ * <p>
+ * Original author: Matthew J. Duftler (duftler(a)us.ibm.com)
+ *
+ * @version $Revision$
+ */
+public class JBossWSDLFactoryImpl extends WSDLFactory
+{
+ /**
+ * Create a new instance of a Definition, with an instance
+ * of a PopulatedExtensionRegistry as its ExtensionRegistry.
+ *
+ * @see com.ibm.wsdl.extensions.PopulatedExtensionRegistry
+ */
+ public Definition newDefinition()
+ {
+ Definition def = new DefinitionImpl();
+ ExtensionRegistry extReg = newPopulatedExtensionRegistry();
+
+ def.setExtensionRegistry(extReg);
+
+ return def;
+ }
+
+ /**
+ * Create a new instance of a WSDLReader.
+ */
+ public WSDLReader newWSDLReader()
+ {
+ return new JBossWSDLReaderImpl();
+ }
+
+ public WSDLWriter newWSDLWriter()
+ {
+ return new WSDLWriterImpl();
+ }
+
+ /**
+ * Create a new instance of an ExtensionRegistry with pre-registered
+ * serializers/deserializers for the SOAP, HTTP and MIME
+ * extensions. Java extensionTypes are also mapped for all
+ * the SOAP, HTTP and MIME extensions.
+ */
+ public ExtensionRegistry newPopulatedExtensionRegistry()
+ {
+ return new PopulatedExtensionRegistry();
+ }
+}
\ No newline at end of file
Property changes on: legacy/branches/jbossws-1.2.1.GA_CP01_JBPAPP-459/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLFactoryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: legacy/branches/jbossws-1.2.1.GA_CP01_JBPAPP-459/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLReaderImpl.java
===================================================================
--- legacy/branches/jbossws-1.2.1.GA_CP01_JBPAPP-459/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLReaderImpl.java (rev 0)
+++ legacy/branches/jbossws-1.2.1.GA_CP01_JBPAPP-459/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLReaderImpl.java 2007-11-29 12:35:27 UTC (rev 5147)
@@ -0,0 +1,2372 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.tools.wsdl;
+
+import com.ibm.wsdl.Constants;
+import com.ibm.wsdl.extensions.schema.SchemaConstants;
+import com.ibm.wsdl.util.StringUtils;
+import com.ibm.wsdl.util.xml.DOMUtils;
+import com.ibm.wsdl.util.xml.QNameUtils;
+import com.ibm.wsdl.util.xml.XPathUtils;
+import org.jboss.ws.core.utils.JBossWSEntityResolver;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.xml.sax.InputSource;
+
+import javax.wsdl.*;
+import javax.wsdl.extensions.AttributeExtensible;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.ExtensionDeserializer;
+import javax.wsdl.extensions.ExtensionRegistry;
+import javax.wsdl.extensions.schema.Schema;
+import javax.wsdl.extensions.schema.SchemaReference;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLLocator;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.*;
+
+
+/**
+ * A WSDLReader fork of the original wsdl4j 1.6.2 package
+ * that delegates to the JBossWSEntityResolver in
+ * <code>private static Document getDocument(InputSource inputSource,String desc)</code>
+ * <p>
+ * Original authors: Matthew J. Duftler,Nirmal Mukhi
+ *
+ * @version $Revision$
+ */
+public class JBossWSDLReaderImpl implements WSDLReader
+{
+ // Used for determining the style of operations.
+ private static final List STYLE_ONE_WAY =
+ Arrays.asList(new String[]{Constants.ELEM_INPUT});
+ private static final List STYLE_REQUEST_RESPONSE =
+ Arrays.asList(new String[]{Constants.ELEM_INPUT, Constants.ELEM_OUTPUT});
+ private static final List STYLE_SOLICIT_RESPONSE =
+ Arrays.asList(new String[]{Constants.ELEM_OUTPUT, Constants.ELEM_INPUT});
+ private static final List STYLE_NOTIFICATION =
+ Arrays.asList(new String[]{Constants.ELEM_OUTPUT});
+
+ protected boolean verbose = true;
+ protected boolean importDocuments = true;
+ protected ExtensionRegistry extReg = null;
+ protected String factoryImplName = null;
+ protected WSDLLocator loc = null;
+ protected WSDLFactory factory = null;
+
+ //Contains all schemas used by this wsdl, either in-line or nested
+ //via wsdl imports or schema imports, includes or redefines
+ protected Map allSchemas = new Hashtable();
+
+
+ /**
+ * Sets the specified feature to the specified value.
+ * <p>
+ * The supported features are:
+ * <p>
+ * <table border=1>
+ * <tr>
+ * <th>Name</th>
+ * <th>Description</th>
+ * <th>Default Value</th>
+ * </tr>
+ * <tr>
+ * <td><center>javax.wsdl.verbose</center></td>
+ * <td>If set to true, status messages will be displayed.</td>
+ * <td><center>true</center></td>
+ * </tr>
+ * <tr>
+ * <td><center>javax.wsdl.importDocuments</center></td>
+ * <td>If set to true, imported WSDL documents will be
+ * retrieved and processed.</td>
+ * <td><center>true</center></td>
+ * </tr>
+ * </table>
+ * <p>
+ * All feature names must be fully-qualified, Java package style. All
+ * names starting with javax.wsdl. are reserved for features defined
+ * by the JWSDL specification. It is recommended that implementation-
+ * specific features be fully-qualified to match the package name
+ * of that implementation. For example: com.abc.featureName
+ *
+ * @param name the name of the feature to be set.
+ * @param value the value to set the feature to.
+ * @throws IllegalArgumentException if the feature name is not recognized.
+ * @see #getFeature(String)
+ */
+ public void setFeature(String name, boolean value)
+ throws IllegalArgumentException
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("Feature name must not be null.");
+ }
+
+ if (name.equals(Constants.FEATURE_VERBOSE))
+ {
+ verbose = value;
+ }
+ else if (name.equals(Constants.FEATURE_IMPORT_DOCUMENTS))
+ {
+ importDocuments = value;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Feature name '" + name +
+ "' not recognized.");
+ }
+ }
+
+ /**
+ * Gets the value of the specified feature.
+ *
+ * @param name the name of the feature to get the value of.
+ * @return the value of the feature.
+ * @throws IllegalArgumentException if the feature name is not recognized.
+ * @see #setFeature(String, boolean)
+ */
+ public boolean getFeature(String name) throws IllegalArgumentException
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("Feature name must not be null.");
+ }
+
+ if (name.equals(Constants.FEATURE_VERBOSE))
+ {
+ return verbose;
+ }
+ else if (name.equals(Constants.FEATURE_IMPORT_DOCUMENTS))
+ {
+ return importDocuments;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Feature name '" + name +
+ "' not recognized.");
+ }
+ }
+
+ /**
+ * Set the extension registry to be used when reading
+ * WSDL documents into a WSDL definition. If an
+ * extension registry is set, that is the extension
+ * registry that will be set as the extensionRegistry
+ * property of the definitions resulting from invoking
+ * readWSDL(...). Default is null.
+ *
+ * @param extReg the extension registry to use for new
+ * definitions
+ */
+ public void setExtensionRegistry(ExtensionRegistry extReg)
+ {
+ this.extReg = extReg;
+ }
+
+ /**
+ * Get the extension registry, if one was set. Default is
+ * null.
+ */
+ public ExtensionRegistry getExtensionRegistry()
+ {
+ return extReg;
+ }
+
+ /**
+ * Get the WSDLFactory object cached in the reader, or use lazy
+ * instantiation if it is not cached yet.
+ */
+ protected WSDLFactory getWSDLFactory() throws WSDLException
+ {
+ if (factory == null)
+ {
+ factory = (factoryImplName != null)
+ ? WSDLFactory.newInstance(factoryImplName)
+ : WSDLFactory.newInstance();
+ }
+ return factory;
+ }
+
+ /**
+ * Set a different factory implementation to use for
+ * creating definitions when reading WSDL documents.
+ * As some WSDLReader implementations may only be
+ * capable of creating definitions using the same
+ * factory implementation from which the reader was
+ * obtained, this method is optional. Default is null.
+ *
+ * @param factoryImplName the fully-qualified class name of the
+ * class which provides a concrete implementation of the abstract
+ * class WSDLFactory.
+ * @throws UnsupportedOperationException if this method
+ * is invoked on an implementation which does not
+ * support it.
+ */
+ public void setFactoryImplName(String factoryImplName)
+ throws UnsupportedOperationException
+ {
+ //check to see if we really need to change the factory name and clear the cache
+ if((this.factoryImplName == null && factoryImplName != null) ||
+ (this.factoryImplName != null && !this.factoryImplName.equals(factoryImplName)))
+ {
+ //the factory object is cached in the reader so set it
+ //to null if the factory impl name is reset.
+ this.factory = null;
+
+ this.factoryImplName = factoryImplName;
+ //if(verbose) System.out.println("WSDLFactory Impl Name set to : "+factoryImplName);
+ }
+ }
+
+ /**
+ * Get the factoryImplName, if one was set. Default is null.
+ */
+ public String getFactoryImplName()
+ {
+ return factoryImplName;
+ }
+
+ protected Definition parseDefinitions(String documentBaseURI,
+ Element defEl,
+ Map importedDefs)
+ throws WSDLException
+ {
+ checkElementName(defEl, Constants.Q_ELEM_DEFINITIONS);
+
+ WSDLFactory factory = getWSDLFactory();
+ Definition def = factory.newDefinition();
+
+ if (extReg != null)
+ {
+ def.setExtensionRegistry(extReg);
+ }
+
+ String name = DOMUtils.getAttribute(defEl, Constants.ATTR_NAME);
+ String targetNamespace = DOMUtils.getAttribute(defEl,
+ Constants.ATTR_TARGET_NAMESPACE);
+ NamedNodeMap attrs = defEl.getAttributes();
+
+ if (importedDefs == null)
+ {
+ importedDefs = new Hashtable();
+ }
+
+ if (documentBaseURI != null)
+ {
+ def.setDocumentBaseURI(documentBaseURI);
+ importedDefs.put(documentBaseURI, def);
+ }
+
+ if (name != null)
+ {
+ def.setQName(new QName(targetNamespace, name));
+ }
+
+ if (targetNamespace != null)
+ {
+ def.setTargetNamespace(targetNamespace);
+ }
+
+ int size = attrs.getLength();
+
+ for (int i = 0; i < size; i++)
+ {
+ Attr attr = (Attr)attrs.item(i);
+ String namespaceURI = attr.getNamespaceURI();
+ String localPart = attr.getLocalName();
+ String value = attr.getValue();
+
+ if (namespaceURI != null && namespaceURI.equals(Constants.NS_URI_XMLNS))
+ {
+ if (localPart != null && !localPart.equals(Constants.ATTR_XMLNS))
+ {
+ def.addNamespace(localPart, value);
+ }
+ else
+ {
+ def.addNamespace(null, value);
+ }
+ }
+ }
+
+ Element tempEl = DOMUtils.getFirstChildElement(defEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_IMPORT, tempEl))
+ {
+ def.addImport(parseImport(tempEl, def, importedDefs));
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ def.setDocumentationElement(tempEl);
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_TYPES, tempEl))
+ {
+ def.setTypes(parseTypes(tempEl, def));
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_MESSAGE, tempEl))
+ {
+ def.addMessage(parseMessage(tempEl, def));
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_PORT_TYPE, tempEl))
+ {
+ def.addPortType(parsePortType(tempEl, def));
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_BINDING, tempEl))
+ {
+ def.addBinding(parseBinding(tempEl, def));
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_SERVICE, tempEl))
+ {
+ def.addService(parseService(tempEl, def));
+ }
+ else
+ {
+ def.addExtensibilityElement(
+ parseExtensibilityElement(Definition.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(defEl, Definition.class, def, def);
+
+ return def;
+ }
+
+ protected Import parseImport(Element importEl,
+ Definition def,
+ Map importedDefs)
+ throws WSDLException
+ {
+ Import importDef = def.createImport();
+
+ try
+ {
+ String namespaceURI = DOMUtils.getAttribute(importEl,
+ Constants.ATTR_NAMESPACE);
+ String locationURI = DOMUtils.getAttribute(importEl,
+ Constants.ATTR_LOCATION);
+ String contextURI = null;
+
+ if (namespaceURI != null)
+ {
+ importDef.setNamespaceURI(namespaceURI);
+ }
+
+ if (locationURI != null)
+ {
+ importDef.setLocationURI(locationURI);
+
+ if (importDocuments)
+ {
+ try
+ {
+ contextURI = def.getDocumentBaseURI();
+ Definition importedDef = null;
+ InputStream inputStream = null;
+ InputSource inputSource = null;
+ URL url = null;
+
+ if (loc != null)
+ {
+ inputSource = loc.getImportInputSource(contextURI, locationURI);
+
+ /*
+ We now have available the latest import URI. This might
+ differ from the locationURI so check the importedDefs for it
+ since it is this that we pass as the documentBaseURI later.
+ */
+ String liu = loc.getLatestImportURI();
+
+ importedDef = (Definition)importedDefs.get(liu);
+
+ inputSource.setSystemId(liu);
+ }
+ else
+ {
+ URL contextURL = (contextURI != null)
+ ? StringUtils.getURL(null, contextURI)
+ : null;
+
+ url = StringUtils.getURL(contextURL, locationURI);
+ importedDef = (Definition)importedDefs.get(url.toString());
+
+ if (importedDef == null)
+ {
+ inputStream = StringUtils.getContentAsInputStream(url);
+
+ if (inputStream != null)
+ {
+ inputSource = new InputSource(inputStream);
+ inputSource.setSystemId(url.toString());
+ }
+ }
+ }
+
+ if (importedDef == null)
+ {
+ if (inputSource == null)
+ {
+ throw new WSDLException(WSDLException.OTHER_ERROR,
+ "Unable to locate imported document " +
+ "at '" + locationURI + "'" +
+ (contextURI == null
+ ? "."
+ : ", relative to '" + contextURI +
+ "'."));
+ }
+
+ Document doc = getDocument(inputSource, inputSource.getSystemId());
+
+ if (inputStream != null)
+ {
+ inputStream.close();
+ }
+
+ Element documentElement = doc.getDocumentElement();
+
+ /*
+ Check if it's a wsdl document.
+ If it's not, don't retrieve and process it.
+ This should later be extended to allow other types of
+ documents to be retrieved and processed, such as schema
+ documents (".xsd"), etc...
+ */
+ if (QNameUtils.matches(Constants.Q_ELEM_DEFINITIONS,
+ documentElement))
+ {
+ if (verbose)
+ {
+ System.out.println("Retrieving document at '" + locationURI +
+ "'" +
+ (contextURI == null
+ ? "."
+ : ", relative to '" + contextURI + "'."));
+ }
+
+ String urlString =
+ (loc != null)
+ ? loc.getLatestImportURI()
+ : (url != null)
+ ? url.toString()
+ : locationURI;
+
+ importedDef = readWSDL(urlString,
+ documentElement,
+ importedDefs);
+ }
+ else
+ {
+ QName docElementQName = QNameUtils.newQName(documentElement);
+
+ if (SchemaConstants.XSD_QNAME_LIST.contains(docElementQName))
+ {
+ if (verbose)
+ {
+ System.out.println("Retrieving schema wsdl:imported from '" + locationURI +
+ "'" +
+ (contextURI == null
+ ? "."
+ : ", relative to '" + contextURI + "'."));
+ }
+
+ WSDLFactory factory = getWSDLFactory();
+
+ importedDef = factory.newDefinition();
+
+ if (extReg != null)
+ {
+ importedDef.setExtensionRegistry(extReg);
+ }
+
+ String urlString =
+ (loc != null)
+ ? loc.getLatestImportURI()
+ : (url != null)
+ ? url.toString()
+ : locationURI;
+
+ importedDef.setDocumentBaseURI(urlString);
+
+ Types types = importedDef.createTypes();
+ types.addExtensibilityElement(
+ parseSchema(Types.class, documentElement, importedDef));
+ importedDef.setTypes(types);
+ }
+ }
+ }
+
+ if (importedDef != null)
+ {
+ importDef.setDefinition(importedDef);
+ }
+ }
+ catch (WSDLException e)
+ {
+ throw e;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new WSDLException(WSDLException.OTHER_ERROR,
+ "Unable to resolve imported document at '" +
+ locationURI +
+ (contextURI == null
+ ? "'." : "', relative to '" + contextURI + "'")
+ , e);
+ }
+ } //end importDocs
+ } //end locationURI
+
+ }
+ catch (WSDLException e)
+ {
+ if (e.getLocation() == null)
+ {
+ e.setLocation(XPathUtils.getXPathExprFromNode(importEl));
+ }
+ else
+ {
+ //If definitions are being parsed recursively for nested imports
+ //the exception location must be built up recursively too so
+ //prepend this element's xpath to exception location.
+ String loc = XPathUtils.getXPathExprFromNode(importEl) + e.getLocation();
+ e.setLocation(loc);
+ }
+
+ throw e;
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = importEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(importEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ importDef.setDocumentationElement(tempEl);
+ }
+ else
+ {
+ importDef.addExtensibilityElement(
+ parseExtensibilityElement(Import.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(importEl, Import.class, importDef, def);
+
+ return importDef;
+
+ }
+
+ protected Types parseTypes(Element typesEl, Definition def)
+ throws WSDLException
+ {
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = typesEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Types types = def.createTypes();
+ Element tempEl = DOMUtils.getFirstChildElement(typesEl);
+ QName tempElType;
+
+ while (tempEl != null)
+ {
+ tempElType = QNameUtils.newQName(tempEl);
+
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ types.setDocumentationElement(tempEl);
+ }
+ else if ((SchemaConstants.XSD_QNAME_LIST).contains(tempElType))
+ {
+ //the element qname indicates it is a schema.
+ types.addExtensibilityElement(
+ parseSchema(Types.class, tempEl, def));
+ }
+ else
+ {
+ types.addExtensibilityElement(
+ parseExtensibilityElement(Types.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(typesEl, Types.class, types, def);
+
+ return types;
+ }
+
+ protected ExtensibilityElement parseSchema( Class parentType,
+ Element el,
+ Definition def)
+ throws WSDLException
+ {
+ QName elementType = null;
+ ExtensionRegistry extReg = null;
+
+ try
+ {
+ extReg = def.getExtensionRegistry();
+
+ if (extReg == null)
+ {
+ throw new WSDLException(WSDLException.CONFIGURATION_ERROR,
+ "No ExtensionRegistry set for this " +
+ "Definition, so unable to deserialize " +
+ "a '" + elementType + "' element in the " +
+ "context of a '" + parentType.getName() +
+ "'.");
+ }
+
+ return parseSchema(parentType, el, def, extReg);
+ }
+ catch (WSDLException e)
+ {
+ if (e.getLocation() == null)
+ {
+ e.setLocation(XPathUtils.getXPathExprFromNode(el));
+ }
+
+ throw e;
+ }
+ }
+
+
+ protected ExtensibilityElement parseSchema( Class parentType,
+ Element el,
+ Definition def,
+ ExtensionRegistry extReg)
+ throws WSDLException
+ {
+ /*
+ * This method returns ExtensibilityElement rather than Schema because we
+ * do not insist that a suitable XSD schema deserializer is registered.
+ * PopulatedExtensionRegistry registers SchemaDeserializer by default, but
+ * if the user chooses not to register a suitable deserializer then the
+ * UnknownDeserializer will be used, returning an UnknownExtensibilityElement.
+ */
+
+ Schema schema = null;
+ SchemaReference schemaRef = null;
+ try
+ {
+
+ QName elementType = QNameUtils.newQName(el);
+
+ ExtensionDeserializer exDS =
+ extReg.queryDeserializer(parentType, elementType);
+
+ //Now unmarshall the DOM element.
+ ExtensibilityElement ee =
+ exDS.unmarshall(parentType, elementType, el, def, extReg);
+
+ if (ee instanceof Schema)
+ {
+ schema = (Schema) ee;
+ }
+ else
+ {
+ //Unknown extensibility element, so don't do any more schema parsing on it.
+ return ee;
+ }
+
+
+ //Keep track of parsed schemas to avoid duplicating Schema objects
+ //through duplicate or circular references (eg: A imports B imports A).
+ if (schema.getDocumentBaseURI() != null)
+ {
+ this.allSchemas.put(schema.getDocumentBaseURI(), schema);
+ }
+
+ //At this point, any SchemaReference objects held by the schema will not
+ //yet point to their referenced schemas, so we must now retrieve these
+ //schemas and set the schema references.
+
+ //First, combine the schema references for imports, includes and redefines
+ //into a single list
+
+ ArrayList allSchemaRefs = new ArrayList();
+
+ Collection ic = schema.getImports().values();
+ Iterator importsIterator = ic.iterator();
+ while(importsIterator.hasNext())
+ {
+ allSchemaRefs.addAll( (Collection) importsIterator.next() );
+ }
+
+ allSchemaRefs.addAll(schema.getIncludes());
+ allSchemaRefs.addAll(schema.getRedefines());
+
+ //Then, retrieve the schema referred to by each schema reference. If the
+ //schema has been read in previously, use the existing schema object.
+ //Otherwise unmarshall the DOM element into a new schema object.
+
+ ListIterator schemaRefIterator = allSchemaRefs.listIterator();
+
+ while(schemaRefIterator.hasNext())
+ {
+ try
+ {
+ schemaRef = (SchemaReference) schemaRefIterator.next();
+
+ if (schemaRef.getSchemaLocationURI() == null)
+ {
+ //cannot get the referenced schema, so ignore this schema reference
+ continue;
+ }
+
+ if (verbose)
+ {
+ System.out.println("Retrieving schema at '" +
+ schemaRef.getSchemaLocationURI() +
+ (schema.getDocumentBaseURI() == null
+ ? "'."
+ : "', relative to '" +
+ schema.getDocumentBaseURI() + "'."));
+ }
+
+
+ InputStream inputStream = null;
+ InputSource inputSource = null;
+
+ //This is the child schema referred to by the schemaReference
+ Schema referencedSchema = null;
+
+ //This is the child schema's location obtained from the WSDLLocator or the URL
+ String location = null;
+
+ if (loc != null)
+ {
+ //Try to get the referenced schema using the wsdl locator
+ inputSource = loc.getImportInputSource(
+ schema.getDocumentBaseURI(), schemaRef.getSchemaLocationURI());
+
+ if (inputSource == null)
+ {
+ throw new WSDLException(WSDLException.OTHER_ERROR,
+ "Unable to locate with a locator "
+ + "the schema referenced at '"
+ + schemaRef.getSchemaLocationURI()
+ + "' relative to document base '"
+ + schema.getDocumentBaseURI() + "'");
+ }
+ location = loc.getLatestImportURI();
+
+ //if a schema from this location has been read previously, use it.
+ referencedSchema = (Schema) this.allSchemas.get(location);
+ }
+ else
+ {
+ // We don't have a wsdl locator, so try to retrieve the schema by its URL
+ String contextURI = schema.getDocumentBaseURI();
+ URL contextURL = (contextURI != null) ? StringUtils.getURL(null, contextURI) : null;
+ URL url = StringUtils.getURL(contextURL, schemaRef.getSchemaLocationURI());
+ location = url.toExternalForm();
+
+ //if a schema from this location has been retrieved previously, use it.
+ referencedSchema = (Schema) this.allSchemas.get(location);
+
+ if (referencedSchema == null)
+ {
+ // We haven't read this schema in before so do it now
+ inputStream = StringUtils.getContentAsInputStream(url);
+
+ if (inputStream != null)
+ {
+ inputSource = new InputSource(inputStream);
+ }
+
+ if (inputSource == null)
+ {
+ throw new WSDLException(WSDLException.OTHER_ERROR,
+ "Unable to locate with a url "
+ + "the document referenced at '"
+ + schemaRef.getSchemaLocationURI()
+ + "'"
+ + (contextURI == null ? "." : ", relative to '"
+ + contextURI + "'."));
+ }
+ }
+
+ } //end if loc
+
+ // If we have not previously read the schema, get its DOM element now.
+ if (referencedSchema == null)
+ {
+ inputSource.setSystemId(location);
+ Document doc = getDocument(inputSource, location);
+
+ if (inputStream != null)
+ {
+ inputStream.close();
+ }
+
+ Element documentElement = doc.getDocumentElement();
+
+ // If it's a schema doc process it, otherwise the schema reference remains null
+
+ QName docElementQName = QNameUtils.newQName(documentElement);
+
+ if (SchemaConstants.XSD_QNAME_LIST.contains(docElementQName))
+ {
+ //We now need to call parseSchema recursively to parse the referenced
+ //schema. The document base URI of the referenced schema will be set to
+ //the document base URI of the current schema plus the schemaLocation in
+ //the schemaRef. We cannot explicitly pass in a new document base URI
+ //to the schema deserializer, so instead we will create a dummy
+ //Definition and set its documentBaseURI to the new document base URI.
+ //We can leave the other definition fields empty because we know
+ //that the SchemaDeserializer.unmarshall method uses the definition
+ //parameter only to get its documentBaseURI. If the unmarshall method
+ //implementation changes (ie: its use of definition changes) we may need
+ //to rethink this approach.
+
+ WSDLFactory factory = getWSDLFactory();
+ Definition dummyDef = factory.newDefinition();
+
+ dummyDef.setDocumentBaseURI(location);
+
+ //By this point, we know we have a SchemaDeserializer registered
+ //so we can safely cast the ExtensibilityElement to a Schema.
+ referencedSchema = (Schema) parseSchema( parentType,
+ documentElement,
+ dummyDef,
+ extReg);
+ }
+
+ } //end if referencedSchema
+
+ schemaRef.setReferencedSchema(referencedSchema);
+ }
+ catch (WSDLException e)
+ {
+ throw e;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new WSDLException(WSDLException.OTHER_ERROR,
+ "An error occurred trying to resolve schema referenced at '"
+ + schemaRef.getSchemaLocationURI()
+ + "'"
+ + (schema.getDocumentBaseURI() == null ? "." : ", relative to '"
+ + schema.getDocumentBaseURI() + "'."),
+ e);
+ }
+
+ } //end while loop
+
+ return schema;
+
+ }
+ catch (WSDLException e)
+ {
+ if (e.getLocation() == null)
+ {
+ e.setLocation(XPathUtils.getXPathExprFromNode(el));
+ }
+ else
+ {
+ //If this method has been called recursively for nested schemas
+ //the exception location must be built up recursively too so
+ //prepend this element's xpath to exception location.
+ String loc = XPathUtils.getXPathExprFromNode(el) + e.getLocation();
+ e.setLocation(loc);
+ }
+
+ throw e;
+ }
+
+ }
+
+
+ protected Binding parseBinding(Element bindingEl, Definition def)
+ throws WSDLException
+ {
+ Binding binding = null;
+
+ List remainingAttrs = DOMUtils.getAttributes(bindingEl);
+ String name = DOMUtils.getAttribute(bindingEl, Constants.ATTR_NAME, remainingAttrs);
+ QName portTypeName = getQualifiedAttributeValue(bindingEl,
+ Constants.ATTR_TYPE,
+ Constants.ELEM_BINDING,
+ def,
+ remainingAttrs);
+
+ PortType portType = null;
+
+ if (name != null)
+ {
+ QName bindingName = new QName(def.getTargetNamespace(), name);
+
+ binding = def.getBinding(bindingName);
+
+ if (binding == null)
+ {
+ binding = def.createBinding();
+ binding.setQName(bindingName);
+ }
+ }
+ else
+ {
+ binding = def.createBinding();
+ }
+
+ // Whether it was retrieved or created, the definition has been found.
+ binding.setUndefined(false);
+
+ if (portTypeName != null)
+ {
+ portType = def.getPortType(portTypeName);
+
+ if (portType == null)
+ {
+ portType = def.createPortType();
+ portType.setQName(portTypeName);
+ def.addPortType(portType);
+ }
+
+ binding.setPortType(portType);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = bindingEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(bindingEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ binding.setDocumentationElement(tempEl);
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_OPERATION, tempEl))
+ {
+ binding.addBindingOperation(parseBindingOperation(tempEl,
+ portType,
+ def));
+ }
+ else
+ {
+ binding.addExtensibilityElement(parseExtensibilityElement(
+ Binding.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ return binding;
+ }
+
+ protected BindingOperation parseBindingOperation(
+ Element bindingOperationEl,
+ PortType portType,
+ Definition def)
+ throws WSDLException
+ {
+ BindingOperation bindingOperation = def.createBindingOperation();
+
+ List remainingAttrs = DOMUtils.getAttributes(bindingOperationEl);
+ String name = DOMUtils.getAttribute(bindingOperationEl,
+ Constants.ATTR_NAME,
+ remainingAttrs);
+
+ if (name != null)
+ {
+ bindingOperation.setName(name);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = bindingOperationEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(bindingOperationEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ bindingOperation.setDocumentationElement(tempEl);
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_INPUT, tempEl))
+ {
+ bindingOperation.setBindingInput(parseBindingInput(tempEl, def));
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_OUTPUT, tempEl))
+ {
+ bindingOperation.setBindingOutput(parseBindingOutput(tempEl, def));
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_FAULT, tempEl))
+ {
+ bindingOperation.addBindingFault(parseBindingFault(tempEl, def));
+ }
+ else
+ {
+ bindingOperation.addExtensibilityElement(
+ parseExtensibilityElement(BindingOperation.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ if (portType != null)
+ {
+ BindingInput bindingInput = bindingOperation.getBindingInput();
+ BindingOutput bindingOutput = bindingOperation.getBindingOutput();
+ String inputName = (bindingInput != null
+ ? (bindingInput.getName() != null ? bindingInput.getName() : Constants.NONE)
+ : null);
+ String outputName = (bindingOutput != null
+ ? (bindingOutput.getName() != null ? bindingOutput.getName() : Constants.NONE)
+ : null);
+ Operation op = portType.getOperation(name, inputName, outputName);
+
+ /*
+ * If the bindingOp input or output message names are null we will search first
+ * for a porttypeOp with corresponding unnamed input or output messages (using
+ * Constants.NONE for inputName or outputName, as above).
+ * However, input and output message names need not be used at all if operation
+ * overloading is not used, so if no match was found we will try again ignoring
+ * these unnamed messages from the search criteria (i.e. using null instead of
+ * Constants.NONE for inputName or outputName).
+ */
+
+ if(op == null)
+ {
+ if(Constants.NONE.equals(inputName) && Constants.NONE.equals(outputName))
+ {
+ //There was no porttype op with unnamed input and output messages,
+ //so ignore input and output name and search on the op name only.
+ op = portType.getOperation(name, null, null);
+ }
+ else if(Constants.NONE.equals(inputName))
+ {
+ //There was no porttype op with an unnamed input message,
+ //so ignore input name and search on the op name and output name only.
+ op = portType.getOperation(name, null, outputName);
+ }
+ else if(Constants.NONE.equals(outputName))
+ {
+ //There was no porttype op with an unnamed output message,
+ //so ignore output name and search on the op name and input name only.
+ op = portType.getOperation(name, inputName, null);
+ }
+ }
+
+ if (op == null)
+ {
+ Input input = def.createInput();
+ Output output = def.createOutput();
+
+ op = def.createOperation();
+ op.setName(name);
+ input.setName(inputName);
+ output.setName(outputName);
+ op.setInput(input);
+ op.setOutput(output);
+ portType.addOperation(op);
+ }
+
+ bindingOperation.setOperation(op);
+ }
+
+ parseExtensibilityAttributes(bindingOperationEl, BindingOperation.class, bindingOperation, def);
+
+ return bindingOperation;
+ }
+
+ protected BindingInput parseBindingInput(Element bindingInputEl,
+ Definition def)
+ throws WSDLException
+ {
+ BindingInput bindingInput = def.createBindingInput();
+
+ List remainingAttrs = DOMUtils.getAttributes(bindingInputEl);
+ String name = DOMUtils.getAttribute(bindingInputEl,
+ Constants.ATTR_NAME,
+ remainingAttrs);
+
+ if (name != null)
+ {
+ bindingInput.setName(name);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = bindingInputEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(bindingInputEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ bindingInput.setDocumentationElement(tempEl);
+ }
+ else
+ {
+ bindingInput.addExtensibilityElement(
+ parseExtensibilityElement(BindingInput.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ return bindingInput;
+ }
+
+ protected BindingOutput parseBindingOutput(Element bindingOutputEl,
+ Definition def)
+ throws WSDLException
+ {
+ BindingOutput bindingOutput = def.createBindingOutput();
+
+ List remainingAttrs = DOMUtils.getAttributes(bindingOutputEl);
+ String name = DOMUtils.getAttribute(bindingOutputEl,
+ Constants.ATTR_NAME,
+ remainingAttrs);
+
+ if (name != null)
+ {
+ bindingOutput.setName(name);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = bindingOutputEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(bindingOutputEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ bindingOutput.setDocumentationElement(tempEl);
+ }
+ else
+ {
+ bindingOutput.addExtensibilityElement(
+ parseExtensibilityElement(BindingOutput.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ return bindingOutput;
+ }
+
+ protected BindingFault parseBindingFault(Element bindingFaultEl,
+ Definition def)
+ throws WSDLException
+ {
+ BindingFault bindingFault = def.createBindingFault();
+
+ List remainingAttrs = DOMUtils.getAttributes(bindingFaultEl);
+ String name = DOMUtils.getAttribute(bindingFaultEl,
+ Constants.ATTR_NAME,
+ remainingAttrs);
+
+ if (name != null)
+ {
+ bindingFault.setName(name);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = bindingFaultEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(bindingFaultEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ bindingFault.setDocumentationElement(tempEl);
+ }
+ else
+ {
+ bindingFault.addExtensibilityElement(
+ parseExtensibilityElement(BindingFault.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(bindingFaultEl, BindingFault.class, bindingFault, def);
+
+ return bindingFault;
+ }
+
+ protected Message parseMessage(Element msgEl, Definition def)
+ throws WSDLException
+ {
+ Message msg = null;
+
+ List remainingAttrs = DOMUtils.getAttributes(msgEl);
+ String name = DOMUtils.getAttribute(msgEl, Constants.ATTR_NAME, remainingAttrs);
+
+ if (name != null)
+ {
+ QName messageName = new QName(def.getTargetNamespace(), name);
+
+ msg = def.getMessage(messageName);
+
+ if (msg == null)
+ {
+ msg = def.createMessage();
+ msg.setQName(messageName);
+ }
+ }
+ else
+ {
+ msg = def.createMessage();
+ }
+
+ // Whether it was retrieved or created, the definition has been found.
+ msg.setUndefined(false);
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = msgEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(msgEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ msg.setDocumentationElement(tempEl);
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_PART, tempEl))
+ {
+ msg.addPart(parsePart(tempEl, def));
+ }
+ else
+ {
+ msg.addExtensibilityElement(
+ parseExtensibilityElement(Message.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(msgEl, Message.class, msg, def);
+
+ return msg;
+ }
+
+ protected Part parsePart(Element partEl, Definition def)
+ throws WSDLException
+ {
+ Part part = def.createPart();
+ String name = DOMUtils.getAttribute(partEl, Constants.ATTR_NAME);
+ QName elementName = getQualifiedAttributeValue(partEl,
+ Constants.ATTR_ELEMENT,
+ Constants.ELEM_MESSAGE,
+ def);
+ QName typeName = getQualifiedAttributeValue(partEl,
+ Constants.ATTR_TYPE,
+ Constants.ELEM_MESSAGE,
+ def);
+
+ if (name != null)
+ {
+ part.setName(name);
+ }
+
+ if (elementName != null)
+ {
+ part.setElementName(elementName);
+ }
+
+ if (typeName != null)
+ {
+ part.setTypeName(typeName);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = partEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(partEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ part.setDocumentationElement(tempEl);
+ }
+ else
+ {
+ part.addExtensibilityElement(
+ parseExtensibilityElement(Part.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(partEl, Part.class, part, def);
+
+ return part;
+ }
+
+ protected void parseExtensibilityAttributes(Element el,
+ Class parentType,
+ AttributeExtensible attrExt,
+ Definition def)
+ throws WSDLException
+ {
+ List nativeAttributeNames = attrExt.getNativeAttributeNames();
+ NamedNodeMap nodeMap = el.getAttributes();
+ int length = nodeMap.getLength();
+
+ for (int i = 0; i < length; i++)
+ {
+ Attr attribute = (Attr)nodeMap.item(i);
+ String localName = attribute.getLocalName();
+ String namespaceURI = attribute.getNamespaceURI();
+ String prefix = attribute.getPrefix();
+ QName qname = new QName(namespaceURI, localName);
+
+ if (namespaceURI != null && !namespaceURI.equals(Constants.NS_URI_WSDL))
+ {
+ if (!namespaceURI.equals(Constants.NS_URI_XMLNS))
+ {
+ DOMUtils.registerUniquePrefix(prefix, namespaceURI, def);
+
+ String strValue = attribute.getValue();
+ int attrType = AttributeExtensible.NO_DECLARED_TYPE;
+ ExtensionRegistry extReg = def.getExtensionRegistry();
+
+ if (extReg != null)
+ {
+ attrType = extReg.queryExtensionAttributeType(parentType, qname);
+ }
+
+ Object val = parseExtensibilityAttribute(el, attrType, strValue, def);
+
+ attrExt.setExtensionAttribute(qname, val);
+ }
+ }
+ else if (!nativeAttributeNames.contains(localName))
+ {
+ WSDLException wsdlExc = new WSDLException(WSDLException.INVALID_WSDL,
+ "Encountered illegal " +
+ "extension attribute '" +
+ qname + "'. Extension " +
+ "attributes must be in " +
+ "a namespace other than " +
+ "WSDL's.");
+
+ wsdlExc.setLocation(XPathUtils.getXPathExprFromNode(el));
+
+ throw wsdlExc;
+ }
+ }
+ }
+
+ protected Object parseExtensibilityAttribute(Element el,
+ int attrType,
+ String attrValue,
+ Definition def)
+ throws WSDLException
+ {
+ if (attrType == AttributeExtensible.QNAME_TYPE)
+ {
+ return DOMUtils.getQName(attrValue, el, def);
+ }
+ else if (attrType == AttributeExtensible.LIST_OF_STRINGS_TYPE)
+ {
+ return StringUtils.parseNMTokens(attrValue);
+ }
+ else if (attrType == AttributeExtensible.LIST_OF_QNAMES_TYPE)
+ {
+ List oldList = StringUtils.parseNMTokens(attrValue);
+ int size = oldList.size();
+ List newList = new Vector(size);
+
+ for (int i = 0; i < size; i++)
+ {
+ String str = (String)oldList.get(i);
+ QName qValue = DOMUtils.getQName(str, el, def);
+
+ newList.add(qValue);
+ }
+
+ return newList;
+ }
+ else if (attrType == AttributeExtensible.STRING_TYPE)
+ {
+ return attrValue;
+ }
+ else
+ {
+ QName qValue = null;
+
+ try
+ {
+ qValue = DOMUtils.getQName(attrValue, el, def);
+ }
+ catch (WSDLException e)
+ {
+ qValue = new QName(attrValue);
+ }
+
+ return qValue;
+ }
+ }
+
+ protected PortType parsePortType(Element portTypeEl, Definition def)
+ throws WSDLException
+ {
+ PortType portType = null;
+ String name = DOMUtils.getAttribute(portTypeEl, Constants.ATTR_NAME);
+
+ if (name != null)
+ {
+ QName portTypeName = new QName(def.getTargetNamespace(), name);
+
+ portType = def.getPortType(portTypeName);
+
+ if (portType == null)
+ {
+ portType = def.createPortType();
+ portType.setQName(portTypeName);
+ }
+ }
+ else
+ {
+ portType = def.createPortType();
+ }
+
+ // Whether it was retrieved or created, the definition has been found.
+ portType.setUndefined(false);
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = portTypeEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(portTypeEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ portType.setDocumentationElement(tempEl);
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_OPERATION, tempEl))
+ {
+ Operation op = parseOperation(tempEl, portType, def);
+
+ if (op != null)
+ {
+ portType.addOperation(op);
+ }
+ }
+ else
+ {
+ portType.addExtensibilityElement(
+ parseExtensibilityElement(PortType.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(portTypeEl, PortType.class, portType, def);
+
+ return portType;
+ }
+
+ protected Operation parseOperation(Element opEl,
+ PortType portType,
+ Definition def)
+ throws WSDLException
+ {
+ Operation op = null;
+
+ List remainingAttrs = DOMUtils.getAttributes(opEl);
+ String name = DOMUtils.getAttribute(opEl, Constants.ATTR_NAME, remainingAttrs);
+ String parameterOrderStr = DOMUtils.getAttribute(opEl,
+ Constants.ATTR_PARAMETER_ORDER,
+ remainingAttrs);
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = opEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(opEl);
+ List messageOrder = new Vector();
+ Element docEl = null;
+ Input input = null;
+ Output output = null;
+ List faults = new Vector();
+ List extElements = new Vector();
+ boolean retrieved = true;
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ docEl = tempEl;
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_INPUT, tempEl))
+ {
+ input = parseInput(tempEl, def);
+ messageOrder.add(Constants.ELEM_INPUT);
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_OUTPUT, tempEl))
+ {
+ output = parseOutput(tempEl, def);
+ messageOrder.add(Constants.ELEM_OUTPUT);
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_FAULT, tempEl))
+ {
+ faults.add(parseFault(tempEl, def));
+ }
+ else
+ {
+ extElements.add(
+ parseExtensibilityElement(Operation.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ if (name != null)
+ {
+ String inputName = (input != null
+ ? (input.getName() != null ? input.getName() : Constants.NONE)
+ : null);
+ String outputName = (output != null
+ ? (output.getName() != null ? output.getName() : Constants.NONE)
+ : null);
+
+ op = portType.getOperation(name, inputName, outputName);
+
+ if (op != null && !op.isUndefined())
+ {
+ op = null;
+ }
+
+ if (op != null)
+ {
+ if (inputName == null)
+ {
+ Input tempIn = op.getInput();
+
+ if (tempIn != null)
+ {
+ if (tempIn.getName() != null)
+ {
+ op = null;
+ }
+ }
+ }
+ }
+
+ if (op != null)
+ {
+ if (outputName == null)
+ {
+ Output tempOut = op.getOutput();
+
+ if (tempOut != null)
+ {
+ if (tempOut.getName() != null)
+ {
+ op = null;
+ }
+ }
+ }
+ }
+
+ if (op == null)
+ {
+ op = def.createOperation();
+ op.setName(name);
+ retrieved = false;
+ }
+ }
+ else
+ {
+ op = def.createOperation();
+ retrieved = false;
+ }
+
+ // Whether it was retrieved or created, the definition has been found.
+ op.setUndefined(false);
+
+ if (parameterOrderStr != null)
+ {
+ op.setParameterOrdering(StringUtils.parseNMTokens(parameterOrderStr));
+ }
+
+ if (docEl != null)
+ {
+ op.setDocumentationElement(docEl);
+ }
+
+ if (input != null)
+ {
+ op.setInput(input);
+ }
+
+ if (output != null)
+ {
+ op.setOutput(output);
+ }
+
+ if (faults.size() > 0)
+ {
+ Iterator faultIterator = faults.iterator();
+
+ while (faultIterator.hasNext())
+ {
+ op.addFault((Fault)faultIterator.next());
+ }
+ }
+
+ if (extElements.size() > 0)
+ {
+ Iterator eeIterator = extElements.iterator();
+
+ while (eeIterator.hasNext())
+ {
+ op.addExtensibilityElement(
+ (ExtensibilityElement) eeIterator.next() );
+ }
+ }
+
+ OperationType style = null;
+
+ if (messageOrder.equals(STYLE_ONE_WAY))
+ {
+ style = OperationType.ONE_WAY;
+ }
+ else if (messageOrder.equals(STYLE_REQUEST_RESPONSE))
+ {
+ style = OperationType.REQUEST_RESPONSE;
+ }
+ else if (messageOrder.equals(STYLE_SOLICIT_RESPONSE))
+ {
+ style = OperationType.SOLICIT_RESPONSE;
+ }
+ else if (messageOrder.equals(STYLE_NOTIFICATION))
+ {
+ style = OperationType.NOTIFICATION;
+ }
+
+ if (style != null)
+ {
+ op.setStyle(style);
+ }
+
+ if (retrieved)
+ {
+ op = null;
+ }
+
+ parseExtensibilityAttributes(opEl, Operation.class, op, def);
+
+ return op;
+ }
+
+ protected Service parseService(Element serviceEl, Definition def)
+ throws WSDLException
+ {
+ Service service = def.createService();
+
+ List remainingAttrs = DOMUtils.getAttributes(serviceEl);
+ String name = DOMUtils.getAttribute(serviceEl, Constants.ATTR_NAME, remainingAttrs);
+
+ if (name != null)
+ {
+ service.setQName(new QName(def.getTargetNamespace(), name));
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = serviceEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(serviceEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ service.setDocumentationElement(tempEl);
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_PORT, tempEl))
+ {
+ service.addPort(parsePort(tempEl, def));
+ }
+ else
+ {
+ service.addExtensibilityElement(
+ parseExtensibilityElement(Service.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(serviceEl, Service.class, service, def);
+
+ return service;
+ }
+
+ protected Port parsePort(Element portEl, Definition def)
+ throws WSDLException
+ {
+ Port port = def.createPort();
+
+ List remainingAttrs = DOMUtils.getAttributes(portEl);
+ String name = DOMUtils.getAttribute(portEl, Constants.ATTR_NAME, remainingAttrs);
+ QName bindingStr = getQualifiedAttributeValue(portEl,
+ Constants.ATTR_BINDING,
+ Constants.ELEM_PORT,
+ def,
+ remainingAttrs);
+
+ if (name != null)
+ {
+ port.setName(name);
+ }
+
+ if (bindingStr != null)
+ {
+ Binding binding = def.getBinding(bindingStr);
+
+ if (binding == null)
+ {
+ binding = def.createBinding();
+ binding.setQName(bindingStr);
+ def.addBinding(binding);
+ }
+
+ port.setBinding(binding);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = portEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(portEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ port.setDocumentationElement(tempEl);
+ }
+ else
+ {
+ port.addExtensibilityElement(parseExtensibilityElement(Port.class,
+ tempEl,
+ def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(portEl, Port.class, port, def);
+
+ return port;
+ }
+
+ protected ExtensibilityElement parseExtensibilityElement(
+ Class parentType,
+ Element el,
+ Definition def)
+ throws WSDLException
+ {
+ QName elementType = QNameUtils.newQName(el);
+
+ String namespaceURI = el.getNamespaceURI();
+
+ try
+ {
+ if (namespaceURI == null || namespaceURI.equals(Constants.NS_URI_WSDL))
+ {
+ throw new WSDLException(WSDLException.INVALID_WSDL,
+ "Encountered illegal extension element '" +
+ elementType +
+ "' in the context of a '" +
+ parentType.getName() +
+ "'. Extension elements must be in " +
+ "a namespace other than WSDL's.");
+ }
+
+ ExtensionRegistry extReg = def.getExtensionRegistry();
+
+ if (extReg == null)
+ {
+ throw new WSDLException(WSDLException.CONFIGURATION_ERROR,
+ "No ExtensionRegistry set for this " +
+ "Definition, so unable to deserialize " +
+ "a '" + elementType + "' element in the " +
+ "context of a '" + parentType.getName() +
+ "'.");
+ }
+
+ ExtensionDeserializer extDS = extReg.queryDeserializer(parentType,
+ elementType);
+
+ return extDS.unmarshall(parentType, elementType, el, def, extReg);
+ }
+ catch (WSDLException e)
+ {
+ if (e.getLocation() == null)
+ {
+ e.setLocation(XPathUtils.getXPathExprFromNode(el));
+ }
+
+ throw e;
+ }
+ }
+
+ protected Input parseInput(Element inputEl, Definition def)
+ throws WSDLException
+ {
+ Input input = def.createInput();
+ String name = DOMUtils.getAttribute(inputEl, Constants.ATTR_NAME);
+ QName messageName = getQualifiedAttributeValue(inputEl,
+ Constants.ATTR_MESSAGE,
+ Constants.ELEM_INPUT,
+ def);
+
+ if (name != null)
+ {
+ input.setName(name);
+ }
+
+ if (messageName != null)
+ {
+ Message message = def.getMessage(messageName);
+
+ if (message == null)
+ {
+ message = def.createMessage();
+ message.setQName(messageName);
+ def.addMessage(message);
+ }
+
+ input.setMessage(message);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = inputEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(inputEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ input.setDocumentationElement(tempEl);
+ }
+ else
+ {
+ input.addExtensibilityElement(
+ parseExtensibilityElement(Input.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(inputEl, Input.class, input, def);
+
+ return input;
+ }
+
+ protected Output parseOutput(Element outputEl, Definition def)
+ throws WSDLException
+ {
+ Output output = def.createOutput();
+ String name = DOMUtils.getAttribute(outputEl, Constants.ATTR_NAME);
+ QName messageName = getQualifiedAttributeValue(outputEl,
+ Constants.ATTR_MESSAGE,
+ Constants.ELEM_OUTPUT,
+ def);
+
+ if (name != null)
+ {
+ output.setName(name);
+ }
+
+ if (messageName != null)
+ {
+ Message message = def.getMessage(messageName);
+
+ if (message == null)
+ {
+ message = def.createMessage();
+ message.setQName(messageName);
+ def.addMessage(message);
+ }
+
+ output.setMessage(message);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = outputEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(outputEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ output.setDocumentationElement(tempEl);
+ }
+ else
+ {
+ output.addExtensibilityElement(
+ parseExtensibilityElement(Output.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(outputEl, Output.class, output, def);
+
+ return output;
+ }
+
+ protected Fault parseFault(Element faultEl, Definition def)
+ throws WSDLException
+ {
+ Fault fault = def.createFault();
+ String name = DOMUtils.getAttribute(faultEl, Constants.ATTR_NAME);
+ QName messageName = getQualifiedAttributeValue(faultEl,
+ Constants.ATTR_MESSAGE,
+ Constants.ELEM_FAULT,
+ def);
+
+ if (name != null)
+ {
+ fault.setName(name);
+ }
+
+ if (messageName != null)
+ {
+ Message message = def.getMessage(messageName);
+
+ if (message == null)
+ {
+ message = def.createMessage();
+ message.setQName(messageName);
+ def.addMessage(message);
+ }
+
+ fault.setMessage(message);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = faultEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(faultEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ fault.setDocumentationElement(tempEl);
+ }
+ else
+ {
+ fault.addExtensibilityElement(
+ parseExtensibilityElement(Fault.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(faultEl, Fault.class, fault, def);
+
+ return fault;
+ }
+
+ /**
+ * This method should be used for elements that support extension
+ * attributes because it does not track unexpected remaining attributes.
+ */
+ private static QName getQualifiedAttributeValue(Element el,
+ String attrName,
+ String elDesc,
+ Definition def)
+ throws WSDLException
+ {
+ try
+ {
+ return DOMUtils.getQualifiedAttributeValue(el,
+ attrName,
+ elDesc,
+ false,
+ def);
+ }
+ catch (WSDLException e)
+ {
+ if (e.getFaultCode().equals(WSDLException.NO_PREFIX_SPECIFIED))
+ {
+ String attrValue = DOMUtils.getAttribute(el, attrName);
+
+ return new QName(attrValue);
+ }
+ else
+ {
+ throw e;
+ }
+ }
+ }
+
+ /**
+ * This method should be used for elements that do not support extension
+ * attributes because it tracks unexpected remaining attributes.
+ */
+ private static QName getQualifiedAttributeValue(Element el,
+ String attrName,
+ String elDesc,
+ Definition def,
+ List remainingAttrs)
+ throws WSDLException
+ {
+ try
+ {
+ return DOMUtils.getQualifiedAttributeValue(el,
+ attrName,
+ elDesc,
+ false,
+ def,
+ remainingAttrs);
+ }
+ catch (WSDLException e)
+ {
+ if (e.getFaultCode().equals(WSDLException.NO_PREFIX_SPECIFIED))
+ {
+ String attrValue = DOMUtils.getAttribute(el, attrName, remainingAttrs);
+
+ return new QName(attrValue);
+ }
+ else
+ {
+ throw e;
+ }
+ }
+ }
+
+ private static void checkElementName(Element el, QName qname)
+ throws WSDLException
+ {
+ if (!QNameUtils.matches(qname, el))
+ {
+ WSDLException wsdlExc = new WSDLException(WSDLException.INVALID_WSDL,
+ "Expected element '" +
+ qname + "'.");
+
+ wsdlExc.setLocation(XPathUtils.getXPathExprFromNode(el));
+
+ throw wsdlExc;
+ }
+ }
+
+ private static Document getDocument(InputSource inputSource,
+ String desc) throws WSDLException
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+
+ factory.setNamespaceAware(true);
+ factory.setValidating(false);
+
+ try
+ {
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ builder.setEntityResolver( new JBossWSEntityResolver() );
+ Document doc = builder.parse(inputSource);
+
+ return doc;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new WSDLException(WSDLException.PARSER_ERROR,
+ "Problem parsing '" + desc + "'.",
+ e);
+ }
+ }
+
+ private static void registerNSDeclarations(NamedNodeMap attrs, Definition def)
+ {
+ int size = attrs.getLength();
+
+ for (int i = 0; i < size; i++)
+ {
+ Attr attr = (Attr)attrs.item(i);
+ String namespaceURI = attr.getNamespaceURI();
+ String localPart = attr.getLocalName();
+ String value = attr.getValue();
+
+ if (namespaceURI != null && namespaceURI.equals(Constants.NS_URI_XMLNS))
+ {
+ if (localPart != null && !localPart.equals(Constants.ATTR_XMLNS))
+ {
+ DOMUtils.registerUniquePrefix(localPart, value, def);
+ }
+ else
+ {
+ DOMUtils.registerUniquePrefix(null, value, def);
+ }
+ }
+ }
+ }
+
+ /**
+ * Read the WSDL document accessible via the specified
+ * URI into a WSDL definition.
+ *
+ * @param wsdlURI a URI (can be a filename or URL) pointing to a
+ * WSDL XML definition.
+ * @return the definition.
+ */
+ public Definition readWSDL(String wsdlURI) throws WSDLException
+ {
+ return readWSDL(null, wsdlURI);
+ }
+
+ /**
+ * Read the WSDL document accessible via the specified
+ * URI into a WSDL definition.
+ *
+ * @param contextURI the context in which to resolve the
+ * wsdlURI, if the wsdlURI is relative. Can be null, in which
+ * case it will be ignored.
+ * @param wsdlURI a URI (can be a filename or URL) pointing to a
+ * WSDL XML definition.
+ * @return the definition.
+ */
+ public Definition readWSDL(String contextURI, String wsdlURI)
+ throws WSDLException
+ {
+ try
+ {
+ if (verbose)
+ {
+ System.out.println("Retrieving document at '" + wsdlURI + "'" +
+ (contextURI == null
+ ? "."
+ : ", relative to '" + contextURI + "'."));
+ }
+
+ URL contextURL = (contextURI != null)
+ ? StringUtils.getURL(null, contextURI)
+ : null;
+ URL url = StringUtils.getURL(contextURL, wsdlURI);
+ InputStream inputStream = StringUtils.getContentAsInputStream(url);
+ InputSource inputSource = new InputSource(inputStream);
+ inputSource.setSystemId(url.toString());
+ Document doc = getDocument(inputSource, url.toString());
+
+ inputStream.close();
+
+ Definition def = readWSDL(url.toString(), doc);
+
+ return def;
+ }
+ catch (WSDLException e)
+ {
+ throw e;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new WSDLException(WSDLException.OTHER_ERROR,
+ "Unable to resolve imported document at '" +
+ wsdlURI +
+ (contextURI == null
+ ? "'."
+ : "', relative to '" + contextURI + "'.")
+ , e);
+ }
+ }
+
+ /**
+ * Read the specified <wsdl:definitions> element into a WSDL
+ * definition.
+ *
+ * @param documentBaseURI the document base URI of the WSDL definition
+ * described by the element. Will be set as the documentBaseURI
+ * of the returned Definition. Can be null, in which case it
+ * will be ignored.
+ * @param definitionsElement the <wsdl:definitions> element
+ * @return the definition described by the element.
+ */
+ public Definition readWSDL(String documentBaseURI,
+ Element definitionsElement)
+ throws WSDLException
+ {
+ return readWSDL(documentBaseURI, definitionsElement, null);
+ }
+
+ /**
+ * Read the specified <wsdl:definitions> element into a WSDL
+ * definition. The WSDLLocator is used to provide the document
+ * base URIs. The InputSource of the WSDLLocator is ignored, instead
+ * the WSDL is parsed from the given Element.
+ *
+ * @param locator A WSDLLocator object used to provide
+ * the document base URI of the WSDL definition described by the
+ * element.
+ * @param definitionsElement the <wsdl:definitions> element
+ * @return the definition described by the element.
+ */
+ public Definition readWSDL(WSDLLocator locator,
+ Element definitionsElement)
+ throws WSDLException
+ {
+ try
+ {
+ this.loc = locator;
+ return readWSDL(locator.getBaseURI(), definitionsElement, null);
+ }
+ finally
+ {
+ locator.close();
+ this.loc = null;
+ }
+ }
+
+ protected Definition readWSDL(String documentBaseURI,
+ Element definitionsElement,
+ Map importedDefs)
+ throws WSDLException
+ {
+ return parseDefinitions(documentBaseURI, definitionsElement, importedDefs);
+ }
+
+ /**
+ * Read the specified WSDL document into a WSDL definition.
+ *
+ * @param documentBaseURI the document base URI of the WSDL definition
+ * described by the document. Will be set as the documentBaseURI
+ * of the returned Definition. Can be null, in which case it
+ * will be ignored.
+ * @param wsdlDocument the WSDL document, an XML
+ * document obeying the WSDL schema.
+ * @return the definition described in the document.
+ */
+ public Definition readWSDL(String documentBaseURI, Document wsdlDocument)
+ throws WSDLException
+ {
+ return readWSDL(documentBaseURI, wsdlDocument.getDocumentElement());
+ }
+
+ /**
+ * Read a WSDL document into a WSDL definition.
+ *
+ * @param documentBaseURI the document base URI of the WSDL definition
+ * described by the document. Will be set as the documentBaseURI
+ * of the returned Definition. Can be null, in which case it
+ * will be ignored.
+ * @param inputSource an InputSource pointing to the
+ * WSDL document, an XML document obeying the WSDL schema.
+ * @return the definition described in the document pointed to
+ * by the InputSource.
+ */
+ public Definition readWSDL(String documentBaseURI, InputSource inputSource)
+ throws WSDLException
+ {
+ String location = (inputSource.getSystemId() != null ?
+ inputSource.getSystemId() : "- WSDL Document -");
+
+ return readWSDL(documentBaseURI,
+ getDocument(inputSource, location));
+ }
+
+ /**
+ * Read a WSDL document into a WSDL definition.
+ *
+ * @param locator A WSDLLocator object used to provide InputSources
+ * pointing to the wsdl file.
+ * @return the definition described in the document
+ */
+ public Definition readWSDL(WSDLLocator locator) throws WSDLException
+ {
+ InputSource is = locator.getBaseInputSource();
+ String base = locator.getBaseURI();
+
+ if (is == null)
+ {
+ throw new WSDLException(WSDLException.OTHER_ERROR,
+ "Unable to locate document at '" + base + "'.");
+ }
+ is.setSystemId(base);
+
+ this.loc = locator;
+
+ if (verbose)
+ {
+ System.out.println("Retrieving document at '" + base + "'.");
+ }
+
+ try
+ {
+ return readWSDL(base, is);
+ }
+ finally
+ {
+ this.loc.close();
+ this.loc = null;
+ }
+ }
+}
+
Property changes on: legacy/branches/jbossws-1.2.1.GA_CP01_JBPAPP-459/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLReaderImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: legacy/branches/jbossws-1.2.1.GA_CP01_JBPAPP-459/jbossws-core/src/java/org/jboss/ws/tools/wsdl/WSDLDefinitionsFactory.java
===================================================================
--- legacy/branches/jbossws-1.2.1.GA_CP01_JBPAPP-459/jbossws-core/src/java/org/jboss/ws/tools/wsdl/WSDLDefinitionsFactory.java 2007-11-29 12:28:47 UTC (rev 5146)
+++ legacy/branches/jbossws-1.2.1.GA_CP01_JBPAPP-459/jbossws-core/src/java/org/jboss/ws/tools/wsdl/WSDLDefinitionsFactory.java 2007-11-29 12:35:27 UTC (rev 5147)
@@ -109,7 +109,7 @@
String defaultNamespace = getDefaultNamespace(wsdlDoc);
if (Constants.NS_WSDL11.equals(defaultNamespace))
{
- WSDLFactory wsdlFactory = WSDLFactory.newInstance();
+ WSDLFactory wsdlFactory = WSDLFactory.newInstance(JBossWSDLFactoryImpl.class.getName());
WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose", false);
@@ -132,8 +132,9 @@
wsdlDefinitions.setWsdlDocument(wsdlDoc);
}
else
+ {
throw new WSDLException("Invalid default namespace: " + defaultNamespace);
-
+ }
if (log.isTraceEnabled())
{
StringWriter stwr = new StringWriter();
17 years, 3 months
JBossWS SVN: r5146 - legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/tools/wsdl.
by jbossws-commits@lists.jboss.org
Author: mageshbk(a)jboss.com
Date: 2007-11-29 07:28:47 -0500 (Thu, 29 Nov 2007)
New Revision: 5146
Added:
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLFactoryImpl.java
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLReaderImpl.java
Modified:
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/tools/wsdl/WSDLDefinitionsFactory.java
Log:
[JBPAPP-460] WSDLDefinitionsFactory doesn't resolve schema references locally
Added: legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLFactoryImpl.java
===================================================================
--- legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLFactoryImpl.java (rev 0)
+++ legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLFactoryImpl.java 2007-11-29 12:28:47 UTC (rev 5146)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.tools.wsdl;
+
+import com.ibm.wsdl.DefinitionImpl;
+import com.ibm.wsdl.extensions.PopulatedExtensionRegistry;
+import com.ibm.wsdl.xml.WSDLWriterImpl;
+
+import javax.wsdl.Definition;
+import javax.wsdl.extensions.ExtensionRegistry;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.wsdl.xml.WSDLWriter;
+
+/**
+ * A fork of the original wsdl4j 1.6.2 package
+ * that delegates to the {@link JBossWSDLReaderImpl}.
+ * <p>
+ * Original author: Matthew J. Duftler (duftler(a)us.ibm.com)
+ *
+ * @version $Revision$
+ */
+public class JBossWSDLFactoryImpl extends WSDLFactory
+{
+ /**
+ * Create a new instance of a Definition, with an instance
+ * of a PopulatedExtensionRegistry as its ExtensionRegistry.
+ *
+ * @see com.ibm.wsdl.extensions.PopulatedExtensionRegistry
+ */
+ public Definition newDefinition()
+ {
+ Definition def = new DefinitionImpl();
+ ExtensionRegistry extReg = newPopulatedExtensionRegistry();
+
+ def.setExtensionRegistry(extReg);
+
+ return def;
+ }
+
+ /**
+ * Create a new instance of a WSDLReader.
+ */
+ public WSDLReader newWSDLReader()
+ {
+ return new JBossWSDLReaderImpl();
+ }
+
+ public WSDLWriter newWSDLWriter()
+ {
+ return new WSDLWriterImpl();
+ }
+
+ /**
+ * Create a new instance of an ExtensionRegistry with pre-registered
+ * serializers/deserializers for the SOAP, HTTP and MIME
+ * extensions. Java extensionTypes are also mapped for all
+ * the SOAP, HTTP and MIME extensions.
+ */
+ public ExtensionRegistry newPopulatedExtensionRegistry()
+ {
+ return new PopulatedExtensionRegistry();
+ }
+}
\ No newline at end of file
Property changes on: legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLFactoryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLReaderImpl.java
===================================================================
--- legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLReaderImpl.java (rev 0)
+++ legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLReaderImpl.java 2007-11-29 12:28:47 UTC (rev 5146)
@@ -0,0 +1,2372 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.tools.wsdl;
+
+import com.ibm.wsdl.Constants;
+import com.ibm.wsdl.extensions.schema.SchemaConstants;
+import com.ibm.wsdl.util.StringUtils;
+import com.ibm.wsdl.util.xml.DOMUtils;
+import com.ibm.wsdl.util.xml.QNameUtils;
+import com.ibm.wsdl.util.xml.XPathUtils;
+import org.jboss.ws.core.utils.JBossWSEntityResolver;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.xml.sax.InputSource;
+
+import javax.wsdl.*;
+import javax.wsdl.extensions.AttributeExtensible;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.ExtensionDeserializer;
+import javax.wsdl.extensions.ExtensionRegistry;
+import javax.wsdl.extensions.schema.Schema;
+import javax.wsdl.extensions.schema.SchemaReference;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLLocator;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.*;
+
+
+/**
+ * A WSDLReader fork of the original wsdl4j 1.6.2 package
+ * that delegates to the JBossWSEntityResolver in
+ * <code>private static Document getDocument(InputSource inputSource,String desc)</code>
+ * <p>
+ * Original authors: Matthew J. Duftler,Nirmal Mukhi
+ *
+ * @version $Revision$
+ */
+public class JBossWSDLReaderImpl implements WSDLReader
+{
+ // Used for determining the style of operations.
+ private static final List STYLE_ONE_WAY =
+ Arrays.asList(new String[]{Constants.ELEM_INPUT});
+ private static final List STYLE_REQUEST_RESPONSE =
+ Arrays.asList(new String[]{Constants.ELEM_INPUT, Constants.ELEM_OUTPUT});
+ private static final List STYLE_SOLICIT_RESPONSE =
+ Arrays.asList(new String[]{Constants.ELEM_OUTPUT, Constants.ELEM_INPUT});
+ private static final List STYLE_NOTIFICATION =
+ Arrays.asList(new String[]{Constants.ELEM_OUTPUT});
+
+ protected boolean verbose = true;
+ protected boolean importDocuments = true;
+ protected ExtensionRegistry extReg = null;
+ protected String factoryImplName = null;
+ protected WSDLLocator loc = null;
+ protected WSDLFactory factory = null;
+
+ //Contains all schemas used by this wsdl, either in-line or nested
+ //via wsdl imports or schema imports, includes or redefines
+ protected Map allSchemas = new Hashtable();
+
+
+ /**
+ * Sets the specified feature to the specified value.
+ * <p>
+ * The supported features are:
+ * <p>
+ * <table border=1>
+ * <tr>
+ * <th>Name</th>
+ * <th>Description</th>
+ * <th>Default Value</th>
+ * </tr>
+ * <tr>
+ * <td><center>javax.wsdl.verbose</center></td>
+ * <td>If set to true, status messages will be displayed.</td>
+ * <td><center>true</center></td>
+ * </tr>
+ * <tr>
+ * <td><center>javax.wsdl.importDocuments</center></td>
+ * <td>If set to true, imported WSDL documents will be
+ * retrieved and processed.</td>
+ * <td><center>true</center></td>
+ * </tr>
+ * </table>
+ * <p>
+ * All feature names must be fully-qualified, Java package style. All
+ * names starting with javax.wsdl. are reserved for features defined
+ * by the JWSDL specification. It is recommended that implementation-
+ * specific features be fully-qualified to match the package name
+ * of that implementation. For example: com.abc.featureName
+ *
+ * @param name the name of the feature to be set.
+ * @param value the value to set the feature to.
+ * @throws IllegalArgumentException if the feature name is not recognized.
+ * @see #getFeature(String)
+ */
+ public void setFeature(String name, boolean value)
+ throws IllegalArgumentException
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("Feature name must not be null.");
+ }
+
+ if (name.equals(Constants.FEATURE_VERBOSE))
+ {
+ verbose = value;
+ }
+ else if (name.equals(Constants.FEATURE_IMPORT_DOCUMENTS))
+ {
+ importDocuments = value;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Feature name '" + name +
+ "' not recognized.");
+ }
+ }
+
+ /**
+ * Gets the value of the specified feature.
+ *
+ * @param name the name of the feature to get the value of.
+ * @return the value of the feature.
+ * @throws IllegalArgumentException if the feature name is not recognized.
+ * @see #setFeature(String, boolean)
+ */
+ public boolean getFeature(String name) throws IllegalArgumentException
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("Feature name must not be null.");
+ }
+
+ if (name.equals(Constants.FEATURE_VERBOSE))
+ {
+ return verbose;
+ }
+ else if (name.equals(Constants.FEATURE_IMPORT_DOCUMENTS))
+ {
+ return importDocuments;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Feature name '" + name +
+ "' not recognized.");
+ }
+ }
+
+ /**
+ * Set the extension registry to be used when reading
+ * WSDL documents into a WSDL definition. If an
+ * extension registry is set, that is the extension
+ * registry that will be set as the extensionRegistry
+ * property of the definitions resulting from invoking
+ * readWSDL(...). Default is null.
+ *
+ * @param extReg the extension registry to use for new
+ * definitions
+ */
+ public void setExtensionRegistry(ExtensionRegistry extReg)
+ {
+ this.extReg = extReg;
+ }
+
+ /**
+ * Get the extension registry, if one was set. Default is
+ * null.
+ */
+ public ExtensionRegistry getExtensionRegistry()
+ {
+ return extReg;
+ }
+
+ /**
+ * Get the WSDLFactory object cached in the reader, or use lazy
+ * instantiation if it is not cached yet.
+ */
+ protected WSDLFactory getWSDLFactory() throws WSDLException
+ {
+ if (factory == null)
+ {
+ factory = (factoryImplName != null)
+ ? WSDLFactory.newInstance(factoryImplName)
+ : WSDLFactory.newInstance();
+ }
+ return factory;
+ }
+
+ /**
+ * Set a different factory implementation to use for
+ * creating definitions when reading WSDL documents.
+ * As some WSDLReader implementations may only be
+ * capable of creating definitions using the same
+ * factory implementation from which the reader was
+ * obtained, this method is optional. Default is null.
+ *
+ * @param factoryImplName the fully-qualified class name of the
+ * class which provides a concrete implementation of the abstract
+ * class WSDLFactory.
+ * @throws UnsupportedOperationException if this method
+ * is invoked on an implementation which does not
+ * support it.
+ */
+ public void setFactoryImplName(String factoryImplName)
+ throws UnsupportedOperationException
+ {
+ //check to see if we really need to change the factory name and clear the cache
+ if((this.factoryImplName == null && factoryImplName != null) ||
+ (this.factoryImplName != null && !this.factoryImplName.equals(factoryImplName)))
+ {
+ //the factory object is cached in the reader so set it
+ //to null if the factory impl name is reset.
+ this.factory = null;
+
+ this.factoryImplName = factoryImplName;
+ //if(verbose) System.out.println("WSDLFactory Impl Name set to : "+factoryImplName);
+ }
+ }
+
+ /**
+ * Get the factoryImplName, if one was set. Default is null.
+ */
+ public String getFactoryImplName()
+ {
+ return factoryImplName;
+ }
+
+ protected Definition parseDefinitions(String documentBaseURI,
+ Element defEl,
+ Map importedDefs)
+ throws WSDLException
+ {
+ checkElementName(defEl, Constants.Q_ELEM_DEFINITIONS);
+
+ WSDLFactory factory = getWSDLFactory();
+ Definition def = factory.newDefinition();
+
+ if (extReg != null)
+ {
+ def.setExtensionRegistry(extReg);
+ }
+
+ String name = DOMUtils.getAttribute(defEl, Constants.ATTR_NAME);
+ String targetNamespace = DOMUtils.getAttribute(defEl,
+ Constants.ATTR_TARGET_NAMESPACE);
+ NamedNodeMap attrs = defEl.getAttributes();
+
+ if (importedDefs == null)
+ {
+ importedDefs = new Hashtable();
+ }
+
+ if (documentBaseURI != null)
+ {
+ def.setDocumentBaseURI(documentBaseURI);
+ importedDefs.put(documentBaseURI, def);
+ }
+
+ if (name != null)
+ {
+ def.setQName(new QName(targetNamespace, name));
+ }
+
+ if (targetNamespace != null)
+ {
+ def.setTargetNamespace(targetNamespace);
+ }
+
+ int size = attrs.getLength();
+
+ for (int i = 0; i < size; i++)
+ {
+ Attr attr = (Attr)attrs.item(i);
+ String namespaceURI = attr.getNamespaceURI();
+ String localPart = attr.getLocalName();
+ String value = attr.getValue();
+
+ if (namespaceURI != null && namespaceURI.equals(Constants.NS_URI_XMLNS))
+ {
+ if (localPart != null && !localPart.equals(Constants.ATTR_XMLNS))
+ {
+ def.addNamespace(localPart, value);
+ }
+ else
+ {
+ def.addNamespace(null, value);
+ }
+ }
+ }
+
+ Element tempEl = DOMUtils.getFirstChildElement(defEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_IMPORT, tempEl))
+ {
+ def.addImport(parseImport(tempEl, def, importedDefs));
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ def.setDocumentationElement(tempEl);
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_TYPES, tempEl))
+ {
+ def.setTypes(parseTypes(tempEl, def));
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_MESSAGE, tempEl))
+ {
+ def.addMessage(parseMessage(tempEl, def));
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_PORT_TYPE, tempEl))
+ {
+ def.addPortType(parsePortType(tempEl, def));
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_BINDING, tempEl))
+ {
+ def.addBinding(parseBinding(tempEl, def));
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_SERVICE, tempEl))
+ {
+ def.addService(parseService(tempEl, def));
+ }
+ else
+ {
+ def.addExtensibilityElement(
+ parseExtensibilityElement(Definition.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(defEl, Definition.class, def, def);
+
+ return def;
+ }
+
+ protected Import parseImport(Element importEl,
+ Definition def,
+ Map importedDefs)
+ throws WSDLException
+ {
+ Import importDef = def.createImport();
+
+ try
+ {
+ String namespaceURI = DOMUtils.getAttribute(importEl,
+ Constants.ATTR_NAMESPACE);
+ String locationURI = DOMUtils.getAttribute(importEl,
+ Constants.ATTR_LOCATION);
+ String contextURI = null;
+
+ if (namespaceURI != null)
+ {
+ importDef.setNamespaceURI(namespaceURI);
+ }
+
+ if (locationURI != null)
+ {
+ importDef.setLocationURI(locationURI);
+
+ if (importDocuments)
+ {
+ try
+ {
+ contextURI = def.getDocumentBaseURI();
+ Definition importedDef = null;
+ InputStream inputStream = null;
+ InputSource inputSource = null;
+ URL url = null;
+
+ if (loc != null)
+ {
+ inputSource = loc.getImportInputSource(contextURI, locationURI);
+
+ /*
+ We now have available the latest import URI. This might
+ differ from the locationURI so check the importedDefs for it
+ since it is this that we pass as the documentBaseURI later.
+ */
+ String liu = loc.getLatestImportURI();
+
+ importedDef = (Definition)importedDefs.get(liu);
+
+ inputSource.setSystemId(liu);
+ }
+ else
+ {
+ URL contextURL = (contextURI != null)
+ ? StringUtils.getURL(null, contextURI)
+ : null;
+
+ url = StringUtils.getURL(contextURL, locationURI);
+ importedDef = (Definition)importedDefs.get(url.toString());
+
+ if (importedDef == null)
+ {
+ inputStream = StringUtils.getContentAsInputStream(url);
+
+ if (inputStream != null)
+ {
+ inputSource = new InputSource(inputStream);
+ inputSource.setSystemId(url.toString());
+ }
+ }
+ }
+
+ if (importedDef == null)
+ {
+ if (inputSource == null)
+ {
+ throw new WSDLException(WSDLException.OTHER_ERROR,
+ "Unable to locate imported document " +
+ "at '" + locationURI + "'" +
+ (contextURI == null
+ ? "."
+ : ", relative to '" + contextURI +
+ "'."));
+ }
+
+ Document doc = getDocument(inputSource, inputSource.getSystemId());
+
+ if (inputStream != null)
+ {
+ inputStream.close();
+ }
+
+ Element documentElement = doc.getDocumentElement();
+
+ /*
+ Check if it's a wsdl document.
+ If it's not, don't retrieve and process it.
+ This should later be extended to allow other types of
+ documents to be retrieved and processed, such as schema
+ documents (".xsd"), etc...
+ */
+ if (QNameUtils.matches(Constants.Q_ELEM_DEFINITIONS,
+ documentElement))
+ {
+ if (verbose)
+ {
+ System.out.println("Retrieving document at '" + locationURI +
+ "'" +
+ (contextURI == null
+ ? "."
+ : ", relative to '" + contextURI + "'."));
+ }
+
+ String urlString =
+ (loc != null)
+ ? loc.getLatestImportURI()
+ : (url != null)
+ ? url.toString()
+ : locationURI;
+
+ importedDef = readWSDL(urlString,
+ documentElement,
+ importedDefs);
+ }
+ else
+ {
+ QName docElementQName = QNameUtils.newQName(documentElement);
+
+ if (SchemaConstants.XSD_QNAME_LIST.contains(docElementQName))
+ {
+ if (verbose)
+ {
+ System.out.println("Retrieving schema wsdl:imported from '" + locationURI +
+ "'" +
+ (contextURI == null
+ ? "."
+ : ", relative to '" + contextURI + "'."));
+ }
+
+ WSDLFactory factory = getWSDLFactory();
+
+ importedDef = factory.newDefinition();
+
+ if (extReg != null)
+ {
+ importedDef.setExtensionRegistry(extReg);
+ }
+
+ String urlString =
+ (loc != null)
+ ? loc.getLatestImportURI()
+ : (url != null)
+ ? url.toString()
+ : locationURI;
+
+ importedDef.setDocumentBaseURI(urlString);
+
+ Types types = importedDef.createTypes();
+ types.addExtensibilityElement(
+ parseSchema(Types.class, documentElement, importedDef));
+ importedDef.setTypes(types);
+ }
+ }
+ }
+
+ if (importedDef != null)
+ {
+ importDef.setDefinition(importedDef);
+ }
+ }
+ catch (WSDLException e)
+ {
+ throw e;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new WSDLException(WSDLException.OTHER_ERROR,
+ "Unable to resolve imported document at '" +
+ locationURI +
+ (contextURI == null
+ ? "'." : "', relative to '" + contextURI + "'")
+ , e);
+ }
+ } //end importDocs
+ } //end locationURI
+
+ }
+ catch (WSDLException e)
+ {
+ if (e.getLocation() == null)
+ {
+ e.setLocation(XPathUtils.getXPathExprFromNode(importEl));
+ }
+ else
+ {
+ //If definitions are being parsed recursively for nested imports
+ //the exception location must be built up recursively too so
+ //prepend this element's xpath to exception location.
+ String loc = XPathUtils.getXPathExprFromNode(importEl) + e.getLocation();
+ e.setLocation(loc);
+ }
+
+ throw e;
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = importEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(importEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ importDef.setDocumentationElement(tempEl);
+ }
+ else
+ {
+ importDef.addExtensibilityElement(
+ parseExtensibilityElement(Import.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(importEl, Import.class, importDef, def);
+
+ return importDef;
+
+ }
+
+ protected Types parseTypes(Element typesEl, Definition def)
+ throws WSDLException
+ {
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = typesEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Types types = def.createTypes();
+ Element tempEl = DOMUtils.getFirstChildElement(typesEl);
+ QName tempElType;
+
+ while (tempEl != null)
+ {
+ tempElType = QNameUtils.newQName(tempEl);
+
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ types.setDocumentationElement(tempEl);
+ }
+ else if ((SchemaConstants.XSD_QNAME_LIST).contains(tempElType))
+ {
+ //the element qname indicates it is a schema.
+ types.addExtensibilityElement(
+ parseSchema(Types.class, tempEl, def));
+ }
+ else
+ {
+ types.addExtensibilityElement(
+ parseExtensibilityElement(Types.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(typesEl, Types.class, types, def);
+
+ return types;
+ }
+
+ protected ExtensibilityElement parseSchema( Class parentType,
+ Element el,
+ Definition def)
+ throws WSDLException
+ {
+ QName elementType = null;
+ ExtensionRegistry extReg = null;
+
+ try
+ {
+ extReg = def.getExtensionRegistry();
+
+ if (extReg == null)
+ {
+ throw new WSDLException(WSDLException.CONFIGURATION_ERROR,
+ "No ExtensionRegistry set for this " +
+ "Definition, so unable to deserialize " +
+ "a '" + elementType + "' element in the " +
+ "context of a '" + parentType.getName() +
+ "'.");
+ }
+
+ return parseSchema(parentType, el, def, extReg);
+ }
+ catch (WSDLException e)
+ {
+ if (e.getLocation() == null)
+ {
+ e.setLocation(XPathUtils.getXPathExprFromNode(el));
+ }
+
+ throw e;
+ }
+ }
+
+
+ protected ExtensibilityElement parseSchema( Class parentType,
+ Element el,
+ Definition def,
+ ExtensionRegistry extReg)
+ throws WSDLException
+ {
+ /*
+ * This method returns ExtensibilityElement rather than Schema because we
+ * do not insist that a suitable XSD schema deserializer is registered.
+ * PopulatedExtensionRegistry registers SchemaDeserializer by default, but
+ * if the user chooses not to register a suitable deserializer then the
+ * UnknownDeserializer will be used, returning an UnknownExtensibilityElement.
+ */
+
+ Schema schema = null;
+ SchemaReference schemaRef = null;
+ try
+ {
+
+ QName elementType = QNameUtils.newQName(el);
+
+ ExtensionDeserializer exDS =
+ extReg.queryDeserializer(parentType, elementType);
+
+ //Now unmarshall the DOM element.
+ ExtensibilityElement ee =
+ exDS.unmarshall(parentType, elementType, el, def, extReg);
+
+ if (ee instanceof Schema)
+ {
+ schema = (Schema) ee;
+ }
+ else
+ {
+ //Unknown extensibility element, so don't do any more schema parsing on it.
+ return ee;
+ }
+
+
+ //Keep track of parsed schemas to avoid duplicating Schema objects
+ //through duplicate or circular references (eg: A imports B imports A).
+ if (schema.getDocumentBaseURI() != null)
+ {
+ this.allSchemas.put(schema.getDocumentBaseURI(), schema);
+ }
+
+ //At this point, any SchemaReference objects held by the schema will not
+ //yet point to their referenced schemas, so we must now retrieve these
+ //schemas and set the schema references.
+
+ //First, combine the schema references for imports, includes and redefines
+ //into a single list
+
+ ArrayList allSchemaRefs = new ArrayList();
+
+ Collection ic = schema.getImports().values();
+ Iterator importsIterator = ic.iterator();
+ while(importsIterator.hasNext())
+ {
+ allSchemaRefs.addAll( (Collection) importsIterator.next() );
+ }
+
+ allSchemaRefs.addAll(schema.getIncludes());
+ allSchemaRefs.addAll(schema.getRedefines());
+
+ //Then, retrieve the schema referred to by each schema reference. If the
+ //schema has been read in previously, use the existing schema object.
+ //Otherwise unmarshall the DOM element into a new schema object.
+
+ ListIterator schemaRefIterator = allSchemaRefs.listIterator();
+
+ while(schemaRefIterator.hasNext())
+ {
+ try
+ {
+ schemaRef = (SchemaReference) schemaRefIterator.next();
+
+ if (schemaRef.getSchemaLocationURI() == null)
+ {
+ //cannot get the referenced schema, so ignore this schema reference
+ continue;
+ }
+
+ if (verbose)
+ {
+ System.out.println("Retrieving schema at '" +
+ schemaRef.getSchemaLocationURI() +
+ (schema.getDocumentBaseURI() == null
+ ? "'."
+ : "', relative to '" +
+ schema.getDocumentBaseURI() + "'."));
+ }
+
+
+ InputStream inputStream = null;
+ InputSource inputSource = null;
+
+ //This is the child schema referred to by the schemaReference
+ Schema referencedSchema = null;
+
+ //This is the child schema's location obtained from the WSDLLocator or the URL
+ String location = null;
+
+ if (loc != null)
+ {
+ //Try to get the referenced schema using the wsdl locator
+ inputSource = loc.getImportInputSource(
+ schema.getDocumentBaseURI(), schemaRef.getSchemaLocationURI());
+
+ if (inputSource == null)
+ {
+ throw new WSDLException(WSDLException.OTHER_ERROR,
+ "Unable to locate with a locator "
+ + "the schema referenced at '"
+ + schemaRef.getSchemaLocationURI()
+ + "' relative to document base '"
+ + schema.getDocumentBaseURI() + "'");
+ }
+ location = loc.getLatestImportURI();
+
+ //if a schema from this location has been read previously, use it.
+ referencedSchema = (Schema) this.allSchemas.get(location);
+ }
+ else
+ {
+ // We don't have a wsdl locator, so try to retrieve the schema by its URL
+ String contextURI = schema.getDocumentBaseURI();
+ URL contextURL = (contextURI != null) ? StringUtils.getURL(null, contextURI) : null;
+ URL url = StringUtils.getURL(contextURL, schemaRef.getSchemaLocationURI());
+ location = url.toExternalForm();
+
+ //if a schema from this location has been retrieved previously, use it.
+ referencedSchema = (Schema) this.allSchemas.get(location);
+
+ if (referencedSchema == null)
+ {
+ // We haven't read this schema in before so do it now
+ inputStream = StringUtils.getContentAsInputStream(url);
+
+ if (inputStream != null)
+ {
+ inputSource = new InputSource(inputStream);
+ }
+
+ if (inputSource == null)
+ {
+ throw new WSDLException(WSDLException.OTHER_ERROR,
+ "Unable to locate with a url "
+ + "the document referenced at '"
+ + schemaRef.getSchemaLocationURI()
+ + "'"
+ + (contextURI == null ? "." : ", relative to '"
+ + contextURI + "'."));
+ }
+ }
+
+ } //end if loc
+
+ // If we have not previously read the schema, get its DOM element now.
+ if (referencedSchema == null)
+ {
+ inputSource.setSystemId(location);
+ Document doc = getDocument(inputSource, location);
+
+ if (inputStream != null)
+ {
+ inputStream.close();
+ }
+
+ Element documentElement = doc.getDocumentElement();
+
+ // If it's a schema doc process it, otherwise the schema reference remains null
+
+ QName docElementQName = QNameUtils.newQName(documentElement);
+
+ if (SchemaConstants.XSD_QNAME_LIST.contains(docElementQName))
+ {
+ //We now need to call parseSchema recursively to parse the referenced
+ //schema. The document base URI of the referenced schema will be set to
+ //the document base URI of the current schema plus the schemaLocation in
+ //the schemaRef. We cannot explicitly pass in a new document base URI
+ //to the schema deserializer, so instead we will create a dummy
+ //Definition and set its documentBaseURI to the new document base URI.
+ //We can leave the other definition fields empty because we know
+ //that the SchemaDeserializer.unmarshall method uses the definition
+ //parameter only to get its documentBaseURI. If the unmarshall method
+ //implementation changes (ie: its use of definition changes) we may need
+ //to rethink this approach.
+
+ WSDLFactory factory = getWSDLFactory();
+ Definition dummyDef = factory.newDefinition();
+
+ dummyDef.setDocumentBaseURI(location);
+
+ //By this point, we know we have a SchemaDeserializer registered
+ //so we can safely cast the ExtensibilityElement to a Schema.
+ referencedSchema = (Schema) parseSchema( parentType,
+ documentElement,
+ dummyDef,
+ extReg);
+ }
+
+ } //end if referencedSchema
+
+ schemaRef.setReferencedSchema(referencedSchema);
+ }
+ catch (WSDLException e)
+ {
+ throw e;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new WSDLException(WSDLException.OTHER_ERROR,
+ "An error occurred trying to resolve schema referenced at '"
+ + schemaRef.getSchemaLocationURI()
+ + "'"
+ + (schema.getDocumentBaseURI() == null ? "." : ", relative to '"
+ + schema.getDocumentBaseURI() + "'."),
+ e);
+ }
+
+ } //end while loop
+
+ return schema;
+
+ }
+ catch (WSDLException e)
+ {
+ if (e.getLocation() == null)
+ {
+ e.setLocation(XPathUtils.getXPathExprFromNode(el));
+ }
+ else
+ {
+ //If this method has been called recursively for nested schemas
+ //the exception location must be built up recursively too so
+ //prepend this element's xpath to exception location.
+ String loc = XPathUtils.getXPathExprFromNode(el) + e.getLocation();
+ e.setLocation(loc);
+ }
+
+ throw e;
+ }
+
+ }
+
+
+ protected Binding parseBinding(Element bindingEl, Definition def)
+ throws WSDLException
+ {
+ Binding binding = null;
+
+ List remainingAttrs = DOMUtils.getAttributes(bindingEl);
+ String name = DOMUtils.getAttribute(bindingEl, Constants.ATTR_NAME, remainingAttrs);
+ QName portTypeName = getQualifiedAttributeValue(bindingEl,
+ Constants.ATTR_TYPE,
+ Constants.ELEM_BINDING,
+ def,
+ remainingAttrs);
+
+ PortType portType = null;
+
+ if (name != null)
+ {
+ QName bindingName = new QName(def.getTargetNamespace(), name);
+
+ binding = def.getBinding(bindingName);
+
+ if (binding == null)
+ {
+ binding = def.createBinding();
+ binding.setQName(bindingName);
+ }
+ }
+ else
+ {
+ binding = def.createBinding();
+ }
+
+ // Whether it was retrieved or created, the definition has been found.
+ binding.setUndefined(false);
+
+ if (portTypeName != null)
+ {
+ portType = def.getPortType(portTypeName);
+
+ if (portType == null)
+ {
+ portType = def.createPortType();
+ portType.setQName(portTypeName);
+ def.addPortType(portType);
+ }
+
+ binding.setPortType(portType);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = bindingEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(bindingEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ binding.setDocumentationElement(tempEl);
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_OPERATION, tempEl))
+ {
+ binding.addBindingOperation(parseBindingOperation(tempEl,
+ portType,
+ def));
+ }
+ else
+ {
+ binding.addExtensibilityElement(parseExtensibilityElement(
+ Binding.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ return binding;
+ }
+
+ protected BindingOperation parseBindingOperation(
+ Element bindingOperationEl,
+ PortType portType,
+ Definition def)
+ throws WSDLException
+ {
+ BindingOperation bindingOperation = def.createBindingOperation();
+
+ List remainingAttrs = DOMUtils.getAttributes(bindingOperationEl);
+ String name = DOMUtils.getAttribute(bindingOperationEl,
+ Constants.ATTR_NAME,
+ remainingAttrs);
+
+ if (name != null)
+ {
+ bindingOperation.setName(name);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = bindingOperationEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(bindingOperationEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ bindingOperation.setDocumentationElement(tempEl);
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_INPUT, tempEl))
+ {
+ bindingOperation.setBindingInput(parseBindingInput(tempEl, def));
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_OUTPUT, tempEl))
+ {
+ bindingOperation.setBindingOutput(parseBindingOutput(tempEl, def));
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_FAULT, tempEl))
+ {
+ bindingOperation.addBindingFault(parseBindingFault(tempEl, def));
+ }
+ else
+ {
+ bindingOperation.addExtensibilityElement(
+ parseExtensibilityElement(BindingOperation.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ if (portType != null)
+ {
+ BindingInput bindingInput = bindingOperation.getBindingInput();
+ BindingOutput bindingOutput = bindingOperation.getBindingOutput();
+ String inputName = (bindingInput != null
+ ? (bindingInput.getName() != null ? bindingInput.getName() : Constants.NONE)
+ : null);
+ String outputName = (bindingOutput != null
+ ? (bindingOutput.getName() != null ? bindingOutput.getName() : Constants.NONE)
+ : null);
+ Operation op = portType.getOperation(name, inputName, outputName);
+
+ /*
+ * If the bindingOp input or output message names are null we will search first
+ * for a porttypeOp with corresponding unnamed input or output messages (using
+ * Constants.NONE for inputName or outputName, as above).
+ * However, input and output message names need not be used at all if operation
+ * overloading is not used, so if no match was found we will try again ignoring
+ * these unnamed messages from the search criteria (i.e. using null instead of
+ * Constants.NONE for inputName or outputName).
+ */
+
+ if(op == null)
+ {
+ if(Constants.NONE.equals(inputName) && Constants.NONE.equals(outputName))
+ {
+ //There was no porttype op with unnamed input and output messages,
+ //so ignore input and output name and search on the op name only.
+ op = portType.getOperation(name, null, null);
+ }
+ else if(Constants.NONE.equals(inputName))
+ {
+ //There was no porttype op with an unnamed input message,
+ //so ignore input name and search on the op name and output name only.
+ op = portType.getOperation(name, null, outputName);
+ }
+ else if(Constants.NONE.equals(outputName))
+ {
+ //There was no porttype op with an unnamed output message,
+ //so ignore output name and search on the op name and input name only.
+ op = portType.getOperation(name, inputName, null);
+ }
+ }
+
+ if (op == null)
+ {
+ Input input = def.createInput();
+ Output output = def.createOutput();
+
+ op = def.createOperation();
+ op.setName(name);
+ input.setName(inputName);
+ output.setName(outputName);
+ op.setInput(input);
+ op.setOutput(output);
+ portType.addOperation(op);
+ }
+
+ bindingOperation.setOperation(op);
+ }
+
+ parseExtensibilityAttributes(bindingOperationEl, BindingOperation.class, bindingOperation, def);
+
+ return bindingOperation;
+ }
+
+ protected BindingInput parseBindingInput(Element bindingInputEl,
+ Definition def)
+ throws WSDLException
+ {
+ BindingInput bindingInput = def.createBindingInput();
+
+ List remainingAttrs = DOMUtils.getAttributes(bindingInputEl);
+ String name = DOMUtils.getAttribute(bindingInputEl,
+ Constants.ATTR_NAME,
+ remainingAttrs);
+
+ if (name != null)
+ {
+ bindingInput.setName(name);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = bindingInputEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(bindingInputEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ bindingInput.setDocumentationElement(tempEl);
+ }
+ else
+ {
+ bindingInput.addExtensibilityElement(
+ parseExtensibilityElement(BindingInput.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ return bindingInput;
+ }
+
+ protected BindingOutput parseBindingOutput(Element bindingOutputEl,
+ Definition def)
+ throws WSDLException
+ {
+ BindingOutput bindingOutput = def.createBindingOutput();
+
+ List remainingAttrs = DOMUtils.getAttributes(bindingOutputEl);
+ String name = DOMUtils.getAttribute(bindingOutputEl,
+ Constants.ATTR_NAME,
+ remainingAttrs);
+
+ if (name != null)
+ {
+ bindingOutput.setName(name);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = bindingOutputEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(bindingOutputEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ bindingOutput.setDocumentationElement(tempEl);
+ }
+ else
+ {
+ bindingOutput.addExtensibilityElement(
+ parseExtensibilityElement(BindingOutput.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ return bindingOutput;
+ }
+
+ protected BindingFault parseBindingFault(Element bindingFaultEl,
+ Definition def)
+ throws WSDLException
+ {
+ BindingFault bindingFault = def.createBindingFault();
+
+ List remainingAttrs = DOMUtils.getAttributes(bindingFaultEl);
+ String name = DOMUtils.getAttribute(bindingFaultEl,
+ Constants.ATTR_NAME,
+ remainingAttrs);
+
+ if (name != null)
+ {
+ bindingFault.setName(name);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = bindingFaultEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(bindingFaultEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ bindingFault.setDocumentationElement(tempEl);
+ }
+ else
+ {
+ bindingFault.addExtensibilityElement(
+ parseExtensibilityElement(BindingFault.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(bindingFaultEl, BindingFault.class, bindingFault, def);
+
+ return bindingFault;
+ }
+
+ protected Message parseMessage(Element msgEl, Definition def)
+ throws WSDLException
+ {
+ Message msg = null;
+
+ List remainingAttrs = DOMUtils.getAttributes(msgEl);
+ String name = DOMUtils.getAttribute(msgEl, Constants.ATTR_NAME, remainingAttrs);
+
+ if (name != null)
+ {
+ QName messageName = new QName(def.getTargetNamespace(), name);
+
+ msg = def.getMessage(messageName);
+
+ if (msg == null)
+ {
+ msg = def.createMessage();
+ msg.setQName(messageName);
+ }
+ }
+ else
+ {
+ msg = def.createMessage();
+ }
+
+ // Whether it was retrieved or created, the definition has been found.
+ msg.setUndefined(false);
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = msgEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(msgEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ msg.setDocumentationElement(tempEl);
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_PART, tempEl))
+ {
+ msg.addPart(parsePart(tempEl, def));
+ }
+ else
+ {
+ msg.addExtensibilityElement(
+ parseExtensibilityElement(Message.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(msgEl, Message.class, msg, def);
+
+ return msg;
+ }
+
+ protected Part parsePart(Element partEl, Definition def)
+ throws WSDLException
+ {
+ Part part = def.createPart();
+ String name = DOMUtils.getAttribute(partEl, Constants.ATTR_NAME);
+ QName elementName = getQualifiedAttributeValue(partEl,
+ Constants.ATTR_ELEMENT,
+ Constants.ELEM_MESSAGE,
+ def);
+ QName typeName = getQualifiedAttributeValue(partEl,
+ Constants.ATTR_TYPE,
+ Constants.ELEM_MESSAGE,
+ def);
+
+ if (name != null)
+ {
+ part.setName(name);
+ }
+
+ if (elementName != null)
+ {
+ part.setElementName(elementName);
+ }
+
+ if (typeName != null)
+ {
+ part.setTypeName(typeName);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = partEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(partEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ part.setDocumentationElement(tempEl);
+ }
+ else
+ {
+ part.addExtensibilityElement(
+ parseExtensibilityElement(Part.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(partEl, Part.class, part, def);
+
+ return part;
+ }
+
+ protected void parseExtensibilityAttributes(Element el,
+ Class parentType,
+ AttributeExtensible attrExt,
+ Definition def)
+ throws WSDLException
+ {
+ List nativeAttributeNames = attrExt.getNativeAttributeNames();
+ NamedNodeMap nodeMap = el.getAttributes();
+ int length = nodeMap.getLength();
+
+ for (int i = 0; i < length; i++)
+ {
+ Attr attribute = (Attr)nodeMap.item(i);
+ String localName = attribute.getLocalName();
+ String namespaceURI = attribute.getNamespaceURI();
+ String prefix = attribute.getPrefix();
+ QName qname = new QName(namespaceURI, localName);
+
+ if (namespaceURI != null && !namespaceURI.equals(Constants.NS_URI_WSDL))
+ {
+ if (!namespaceURI.equals(Constants.NS_URI_XMLNS))
+ {
+ DOMUtils.registerUniquePrefix(prefix, namespaceURI, def);
+
+ String strValue = attribute.getValue();
+ int attrType = AttributeExtensible.NO_DECLARED_TYPE;
+ ExtensionRegistry extReg = def.getExtensionRegistry();
+
+ if (extReg != null)
+ {
+ attrType = extReg.queryExtensionAttributeType(parentType, qname);
+ }
+
+ Object val = parseExtensibilityAttribute(el, attrType, strValue, def);
+
+ attrExt.setExtensionAttribute(qname, val);
+ }
+ }
+ else if (!nativeAttributeNames.contains(localName))
+ {
+ WSDLException wsdlExc = new WSDLException(WSDLException.INVALID_WSDL,
+ "Encountered illegal " +
+ "extension attribute '" +
+ qname + "'. Extension " +
+ "attributes must be in " +
+ "a namespace other than " +
+ "WSDL's.");
+
+ wsdlExc.setLocation(XPathUtils.getXPathExprFromNode(el));
+
+ throw wsdlExc;
+ }
+ }
+ }
+
+ protected Object parseExtensibilityAttribute(Element el,
+ int attrType,
+ String attrValue,
+ Definition def)
+ throws WSDLException
+ {
+ if (attrType == AttributeExtensible.QNAME_TYPE)
+ {
+ return DOMUtils.getQName(attrValue, el, def);
+ }
+ else if (attrType == AttributeExtensible.LIST_OF_STRINGS_TYPE)
+ {
+ return StringUtils.parseNMTokens(attrValue);
+ }
+ else if (attrType == AttributeExtensible.LIST_OF_QNAMES_TYPE)
+ {
+ List oldList = StringUtils.parseNMTokens(attrValue);
+ int size = oldList.size();
+ List newList = new Vector(size);
+
+ for (int i = 0; i < size; i++)
+ {
+ String str = (String)oldList.get(i);
+ QName qValue = DOMUtils.getQName(str, el, def);
+
+ newList.add(qValue);
+ }
+
+ return newList;
+ }
+ else if (attrType == AttributeExtensible.STRING_TYPE)
+ {
+ return attrValue;
+ }
+ else
+ {
+ QName qValue = null;
+
+ try
+ {
+ qValue = DOMUtils.getQName(attrValue, el, def);
+ }
+ catch (WSDLException e)
+ {
+ qValue = new QName(attrValue);
+ }
+
+ return qValue;
+ }
+ }
+
+ protected PortType parsePortType(Element portTypeEl, Definition def)
+ throws WSDLException
+ {
+ PortType portType = null;
+ String name = DOMUtils.getAttribute(portTypeEl, Constants.ATTR_NAME);
+
+ if (name != null)
+ {
+ QName portTypeName = new QName(def.getTargetNamespace(), name);
+
+ portType = def.getPortType(portTypeName);
+
+ if (portType == null)
+ {
+ portType = def.createPortType();
+ portType.setQName(portTypeName);
+ }
+ }
+ else
+ {
+ portType = def.createPortType();
+ }
+
+ // Whether it was retrieved or created, the definition has been found.
+ portType.setUndefined(false);
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = portTypeEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(portTypeEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ portType.setDocumentationElement(tempEl);
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_OPERATION, tempEl))
+ {
+ Operation op = parseOperation(tempEl, portType, def);
+
+ if (op != null)
+ {
+ portType.addOperation(op);
+ }
+ }
+ else
+ {
+ portType.addExtensibilityElement(
+ parseExtensibilityElement(PortType.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(portTypeEl, PortType.class, portType, def);
+
+ return portType;
+ }
+
+ protected Operation parseOperation(Element opEl,
+ PortType portType,
+ Definition def)
+ throws WSDLException
+ {
+ Operation op = null;
+
+ List remainingAttrs = DOMUtils.getAttributes(opEl);
+ String name = DOMUtils.getAttribute(opEl, Constants.ATTR_NAME, remainingAttrs);
+ String parameterOrderStr = DOMUtils.getAttribute(opEl,
+ Constants.ATTR_PARAMETER_ORDER,
+ remainingAttrs);
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = opEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(opEl);
+ List messageOrder = new Vector();
+ Element docEl = null;
+ Input input = null;
+ Output output = null;
+ List faults = new Vector();
+ List extElements = new Vector();
+ boolean retrieved = true;
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ docEl = tempEl;
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_INPUT, tempEl))
+ {
+ input = parseInput(tempEl, def);
+ messageOrder.add(Constants.ELEM_INPUT);
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_OUTPUT, tempEl))
+ {
+ output = parseOutput(tempEl, def);
+ messageOrder.add(Constants.ELEM_OUTPUT);
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_FAULT, tempEl))
+ {
+ faults.add(parseFault(tempEl, def));
+ }
+ else
+ {
+ extElements.add(
+ parseExtensibilityElement(Operation.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ if (name != null)
+ {
+ String inputName = (input != null
+ ? (input.getName() != null ? input.getName() : Constants.NONE)
+ : null);
+ String outputName = (output != null
+ ? (output.getName() != null ? output.getName() : Constants.NONE)
+ : null);
+
+ op = portType.getOperation(name, inputName, outputName);
+
+ if (op != null && !op.isUndefined())
+ {
+ op = null;
+ }
+
+ if (op != null)
+ {
+ if (inputName == null)
+ {
+ Input tempIn = op.getInput();
+
+ if (tempIn != null)
+ {
+ if (tempIn.getName() != null)
+ {
+ op = null;
+ }
+ }
+ }
+ }
+
+ if (op != null)
+ {
+ if (outputName == null)
+ {
+ Output tempOut = op.getOutput();
+
+ if (tempOut != null)
+ {
+ if (tempOut.getName() != null)
+ {
+ op = null;
+ }
+ }
+ }
+ }
+
+ if (op == null)
+ {
+ op = def.createOperation();
+ op.setName(name);
+ retrieved = false;
+ }
+ }
+ else
+ {
+ op = def.createOperation();
+ retrieved = false;
+ }
+
+ // Whether it was retrieved or created, the definition has been found.
+ op.setUndefined(false);
+
+ if (parameterOrderStr != null)
+ {
+ op.setParameterOrdering(StringUtils.parseNMTokens(parameterOrderStr));
+ }
+
+ if (docEl != null)
+ {
+ op.setDocumentationElement(docEl);
+ }
+
+ if (input != null)
+ {
+ op.setInput(input);
+ }
+
+ if (output != null)
+ {
+ op.setOutput(output);
+ }
+
+ if (faults.size() > 0)
+ {
+ Iterator faultIterator = faults.iterator();
+
+ while (faultIterator.hasNext())
+ {
+ op.addFault((Fault)faultIterator.next());
+ }
+ }
+
+ if (extElements.size() > 0)
+ {
+ Iterator eeIterator = extElements.iterator();
+
+ while (eeIterator.hasNext())
+ {
+ op.addExtensibilityElement(
+ (ExtensibilityElement) eeIterator.next() );
+ }
+ }
+
+ OperationType style = null;
+
+ if (messageOrder.equals(STYLE_ONE_WAY))
+ {
+ style = OperationType.ONE_WAY;
+ }
+ else if (messageOrder.equals(STYLE_REQUEST_RESPONSE))
+ {
+ style = OperationType.REQUEST_RESPONSE;
+ }
+ else if (messageOrder.equals(STYLE_SOLICIT_RESPONSE))
+ {
+ style = OperationType.SOLICIT_RESPONSE;
+ }
+ else if (messageOrder.equals(STYLE_NOTIFICATION))
+ {
+ style = OperationType.NOTIFICATION;
+ }
+
+ if (style != null)
+ {
+ op.setStyle(style);
+ }
+
+ if (retrieved)
+ {
+ op = null;
+ }
+
+ parseExtensibilityAttributes(opEl, Operation.class, op, def);
+
+ return op;
+ }
+
+ protected Service parseService(Element serviceEl, Definition def)
+ throws WSDLException
+ {
+ Service service = def.createService();
+
+ List remainingAttrs = DOMUtils.getAttributes(serviceEl);
+ String name = DOMUtils.getAttribute(serviceEl, Constants.ATTR_NAME, remainingAttrs);
+
+ if (name != null)
+ {
+ service.setQName(new QName(def.getTargetNamespace(), name));
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = serviceEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(serviceEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ service.setDocumentationElement(tempEl);
+ }
+ else if (QNameUtils.matches(Constants.Q_ELEM_PORT, tempEl))
+ {
+ service.addPort(parsePort(tempEl, def));
+ }
+ else
+ {
+ service.addExtensibilityElement(
+ parseExtensibilityElement(Service.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(serviceEl, Service.class, service, def);
+
+ return service;
+ }
+
+ protected Port parsePort(Element portEl, Definition def)
+ throws WSDLException
+ {
+ Port port = def.createPort();
+
+ List remainingAttrs = DOMUtils.getAttributes(portEl);
+ String name = DOMUtils.getAttribute(portEl, Constants.ATTR_NAME, remainingAttrs);
+ QName bindingStr = getQualifiedAttributeValue(portEl,
+ Constants.ATTR_BINDING,
+ Constants.ELEM_PORT,
+ def,
+ remainingAttrs);
+
+ if (name != null)
+ {
+ port.setName(name);
+ }
+
+ if (bindingStr != null)
+ {
+ Binding binding = def.getBinding(bindingStr);
+
+ if (binding == null)
+ {
+ binding = def.createBinding();
+ binding.setQName(bindingStr);
+ def.addBinding(binding);
+ }
+
+ port.setBinding(binding);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = portEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(portEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ port.setDocumentationElement(tempEl);
+ }
+ else
+ {
+ port.addExtensibilityElement(parseExtensibilityElement(Port.class,
+ tempEl,
+ def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(portEl, Port.class, port, def);
+
+ return port;
+ }
+
+ protected ExtensibilityElement parseExtensibilityElement(
+ Class parentType,
+ Element el,
+ Definition def)
+ throws WSDLException
+ {
+ QName elementType = QNameUtils.newQName(el);
+
+ String namespaceURI = el.getNamespaceURI();
+
+ try
+ {
+ if (namespaceURI == null || namespaceURI.equals(Constants.NS_URI_WSDL))
+ {
+ throw new WSDLException(WSDLException.INVALID_WSDL,
+ "Encountered illegal extension element '" +
+ elementType +
+ "' in the context of a '" +
+ parentType.getName() +
+ "'. Extension elements must be in " +
+ "a namespace other than WSDL's.");
+ }
+
+ ExtensionRegistry extReg = def.getExtensionRegistry();
+
+ if (extReg == null)
+ {
+ throw new WSDLException(WSDLException.CONFIGURATION_ERROR,
+ "No ExtensionRegistry set for this " +
+ "Definition, so unable to deserialize " +
+ "a '" + elementType + "' element in the " +
+ "context of a '" + parentType.getName() +
+ "'.");
+ }
+
+ ExtensionDeserializer extDS = extReg.queryDeserializer(parentType,
+ elementType);
+
+ return extDS.unmarshall(parentType, elementType, el, def, extReg);
+ }
+ catch (WSDLException e)
+ {
+ if (e.getLocation() == null)
+ {
+ e.setLocation(XPathUtils.getXPathExprFromNode(el));
+ }
+
+ throw e;
+ }
+ }
+
+ protected Input parseInput(Element inputEl, Definition def)
+ throws WSDLException
+ {
+ Input input = def.createInput();
+ String name = DOMUtils.getAttribute(inputEl, Constants.ATTR_NAME);
+ QName messageName = getQualifiedAttributeValue(inputEl,
+ Constants.ATTR_MESSAGE,
+ Constants.ELEM_INPUT,
+ def);
+
+ if (name != null)
+ {
+ input.setName(name);
+ }
+
+ if (messageName != null)
+ {
+ Message message = def.getMessage(messageName);
+
+ if (message == null)
+ {
+ message = def.createMessage();
+ message.setQName(messageName);
+ def.addMessage(message);
+ }
+
+ input.setMessage(message);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = inputEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(inputEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ input.setDocumentationElement(tempEl);
+ }
+ else
+ {
+ input.addExtensibilityElement(
+ parseExtensibilityElement(Input.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(inputEl, Input.class, input, def);
+
+ return input;
+ }
+
+ protected Output parseOutput(Element outputEl, Definition def)
+ throws WSDLException
+ {
+ Output output = def.createOutput();
+ String name = DOMUtils.getAttribute(outputEl, Constants.ATTR_NAME);
+ QName messageName = getQualifiedAttributeValue(outputEl,
+ Constants.ATTR_MESSAGE,
+ Constants.ELEM_OUTPUT,
+ def);
+
+ if (name != null)
+ {
+ output.setName(name);
+ }
+
+ if (messageName != null)
+ {
+ Message message = def.getMessage(messageName);
+
+ if (message == null)
+ {
+ message = def.createMessage();
+ message.setQName(messageName);
+ def.addMessage(message);
+ }
+
+ output.setMessage(message);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = outputEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(outputEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ output.setDocumentationElement(tempEl);
+ }
+ else
+ {
+ output.addExtensibilityElement(
+ parseExtensibilityElement(Output.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(outputEl, Output.class, output, def);
+
+ return output;
+ }
+
+ protected Fault parseFault(Element faultEl, Definition def)
+ throws WSDLException
+ {
+ Fault fault = def.createFault();
+ String name = DOMUtils.getAttribute(faultEl, Constants.ATTR_NAME);
+ QName messageName = getQualifiedAttributeValue(faultEl,
+ Constants.ATTR_MESSAGE,
+ Constants.ELEM_FAULT,
+ def);
+
+ if (name != null)
+ {
+ fault.setName(name);
+ }
+
+ if (messageName != null)
+ {
+ Message message = def.getMessage(messageName);
+
+ if (message == null)
+ {
+ message = def.createMessage();
+ message.setQName(messageName);
+ def.addMessage(message);
+ }
+
+ fault.setMessage(message);
+ }
+
+ //register any NS decls with the Definition
+ NamedNodeMap attrs = faultEl.getAttributes();
+ registerNSDeclarations(attrs, def);
+
+ Element tempEl = DOMUtils.getFirstChildElement(faultEl);
+
+ while (tempEl != null)
+ {
+ if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+ {
+ fault.setDocumentationElement(tempEl);
+ }
+ else
+ {
+ fault.addExtensibilityElement(
+ parseExtensibilityElement(Fault.class, tempEl, def));
+ }
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
+
+ parseExtensibilityAttributes(faultEl, Fault.class, fault, def);
+
+ return fault;
+ }
+
+ /**
+ * This method should be used for elements that support extension
+ * attributes because it does not track unexpected remaining attributes.
+ */
+ private static QName getQualifiedAttributeValue(Element el,
+ String attrName,
+ String elDesc,
+ Definition def)
+ throws WSDLException
+ {
+ try
+ {
+ return DOMUtils.getQualifiedAttributeValue(el,
+ attrName,
+ elDesc,
+ false,
+ def);
+ }
+ catch (WSDLException e)
+ {
+ if (e.getFaultCode().equals(WSDLException.NO_PREFIX_SPECIFIED))
+ {
+ String attrValue = DOMUtils.getAttribute(el, attrName);
+
+ return new QName(attrValue);
+ }
+ else
+ {
+ throw e;
+ }
+ }
+ }
+
+ /**
+ * This method should be used for elements that do not support extension
+ * attributes because it tracks unexpected remaining attributes.
+ */
+ private static QName getQualifiedAttributeValue(Element el,
+ String attrName,
+ String elDesc,
+ Definition def,
+ List remainingAttrs)
+ throws WSDLException
+ {
+ try
+ {
+ return DOMUtils.getQualifiedAttributeValue(el,
+ attrName,
+ elDesc,
+ false,
+ def,
+ remainingAttrs);
+ }
+ catch (WSDLException e)
+ {
+ if (e.getFaultCode().equals(WSDLException.NO_PREFIX_SPECIFIED))
+ {
+ String attrValue = DOMUtils.getAttribute(el, attrName, remainingAttrs);
+
+ return new QName(attrValue);
+ }
+ else
+ {
+ throw e;
+ }
+ }
+ }
+
+ private static void checkElementName(Element el, QName qname)
+ throws WSDLException
+ {
+ if (!QNameUtils.matches(qname, el))
+ {
+ WSDLException wsdlExc = new WSDLException(WSDLException.INVALID_WSDL,
+ "Expected element '" +
+ qname + "'.");
+
+ wsdlExc.setLocation(XPathUtils.getXPathExprFromNode(el));
+
+ throw wsdlExc;
+ }
+ }
+
+ private static Document getDocument(InputSource inputSource,
+ String desc) throws WSDLException
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+
+ factory.setNamespaceAware(true);
+ factory.setValidating(false);
+
+ try
+ {
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ builder.setEntityResolver( new JBossWSEntityResolver() );
+ Document doc = builder.parse(inputSource);
+
+ return doc;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new WSDLException(WSDLException.PARSER_ERROR,
+ "Problem parsing '" + desc + "'.",
+ e);
+ }
+ }
+
+ private static void registerNSDeclarations(NamedNodeMap attrs, Definition def)
+ {
+ int size = attrs.getLength();
+
+ for (int i = 0; i < size; i++)
+ {
+ Attr attr = (Attr)attrs.item(i);
+ String namespaceURI = attr.getNamespaceURI();
+ String localPart = attr.getLocalName();
+ String value = attr.getValue();
+
+ if (namespaceURI != null && namespaceURI.equals(Constants.NS_URI_XMLNS))
+ {
+ if (localPart != null && !localPart.equals(Constants.ATTR_XMLNS))
+ {
+ DOMUtils.registerUniquePrefix(localPart, value, def);
+ }
+ else
+ {
+ DOMUtils.registerUniquePrefix(null, value, def);
+ }
+ }
+ }
+ }
+
+ /**
+ * Read the WSDL document accessible via the specified
+ * URI into a WSDL definition.
+ *
+ * @param wsdlURI a URI (can be a filename or URL) pointing to a
+ * WSDL XML definition.
+ * @return the definition.
+ */
+ public Definition readWSDL(String wsdlURI) throws WSDLException
+ {
+ return readWSDL(null, wsdlURI);
+ }
+
+ /**
+ * Read the WSDL document accessible via the specified
+ * URI into a WSDL definition.
+ *
+ * @param contextURI the context in which to resolve the
+ * wsdlURI, if the wsdlURI is relative. Can be null, in which
+ * case it will be ignored.
+ * @param wsdlURI a URI (can be a filename or URL) pointing to a
+ * WSDL XML definition.
+ * @return the definition.
+ */
+ public Definition readWSDL(String contextURI, String wsdlURI)
+ throws WSDLException
+ {
+ try
+ {
+ if (verbose)
+ {
+ System.out.println("Retrieving document at '" + wsdlURI + "'" +
+ (contextURI == null
+ ? "."
+ : ", relative to '" + contextURI + "'."));
+ }
+
+ URL contextURL = (contextURI != null)
+ ? StringUtils.getURL(null, contextURI)
+ : null;
+ URL url = StringUtils.getURL(contextURL, wsdlURI);
+ InputStream inputStream = StringUtils.getContentAsInputStream(url);
+ InputSource inputSource = new InputSource(inputStream);
+ inputSource.setSystemId(url.toString());
+ Document doc = getDocument(inputSource, url.toString());
+
+ inputStream.close();
+
+ Definition def = readWSDL(url.toString(), doc);
+
+ return def;
+ }
+ catch (WSDLException e)
+ {
+ throw e;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new WSDLException(WSDLException.OTHER_ERROR,
+ "Unable to resolve imported document at '" +
+ wsdlURI +
+ (contextURI == null
+ ? "'."
+ : "', relative to '" + contextURI + "'.")
+ , e);
+ }
+ }
+
+ /**
+ * Read the specified <wsdl:definitions> element into a WSDL
+ * definition.
+ *
+ * @param documentBaseURI the document base URI of the WSDL definition
+ * described by the element. Will be set as the documentBaseURI
+ * of the returned Definition. Can be null, in which case it
+ * will be ignored.
+ * @param definitionsElement the <wsdl:definitions> element
+ * @return the definition described by the element.
+ */
+ public Definition readWSDL(String documentBaseURI,
+ Element definitionsElement)
+ throws WSDLException
+ {
+ return readWSDL(documentBaseURI, definitionsElement, null);
+ }
+
+ /**
+ * Read the specified <wsdl:definitions> element into a WSDL
+ * definition. The WSDLLocator is used to provide the document
+ * base URIs. The InputSource of the WSDLLocator is ignored, instead
+ * the WSDL is parsed from the given Element.
+ *
+ * @param locator A WSDLLocator object used to provide
+ * the document base URI of the WSDL definition described by the
+ * element.
+ * @param definitionsElement the <wsdl:definitions> element
+ * @return the definition described by the element.
+ */
+ public Definition readWSDL(WSDLLocator locator,
+ Element definitionsElement)
+ throws WSDLException
+ {
+ try
+ {
+ this.loc = locator;
+ return readWSDL(locator.getBaseURI(), definitionsElement, null);
+ }
+ finally
+ {
+ locator.close();
+ this.loc = null;
+ }
+ }
+
+ protected Definition readWSDL(String documentBaseURI,
+ Element definitionsElement,
+ Map importedDefs)
+ throws WSDLException
+ {
+ return parseDefinitions(documentBaseURI, definitionsElement, importedDefs);
+ }
+
+ /**
+ * Read the specified WSDL document into a WSDL definition.
+ *
+ * @param documentBaseURI the document base URI of the WSDL definition
+ * described by the document. Will be set as the documentBaseURI
+ * of the returned Definition. Can be null, in which case it
+ * will be ignored.
+ * @param wsdlDocument the WSDL document, an XML
+ * document obeying the WSDL schema.
+ * @return the definition described in the document.
+ */
+ public Definition readWSDL(String documentBaseURI, Document wsdlDocument)
+ throws WSDLException
+ {
+ return readWSDL(documentBaseURI, wsdlDocument.getDocumentElement());
+ }
+
+ /**
+ * Read a WSDL document into a WSDL definition.
+ *
+ * @param documentBaseURI the document base URI of the WSDL definition
+ * described by the document. Will be set as the documentBaseURI
+ * of the returned Definition. Can be null, in which case it
+ * will be ignored.
+ * @param inputSource an InputSource pointing to the
+ * WSDL document, an XML document obeying the WSDL schema.
+ * @return the definition described in the document pointed to
+ * by the InputSource.
+ */
+ public Definition readWSDL(String documentBaseURI, InputSource inputSource)
+ throws WSDLException
+ {
+ String location = (inputSource.getSystemId() != null ?
+ inputSource.getSystemId() : "- WSDL Document -");
+
+ return readWSDL(documentBaseURI,
+ getDocument(inputSource, location));
+ }
+
+ /**
+ * Read a WSDL document into a WSDL definition.
+ *
+ * @param locator A WSDLLocator object used to provide InputSources
+ * pointing to the wsdl file.
+ * @return the definition described in the document
+ */
+ public Definition readWSDL(WSDLLocator locator) throws WSDLException
+ {
+ InputSource is = locator.getBaseInputSource();
+ String base = locator.getBaseURI();
+
+ if (is == null)
+ {
+ throw new WSDLException(WSDLException.OTHER_ERROR,
+ "Unable to locate document at '" + base + "'.");
+ }
+ is.setSystemId(base);
+
+ this.loc = locator;
+
+ if (verbose)
+ {
+ System.out.println("Retrieving document at '" + base + "'.");
+ }
+
+ try
+ {
+ return readWSDL(base, is);
+ }
+ finally
+ {
+ this.loc.close();
+ this.loc = null;
+ }
+ }
+}
+
Property changes on: legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/tools/wsdl/JBossWSDLReaderImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/tools/wsdl/WSDLDefinitionsFactory.java
===================================================================
--- legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/tools/wsdl/WSDLDefinitionsFactory.java 2007-11-29 11:18:14 UTC (rev 5145)
+++ legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/tools/wsdl/WSDLDefinitionsFactory.java 2007-11-29 12:28:47 UTC (rev 5146)
@@ -109,7 +109,7 @@
String defaultNamespace = getDefaultNamespace(wsdlDoc);
if (Constants.NS_WSDL11.equals(defaultNamespace))
{
- WSDLFactory wsdlFactory = WSDLFactory.newInstance();
+ WSDLFactory wsdlFactory = WSDLFactory.newInstance(JBossWSDLFactoryImpl.class.getName());
WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose", false);
@@ -132,8 +132,9 @@
wsdlDefinitions.setWsdlDocument(wsdlDoc);
}
else
+ {
throw new WSDLException("Invalid default namespace: " + defaultNamespace);
-
+ }
if (log.isTraceEnabled())
{
StringWriter stwr = new StringWriter();
17 years, 3 months
JBossWS SVN: r5145 - in framework/trunk/hudson/hudson-home: jobs and 2 other directories.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2007-11-29 06:18:14 -0500 (Thu, 29 Nov 2007)
New Revision: 5145
Added:
framework/trunk/hudson/hudson-home/jobs/Distro-Native-AS-4.0.5-No-EJB3/
framework/trunk/hudson/hudson-home/jobs/Distro-Native-AS-4.0.5-No-EJB3/config.xml
Modified:
framework/trunk/hudson/hudson-home/config.xml
framework/trunk/hudson/hudson-home/jobs/Distro-ALL/config.xml
Log:
[JBWS-1914] new Hudson job
Modified: framework/trunk/hudson/hudson-home/config.xml
===================================================================
--- framework/trunk/hudson/hudson-home/config.xml 2007-11-29 10:38:22 UTC (rev 5144)
+++ framework/trunk/hudson/hudson-home/config.xml 2007-11-29 11:18:14 UTC (rev 5145)
@@ -75,6 +75,7 @@
<no-comparator/>
<string>Distro-ALL</string>
<string>Distro-Native-AS-4.0.5</string>
+ <string>Distro-Native-AS-4.0.5-No-EJB3</string>
<string>Distro-Native-AS-4.2.1</string>
<string>Distro-Native-AS-4.2.2</string>
<string>Distro-Native-AS-4.2.2-JDK6</string>
Modified: framework/trunk/hudson/hudson-home/jobs/Distro-ALL/config.xml
===================================================================
--- framework/trunk/hudson/hudson-home/jobs/Distro-ALL/config.xml 2007-11-29 10:38:22 UTC (rev 5144)
+++ framework/trunk/hudson/hudson-home/jobs/Distro-ALL/config.xml 2007-11-29 11:18:14 UTC (rev 5145)
@@ -3,7 +3,7 @@
<builders class="vector"/>
<publishers class="vector">
<hudson.tasks.BuildTrigger>
- <childProjects>Distro-Native-AS-4.0.5, Distro-Native-AS-4.2.1, Distro-Native-AS-4.2.2, Distro-Native-AS-4.2.2-JDK6, Distro-Native-AS-5.0.0, Distro-Metro-AS-4.2.2, Distro-Metro-AS-5.0.0, Distro-CXF-AS-4.2.2, Distro-CXF-AS-5.0.0</childProjects>
+ <childProjects>Distro-Native-AS-4.0.5, Distro-Native-AS-4.0.5-No-EJB3, Distro-Native-AS-4.2.1, Distro-Native-AS-4.2.2, Distro-Native-AS-4.2.2-JDK6, Distro-Native-AS-5.0.0, Distro-Metro-AS-4.2.2, Distro-Metro-AS-5.0.0, Distro-CXF-AS-4.2.2, Distro-CXF-AS-5.0.0</childProjects>
</hudson.tasks.BuildTrigger>
</publishers>
<buildWrappers class="vector"/>
@@ -20,4 +20,4 @@
<properties/>
<description>Run all distribution tests</description>
<actions class="vector"/>
-</project>
\ No newline at end of file
+</project>
Added: framework/trunk/hudson/hudson-home/jobs/Distro-Native-AS-4.0.5-No-EJB3/config.xml
===================================================================
--- framework/trunk/hudson/hudson-home/jobs/Distro-Native-AS-4.0.5-No-EJB3/config.xml (rev 0)
+++ framework/trunk/hudson/hudson-home/jobs/Distro-Native-AS-4.0.5-No-EJB3/config.xml 2007-11-29 11:18:14 UTC (rev 5145)
@@ -0,0 +1,115 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<project>
+ <builders class="vector">
+ <hudson.tasks.Shell>
+ <command>
+#
+# Module settings
+#
+MODULE=Distro-Native-AS-4.0.5-No-EJB3
+
+WORKSPACE=`pwd`
+FRAMEWORKDIR=$WORKSPACE/framework
+STACKNATIVE=$WORKSPACE/stack-native
+STACKMETRO=$WORKSPACE/stack-metro
+STACKCXF=$WORKSPACE/stack-cxf
+JBOSS_BINDADDR=(a)jboss.bind.address@
+JBOSS500_INSTANCE=@hudson.home@/jobs/AS-5.0.0/workspace/JBossAS-5.0.0/build/output/(a)hudson.jboss500.build@
+JBOSS422_INSTANCE=@hudson.home@/jobs/AS-4.2.2/workspace/JBossAS-4.2.2/build/output/(a)hudson.jboss422.build@
+JBOSS405_INSTANCE=@hudson.home@/jobs/AS-4.0.5/workspace/JBossAS-4.0.5/build/output/(a)hudson.jboss405.build@
+JBOSS_INSTANCE=$JBOSS405_INSTANCE
+ENVIRONMENT="-Djboss.bind.address=(a)jboss.bind.address@ -Djbossws.integration.target=jboss405.no.ejb3 -Djboss500.home=$JBOSS500_INSTANCE -Djboss422.home=$JBOSS422_INSTANCE -Djboss405.home=$JBOSS405_INSTANCE"
+
+#
+# stop jbossas
+#
+$FRAMEWORKDIR/hudson/jboss/bin/jboss.sh $JBOSS_INSTANCE stop
+
+#
+# Build distro
+#
+cd $STACKNATIVE
+cp ant.properties.example ant.properties
+./build.sh $ENVIRONMENT clean build-bin-dist
+
+#
+# Deploy distro
+#
+cd output/jbossws-native-(a)version.id@
+./build.sh $ENVIRONMENT deploy-jboss405
+
+#
+# start jbossas
+#
+$FRAMEWORKDIR/hudson/jboss/bin/jboss.sh $JBOSS_INSTANCE start $JBOSS_BINDADDR
+
+# Was it successfully started?
+$FRAMEWORKDIR/hudson/jboss/bin/http-spider.sh $JBOSS_BINDADDR:8080 $WORKSPACE
+if [ -e $WORKSPACE/spider.failed ]; then
+ tail -n 100 $JBOSS_INSTANCE/server/@jboss.server.instance(a)/log/server.log
+ $FRAMEWORKDIR/hudson/jboss/bin/jboss.sh $JBOSS_INSTANCE stop $JBOSS_BINDADDR
+ exit 1
+fi
+
+#
+# execute tests
+#
+./build.sh $ENVIRONMENT tests-clean tests 2>&1 | tee $WORKSPACE/tests.out
+cat $WORKSPACE/tests.out | egrep FIXME\|FAILED | sort -u
+
+#
+# stop jbossas
+#
+$FRAMEWORKDIR/hudson/jboss/bin/jboss.sh $JBOSS_INSTANCE stop
+</command>
+ </hudson.tasks.Shell>
+ </builders>
+ <publishers class="vector">
+ <hudson.tasks.junit.JUnitResultArchiver>
+ <testResults>stack-native/output/jbossws-native-@version.id(a)/output/reports/*.xml</testResults>
+ </hudson.tasks.junit.JUnitResultArchiver>
+ <hudson.tasks.Mailer>
+ <recipients>@hudson.mail.recipients@</recipients>
+ <dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
+ <sendToIndividuals>true</sendToIndividuals>
+ </hudson.tasks.Mailer>
+ </publishers>
+ <buildWrappers class="vector"/>
+ <scm class="hudson.scm.SubversionSCM">
+ <locations>
+ <hudson.scm.SubversionSCM-ModuleLocation>
+ <remote>@hudson.framework.url@</remote>
+ <local>framework</local>
+ </hudson.scm.SubversionSCM-ModuleLocation>
+ <hudson.scm.SubversionSCM-ModuleLocation>
+ <remote>@hudson.native.url@</remote>
+ <local>stack-native</local>
+ </hudson.scm.SubversionSCM-ModuleLocation>
+ <hudson.scm.SubversionSCM-ModuleLocation>
+ <remote>@hudson.metro.url@</remote>
+ <local>stack-metro</local>
+ </hudson.scm.SubversionSCM-ModuleLocation>
+ <hudson.scm.SubversionSCM-ModuleLocation>
+ <remote>@hudson.cxf.url@</remote>
+ <local>stack-cxf</local>
+ </hudson.scm.SubversionSCM-ModuleLocation>
+ </locations>
+ <useUpdate>true</useUpdate>
+ <browser class="hudson.scm.browsers.FishEyeSVN">
+ <url>http://fisheye.jboss.com/browse/JBossWS/</url>
+ <rootModule></rootModule>
+ </browser>
+ </scm>
+ <canRoam>true</canRoam>
+ <disabled>false</disabled>
+ <enableRemoteTrigger>false</enableRemoteTrigger>
+ <triggers class="vector"/>
+ <logRotator>
+ <daysToKeep>-1</daysToKeep>
+ <numToKeep>20</numToKeep>
+ </logRotator>
+ <keepDependencies>false</keepDependencies>
+ <properties/>
+ <description>Build and test jbossws-native-(a)version.id@ against AS-4.0.5 without EJB3 support</description>
+ <actions class="vector"/>
+</project>
\ No newline at end of file
Property changes on: framework/trunk/hudson/hudson-home/jobs/Distro-Native-AS-4.0.5-No-EJB3/config.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
17 years, 3 months
JBossWS SVN: r5144 - in stack/native/trunk/src/main/java/org/jboss/ws: extensions/wsrm/transport/backchannel and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2007-11-29 05:38:22 -0500 (Thu, 29 Nov 2007)
New Revision: 5144
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/core/MessageTrace.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMCallbackHandlerImpl.java
Log:
beautify WSRM messages
Modified: stack/native/trunk/src/main/java/org/jboss/ws/core/MessageTrace.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/core/MessageTrace.java 2007-11-29 09:40:23 UTC (rev 5143)
+++ stack/native/trunk/src/main/java/org/jboss/ws/core/MessageTrace.java 2007-11-29 10:38:22 UTC (rev 5144)
@@ -23,13 +23,17 @@
// $Id$
+import java.io.ByteArrayInputStream;
+
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
+import javax.xml.transform.stream.StreamSource;
import org.jboss.logging.Logger;
import org.jboss.ws.core.soap.SOAPElementImpl;
import org.jboss.ws.core.soap.SOAPElementWriter;
+import org.jboss.ws.core.soap.XMLFragment;
import org.jboss.wsf.common.DOMWriter;
import org.w3c.dom.Element;
@@ -77,7 +81,9 @@
}
else if (message instanceof byte[])
{
- msgLog.trace(messagePrefix + "\n" + new String((byte[])message));
+ Element root = new XMLFragment(new StreamSource(new ByteArrayInputStream((byte[])message))).toElement();
+ String xmlString = DOMWriter.printNode(root, true);
+ msgLog.trace(messagePrefix + "\n" + xmlString);
}
else
{
Modified: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMCallbackHandlerImpl.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMCallbackHandlerImpl.java 2007-11-29 09:40:23 UTC (rev 5143)
+++ stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/backchannel/RMCallbackHandlerImpl.java 2007-11-29 10:38:22 UTC (rev 5144)
@@ -95,7 +95,7 @@
this.listener.unassignedMessageReceived();
}
}
- logger.debug("Message content is: " + requestMessage);
+ MessageTrace.traceMessage("Incoming RM Response Message (callback)", requestMessage.getBytes());
}
}
17 years, 3 months
JBossWS SVN: r5143 - in framework/trunk/hudson/hudson-home: jobs/Integration-ALL and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2007-11-29 04:40:23 -0500 (Thu, 29 Nov 2007)
New Revision: 5143
Modified:
framework/trunk/hudson/hudson-home/config.xml
framework/trunk/hudson/hudson-home/jobs/Integration-ALL/config.xml
Log:
[JBWS-1914] other hudson dependencies
Modified: framework/trunk/hudson/hudson-home/config.xml
===================================================================
--- framework/trunk/hudson/hudson-home/config.xml 2007-11-29 09:36:15 UTC (rev 5142)
+++ framework/trunk/hudson/hudson-home/config.xml 2007-11-29 09:40:23 UTC (rev 5143)
@@ -101,6 +101,7 @@
<no-comparator/>
<string>Integration-ALL</string>
<string>Integration-Native-AS-4.0.5</string>
+ <string>Integration-Native-AS-4.0.5-No-EJB3</string>
<string>Integration-Native-AS-4.2.1</string>
<string>Integration-Native-AS-4.2.2</string>
<string>Integration-Native-AS-5.0.0</string>
@@ -162,4 +163,4 @@
</view>
</views>
-</hudson>
\ No newline at end of file
+</hudson>
Modified: framework/trunk/hudson/hudson-home/jobs/Integration-ALL/config.xml
===================================================================
--- framework/trunk/hudson/hudson-home/jobs/Integration-ALL/config.xml 2007-11-29 09:36:15 UTC (rev 5142)
+++ framework/trunk/hudson/hudson-home/jobs/Integration-ALL/config.xml 2007-11-29 09:40:23 UTC (rev 5143)
@@ -3,7 +3,7 @@
<builders class="vector"/>
<publishers class="vector">
<hudson.tasks.BuildTrigger>
- <childProjects>Integration-Native-AS-4.0.5, Integration-Native-AS-4.2.1, Integration-Native-AS-4.2.2, Integration-Native-AS-5.0.0, Integration-Metro-AS-4.2.2, Integration-Metro-AS-5.0.0, Integration-CXF-AS-4.2.2, Integration-CXF-AS-5.0.0</childProjects>
+ <childProjects>Integration-Native-AS-4.0.5, Integration-Native-AS-4.0.5-No-EJB3, Integration-Native-AS-4.2.1, Integration-Native-AS-4.2.2, Integration-Native-AS-5.0.0, Integration-Metro-AS-4.2.2, Integration-Metro-AS-5.0.0, Integration-CXF-AS-4.2.2, Integration-CXF-AS-5.0.0</childProjects>
</hudson.tasks.BuildTrigger>
</publishers>
<buildWrappers class="vector"/>
@@ -20,4 +20,4 @@
<properties/>
<description>Run all integration tests</description>
<actions class="vector"/>
-</project>
\ No newline at end of file
+</project>
17 years, 3 months
JBossWS SVN: r5142 - in framework/trunk/hudson/hudson-home/jobs: Integration-Native-AS-4.0.5-No-EJB3 and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2007-11-29 04:36:15 -0500 (Thu, 29 Nov 2007)
New Revision: 5142
Added:
framework/trunk/hudson/hudson-home/jobs/Integration-Native-AS-4.0.5-No-EJB3/
framework/trunk/hudson/hudson-home/jobs/Integration-Native-AS-4.0.5-No-EJB3/config.xml
Log:
[JBWS-1914] adding new task to Hudson
Added: framework/trunk/hudson/hudson-home/jobs/Integration-Native-AS-4.0.5-No-EJB3/config.xml
===================================================================
--- framework/trunk/hudson/hudson-home/jobs/Integration-Native-AS-4.0.5-No-EJB3/config.xml (rev 0)
+++ framework/trunk/hudson/hudson-home/jobs/Integration-Native-AS-4.0.5-No-EJB3/config.xml 2007-11-29 09:36:15 UTC (rev 5142)
@@ -0,0 +1,106 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<project>
+ <builders class="vector">
+ <hudson.tasks.Shell>
+ <command>
+#
+# Module settings
+#
+MODULE=Integration-Native-AS-4.0.5-No-EJB3
+
+WORKSPACE=`pwd`
+FRAMEWORKDIR=$WORKSPACE/framework
+STACKNATIVE=$WORKSPACE/stack-native
+STACKMETRO=$WORKSPACE/stack-metro
+STACKCXF=$WORKSPACE/stack-cxf
+JBOSS_BINDADDR=(a)jboss.bind.address@
+JBOSS_INSTANCE=@hudson.home@/jobs/AS-4.0.5/workspace/JBossAS-4.0.5/build/output/(a)hudson.jboss405.build@
+ENVIRONMENT="-Djboss.bind.address=(a)jboss.bind.address@ -Djbossws.integration.target=jboss405.no.ejb3 -Djboss405.home=$JBOSS_INSTANCE"
+
+#
+# stop jbossas
+#
+$FRAMEWORKDIR/hudson/jboss/bin/jboss.sh $JBOSS_INSTANCE stop
+
+#
+# build and deploy
+#
+cd $STACKNATIVE
+cp ant.properties.example ant.properties
+./build.sh $ENVIRONMENT -Dforce.thirdparty.get=true clean deploy-jboss405
+
+#
+# start jbossas
+#
+$FRAMEWORKDIR/hudson/jboss/bin/jboss.sh $JBOSS_INSTANCE start $JBOSS_BINDADDR
+
+# Was it successfully started?
+$FRAMEWORKDIR/hudson/jboss/bin/http-spider.sh $JBOSS_BINDADDR:8080 $WORKSPACE
+if [ -e $WORKSPACE/spider.failed ]; then
+ tail -n 100 $JBOSS_INSTANCE/server/@jboss.server.instance(a)/log/server.log
+ $FRAMEWORKDIR/hudson/jboss/bin/jboss.sh $JBOSS_INSTANCE stop $JBOSS_BINDADDR
+ exit 1
+fi
+
+#
+# execute tests
+#
+./build.sh $ENVIRONMENT tests-clean tests-integration 2>&1 | tee $WORKSPACE/tests.out
+cat $WORKSPACE/tests.out | egrep FIXME\|FAILED | sort -u
+
+#
+# stop jbossas
+#
+$FRAMEWORKDIR/hudson/jboss/bin/jboss.sh $JBOSS_INSTANCE stop
+</command>
+ </hudson.tasks.Shell>
+ </builders>
+ <publishers class="vector">
+ <hudson.tasks.junit.JUnitResultArchiver>
+ <testResults>stack-native/output/tests/reports/*.xml</testResults>
+ </hudson.tasks.junit.JUnitResultArchiver>
+ <hudson.tasks.Mailer>
+ <recipients>@hudson.mail.recipients@</recipients>
+ <dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
+ <sendToIndividuals>true</sendToIndividuals>
+ </hudson.tasks.Mailer>
+ </publishers>
+ <buildWrappers class="vector"/>
+ <scm class="hudson.scm.SubversionSCM">
+ <locations>
+ <hudson.scm.SubversionSCM-ModuleLocation>
+ <remote>@hudson.framework.url@</remote>
+ <local>framework</local>
+ </hudson.scm.SubversionSCM-ModuleLocation>
+ <hudson.scm.SubversionSCM-ModuleLocation>
+ <remote>@hudson.native.url@</remote>
+ <local>stack-native</local>
+ </hudson.scm.SubversionSCM-ModuleLocation>
+ <hudson.scm.SubversionSCM-ModuleLocation>
+ <remote>@hudson.metro.url@</remote>
+ <local>stack-metro</local>
+ </hudson.scm.SubversionSCM-ModuleLocation>
+ <hudson.scm.SubversionSCM-ModuleLocation>
+ <remote>@hudson.cxf.url@</remote>
+ <local>stack-cxf</local>
+ </hudson.scm.SubversionSCM-ModuleLocation>
+ </locations>
+ <useUpdate>true</useUpdate>
+ <browser class="hudson.scm.browsers.FishEyeSVN">
+ <url>http://fisheye.jboss.com/browse/JBossWS/</url>
+ <rootModule></rootModule>
+ </browser>
+ </scm>
+ <canRoam>true</canRoam>
+ <disabled>false</disabled>
+ <enableRemoteTrigger>false</enableRemoteTrigger>
+ <triggers class="vector"/>
+ <logRotator>
+ <daysToKeep>-1</daysToKeep>
+ <numToKeep>20</numToKeep>
+ </logRotator>
+ <keepDependencies>false</keepDependencies>
+ <properties/>
+ <description>Build and test jbossws-(a)version.id@ against AS-4.0.5 without EJB3 support</description>
+ <actions class="vector"/>
+</project>
\ No newline at end of file
Property changes on: framework/trunk/hudson/hudson-home/jobs/Integration-Native-AS-4.0.5-No-EJB3/config.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
17 years, 3 months