You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrf-commits@ws.apache.org by sc...@apache.org on 2005/08/02 18:30:44 UTC
svn commit: r227033 [3/27] - in /webservices/wsrf/trunk: ./
src/java/org/apache/ws/ src/java/org/apache/ws/addressing/
src/java/org/apache/ws/addressing/v2003_03/
src/java/org/apache/ws/addressing/v2004_08_10/
src/java/org/apache/ws/resource/ src/java/...
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/ErrorCode.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/ErrorCode.java?rev=227033&r1=227032&r2=227033&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/ErrorCode.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/ErrorCode.java Tue Aug 2 09:28:49 2005
@@ -1,90 +1,90 @@
-/*=============================================================================*
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *=============================================================================*/
-package org.apache.ws.resource.faults;
-
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.ws.resource.i18n.Keys;
-import org.apache.ws.resource.i18n.MessagesImpl;
-import org.apache.ws.util.i18n.Messages;
-import org.apache.xmlbeans.XmlObject;
-
-import java.net.URI;
-import java.util.Arrays;
-
-/**
- * The WS-BaseFaults ErrorCode type.
- *
- * @author Ian P. Springer
- */
-public class ErrorCode
-{
- public static final Messages MSG = MessagesImpl.getInstance();
- private URI m_dialect; // in the XML type, this is a required attribute on the top-level ErrorCode element
- private XmlObject[] m_content;
-
- /**
- * Creates a new ErrorCode with the specified dialect.
- *
- * @param dialect DOCUMENT_ME
- */
- public ErrorCode( URI dialect )
- {
- m_dialect = dialect;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param content DOCUMENT_ME
- */
- public void setContent( XmlObject[] content )
- {
- m_content = content;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public XmlObject[] getContent( )
- {
- return m_content;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public URI getDialect( )
- {
- return m_dialect;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public String toString( )
- {
- return new ToStringBuilder( this ).append( MSG.getMessage(Keys.DIALECT), m_dialect )
- .append( MSG.getMessage(Keys.CONTENT),
- Arrays.asList( m_content ) ).toString( );
- }
-
+/*=============================================================================*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.faults;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.ws.resource.i18n.Keys;
+import org.apache.ws.resource.i18n.MessagesImpl;
+import org.apache.ws.util.i18n.Messages;
+import org.apache.xmlbeans.XmlObject;
+import java.net.URI;
+import java.util.Arrays;
+
+/**
+ * The WS-BaseFaults ErrorCode type.
+ *
+ * @author Ian P. Springer
+ */
+public class ErrorCode
+{
+ /** DOCUMENT_ME */
+ public static final Messages MSG = MessagesImpl.getInstance( );
+ private URI m_dialect; // in the XML type, this is a required attribute on the top-level ErrorCode element
+ private XmlObject[] m_content;
+
+ /**
+ * Creates a new ErrorCode with the specified dialect.
+ *
+ * @param dialect DOCUMENT_ME
+ */
+ public ErrorCode( URI dialect )
+ {
+ m_dialect = dialect;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param content DOCUMENT_ME
+ */
+ public void setContent( XmlObject[] content )
+ {
+ m_content = content;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public XmlObject[] getContent( )
+ {
+ return m_content;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public URI getDialect( )
+ {
+ return m_dialect;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public String toString( )
+ {
+ return new ToStringBuilder( this ).append( MSG.getMessage( Keys.DIALECT ),
+ m_dialect )
+ .append( MSG.getMessage( Keys.CONTENT ),
+ Arrays.asList( m_content ) ).toString( );
+ }
}
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/FaultException.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/FaultException.java?rev=227033&r1=227032&r2=227033&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/FaultException.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/FaultException.java Tue Aug 2 09:28:49 2005
@@ -1,98 +1,144 @@
-/*=============================================================================*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *=============================================================================*/
-package org.apache.ws.resource.faults;
-
-import org.apache.ws.util.SaajUtils;
-import org.apache.ws.util.XmlBeanUtils;
-import org.apache.xmlbeans.XmlObject;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import javax.xml.namespace.QName;
-import javax.xml.rpc.JAXRPCException;
-import javax.xml.rpc.soap.SOAPFaultException;
-import javax.xml.soap.Detail;
-import javax.xml.soap.DetailEntry;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPFactory;
-
-/**
- * Subclass of JAX-RPC {@link SOAPFaultException} that adds convenient methods for
- * adding Detail entries. The entries may be specified as either DOM nodes or XmlBeans.
- *
- * @author Ian P. Springer
- */
-public class FaultException extends SOAPFaultException
-{
-
- private Detail m_detail;
-
- public FaultException( QName faultCode, String faultString, String faultActor, Detail detail )
- {
- super( faultCode, faultString, faultActor, detail );
- m_detail = detail;
- }
-
- public FaultException( QName faultCode, String faultString, String faultActor )
- {
- this( faultCode, faultString, faultActor, createDetail() );
- }
-
- public FaultException( QName faultCode, String faultString )
- {
- this( faultCode, faultString, null );
- }
-
- private static Detail createDetail()
- {
- try
- {
- return SOAPFactory.newInstance().createDetail();
- }
- catch ( SOAPException soape )
- {
- throw new JAXRPCException( "Failed to create SAAJ Detail object via SOAPFactory.", soape );
- }
- }
-
- public DetailEntry addDetailEntry( XmlObject xmlElem )
- {
- XmlObject docXBean = XmlBeanUtils.getDocument( xmlElem );
- return addDetailEntry( ((Document)docXBean.newDomNode()).getDocumentElement() );
- }
-
- public DetailEntry addDetailEntry( Element domElem )
- {
- if ( m_detail == null )
- {
- throw new IllegalStateException( "Detail entry cannot be added because Detail is null." );
- }
- try
- {
- return SaajUtils.addDetailEntry( m_detail, domElem );
- }
- catch ( SOAPException soape )
- {
- throw new JAXRPCException( "Failed to add detail entry to SAAJ Detail object.", soape );
- }
- }
-
- public Detail getDetail()
- {
- return m_detail;
- }
-
-}
+/*=============================================================================*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.faults;
+
+import org.apache.ws.util.SaajUtils;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.xmlbeans.XmlObject;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import javax.xml.namespace.QName;
+import javax.xml.rpc.JAXRPCException;
+import javax.xml.rpc.soap.SOAPFaultException;
+import javax.xml.soap.Detail;
+import javax.xml.soap.DetailEntry;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+
+/**
+ * Subclass of JAX-RPC {@link SOAPFaultException} that adds convenient methods for
+ * adding Detail entries. The entries may be specified as either DOM nodes or XmlBeans.
+ *
+ * @author Ian P. Springer
+ */
+public class FaultException
+ extends SOAPFaultException
+{
+ private Detail m_detail;
+
+ /**
+ * Creates a new {@link FaultException} object.
+ *
+ * @param faultCode DOCUMENT_ME
+ * @param faultString DOCUMENT_ME
+ * @param faultActor DOCUMENT_ME
+ * @param detail DOCUMENT_ME
+ */
+ public FaultException( QName faultCode,
+ String faultString,
+ String faultActor,
+ Detail detail )
+ {
+ super( faultCode, faultString, faultActor, detail );
+ m_detail = detail;
+ }
+
+ /**
+ * Creates a new {@link FaultException} object.
+ *
+ * @param faultCode DOCUMENT_ME
+ * @param faultString DOCUMENT_ME
+ * @param faultActor DOCUMENT_ME
+ */
+ public FaultException( QName faultCode,
+ String faultString,
+ String faultActor )
+ {
+ this( faultCode, faultString, faultActor,
+ createDetail( ) );
+ }
+
+ /**
+ * Creates a new {@link FaultException} object.
+ *
+ * @param faultCode DOCUMENT_ME
+ * @param faultString DOCUMENT_ME
+ */
+ public FaultException( QName faultCode,
+ String faultString )
+ {
+ this( faultCode, faultString, null );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public Detail getDetail( )
+ {
+ return m_detail;
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param xmlElem DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public DetailEntry addDetailEntry( XmlObject xmlElem )
+ {
+ XmlObject docXBean = XmlBeanUtils.getDocument( xmlElem );
+ return addDetailEntry( ( (Document) docXBean.newDomNode( ) ).getDocumentElement( ) );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param domElem DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public DetailEntry addDetailEntry( Element domElem )
+ {
+ if ( m_detail == null )
+ {
+ throw new IllegalStateException( "Detail entry cannot be added because Detail is null." );
+ }
+
+ try
+ {
+ return SaajUtils.addDetailEntry( m_detail, domElem );
+ }
+ catch ( SOAPException soape )
+ {
+ throw new JAXRPCException( "Failed to add detail entry to SAAJ Detail object.", soape );
+ }
+ }
+
+ private static Detail createDetail( )
+ {
+ try
+ {
+ return SOAPFactory.newInstance( ).createDetail( );
+ }
+ catch ( SOAPException soape )
+ {
+ throw new JAXRPCException( "Failed to create SAAJ Detail object via SOAPFactory.", soape );
+ }
+ }
+}
\ No newline at end of file
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/ResourceKeyHeaderNotFoundFaultException.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/ResourceKeyHeaderNotFoundFaultException.java?rev=227033&r1=227032&r2=227033&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/ResourceKeyHeaderNotFoundFaultException.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/ResourceKeyHeaderNotFoundFaultException.java Tue Aug 2 09:28:49 2005
@@ -1,48 +1,47 @@
-/*=============================================================================*
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *=============================================================================*/
-package org.apache.ws.resource.faults;
-
-import org.apache.ws.Soap1_1Constants;
-import org.apache.ws.resource.i18n.Keys;
-import org.apache.ws.resource.i18n.MessagesImpl;
-import org.apache.ws.util.i18n.Messages;
-
-import javax.xml.namespace.QName;
-
-/**
- * A fault that is thrown when the expected resource identifier header element
- * is not found in a SOAP request Header. The name of the header element that
- * is expected for a particular type of resource is configured via the
- * resourceKeyName parameter for that resource's home in the Apache WSRF
- * JNDI configuration file.
- */
-public class ResourceKeyHeaderNotFoundFaultException
- extends FaultException
-{
-
- private static final Messages MSG = MessagesImpl.getInstance();
-
- /**
- * Creates a new {@link ResourceKeyHeaderNotFoundFaultException} object.
- *
- * @param expectedHeaderName DOCUMENT_ME
- */
- public ResourceKeyHeaderNotFoundFaultException( QName expectedHeaderName )
- {
- super( Soap1_1Constants.FAULT_CLIENT, MSG.getMessage( Keys.EXPECTED_ADDRESSING_HEADER, String.valueOf( expectedHeaderName ) ) );
- }
-
+/*=============================================================================*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.faults;
+
+import org.apache.ws.Soap1_1Constants;
+import org.apache.ws.resource.i18n.Keys;
+import org.apache.ws.resource.i18n.MessagesImpl;
+import org.apache.ws.util.i18n.Messages;
+import javax.xml.namespace.QName;
+
+/**
+ * A fault that is thrown when the expected resource identifier header element
+ * is not found in a SOAP request Header. The name of the header element that
+ * is expected for a particular type of resource is configured via the
+ * resourceKeyName parameter for that resource's home in the Apache WSRF
+ * JNDI configuration file.
+ */
+public class ResourceKeyHeaderNotFoundFaultException
+ extends FaultException
+{
+ private static final Messages MSG = MessagesImpl.getInstance( );
+
+ /**
+ * Creates a new {@link ResourceKeyHeaderNotFoundFaultException} object.
+ *
+ * @param expectedHeaderName DOCUMENT_ME
+ */
+ public ResourceKeyHeaderNotFoundFaultException( QName expectedHeaderName )
+ {
+ super( Soap1_1Constants.FAULT_CLIENT,
+ MSG.getMessage( Keys.EXPECTED_ADDRESSING_HEADER,
+ String.valueOf( expectedHeaderName ) ) );
+ }
}
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/v2004_06/FaultsConstants.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/v2004_06/FaultsConstants.java?rev=227033&r1=227032&r2=227033&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/v2004_06/FaultsConstants.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/v2004_06/FaultsConstants.java Tue Aug 2 09:28:49 2005
@@ -1,46 +1,44 @@
-/*=============================================================================*
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *=============================================================================*/
-package org.apache.ws.resource.faults.v2004_06;
-
-import org.apache.ws.resource.v2004_06.WsrfConstants;
-
-/**
- * Constants for namespaces defined by the 2004/06 version of the WSRF BaseFaults specification.
- */
-public interface FaultsConstants
-{
-
- /**
- * Namespace URI for WS-BaseFaults schema.
- */
- String NSURI_BASEFAULTS_SCHEMA = WsrfConstants.BASE_URI_WSRF + "wsrf-WS-BaseFaults-1.2-draft-01.xsd";
-
- /**
- * Namespace prefix for WS-BaseFaults schema.
- */
- String NSPREFIX_BASEFAULTS_SCHEMA = "wsbf";
-
- /**
- * Namespace URI for WS-BaseFaults WSDL.
- */
- String NSURI_BASEFAULTS_WSDL = WsrfConstants.BASE_URI_WSRF + "wsrf-WS-BaseFaults-1.2-draft-01.wsdl";
-
- /**
- * Namespace prefix for WS-BaseFaults WSDL.
- */
- String NSPREFIX_BASEFAULTS_WSDL = "wsbfw";
-
+/*=============================================================================*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.faults.v2004_06;
+
+import org.apache.ws.resource.v2004_06.WsrfConstants;
+
+/**
+ * Constants for namespaces defined by the 2004/06 version of the WSRF BaseFaults specification.
+ */
+public interface FaultsConstants
+{
+ /**
+ * Namespace URI for WS-BaseFaults schema.
+ */
+ String NSURI_BASEFAULTS_SCHEMA = WsrfConstants.BASE_URI_WSRF + "wsrf-WS-BaseFaults-1.2-draft-01.xsd";
+
+ /**
+ * Namespace prefix for WS-BaseFaults schema.
+ */
+ String NSPREFIX_BASEFAULTS_SCHEMA = "wsbf";
+
+ /**
+ * Namespace URI for WS-BaseFaults WSDL.
+ */
+ String NSURI_BASEFAULTS_WSDL = WsrfConstants.BASE_URI_WSRF + "wsrf-WS-BaseFaults-1.2-draft-01.wsdl";
+
+ /**
+ * Namespace prefix for WS-BaseFaults WSDL.
+ */
+ String NSPREFIX_BASEFAULTS_WSDL = "wsbfw";
}
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/v2004_11/FaultsConstants.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/v2004_11/FaultsConstants.java?rev=227033&r1=227032&r2=227033&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/v2004_11/FaultsConstants.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/faults/v2004_11/FaultsConstants.java Tue Aug 2 09:28:49 2005
@@ -1,46 +1,44 @@
-/*=============================================================================*
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *=============================================================================*/
-package org.apache.ws.resource.faults.v2004_11;
-
-import org.apache.ws.resource.v2004_11.WsrfConstants;
-
-/**
- * Constants for namespaces defined by the 2004/11 version of the WSRF BaseFaults specification.
- */
-public interface FaultsConstants
-{
-
- /**
- * Namespace URI for WS-BaseFaults schema.
- */
- String NSURI_BASEFAULTS_SCHEMA = WsrfConstants.BASE_URI_WSRF + "wsrf-WS-BaseFaults-1.2-draft-03.xsd";
-
- /**
- * Namespace prefix for WS-BaseFaults schema.
- */
- String NSPREFIX_BASEFAULTS_SCHEMA = "wsrf-bf";
-
- /**
- * Namespace URI for WS-BaseFaults WSDL.
- */
- String NSURI_BASEFAULTS_WSDL = WsrfConstants.BASE_URI_WSRF + "wsrf-WS-BaseFaults-1.2-draft-03.wsdl";
-
- /**
- * Namespace prefix for WS-BaseFaults WSDL.
- */
- String NSPREFIX_BASEFAULTS_WSDL = "wsrf-bfw";
-
+/*=============================================================================*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.faults.v2004_11;
+
+import org.apache.ws.resource.v2004_11.WsrfConstants;
+
+/**
+ * Constants for namespaces defined by the 2004/11 version of the WSRF BaseFaults specification.
+ */
+public interface FaultsConstants
+{
+ /**
+ * Namespace URI for WS-BaseFaults schema.
+ */
+ String NSURI_BASEFAULTS_SCHEMA = WsrfConstants.BASE_URI_WSRF + "wsrf-WS-BaseFaults-1.2-draft-03.xsd";
+
+ /**
+ * Namespace prefix for WS-BaseFaults schema.
+ */
+ String NSPREFIX_BASEFAULTS_SCHEMA = "wsrf-bf";
+
+ /**
+ * Namespace URI for WS-BaseFaults WSDL.
+ */
+ String NSURI_BASEFAULTS_WSDL = WsrfConstants.BASE_URI_WSRF + "wsrf-WS-BaseFaults-1.2-draft-03.wsdl";
+
+ /**
+ * Namespace prefix for WS-BaseFaults WSDL.
+ */
+ String NSPREFIX_BASEFAULTS_WSDL = "wsrf-bfw";
}
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/AbstractSoapMethodNameMap.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/AbstractSoapMethodNameMap.java?rev=227033&r1=227032&r2=227033&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/AbstractSoapMethodNameMap.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/AbstractSoapMethodNameMap.java Tue Aug 2 09:28:49 2005
@@ -56,24 +56,13 @@
{
methodName = parent.getMethodName( requestName );
}
+
if ( methodName == null )
{
methodName = getDefaultMethodName( requestName );
}
- return methodName;
- }
- /**
- * Returns a default name for a method based on a request's WS-Addressing Action header.
- * Subclasses that wish to support mapping based on wsa:Action should override this method.
- *
- * @param action string representation of WS-Addressing Action header value
- *
- * @return a method name, or null if no mapping is configured for the specified wsa:Action
- */
- protected String lookupMethodNameFromAction( String action )
- {
- return null;
+ return methodName;
}
/**
@@ -87,18 +76,22 @@
*/
public final String getMethodNameFromAction( String action )
{
- if(action == null) { return null; }
-
+ if ( action == null )
+ {
+ return null;
+ }
+
SoapMethodNameMap parent = getParent( );
String methodName = null;
if ( parent != null )
{
methodName = parent.getMethodNameFromAction( action );
}
- if ( methodName == null )
- {
- methodName = lookupMethodNameFromAction( action );
- }
+
+ if ( methodName == null )
+ {
+ methodName = lookupMethodNameFromAction( action );
+ }
return methodName;
}
@@ -121,5 +114,18 @@
public SoapMethodNameMap getParent( )
{
return m_parent;
+ }
+
+ /**
+ * Returns a default name for a method based on a request's WS-Addressing Action header.
+ * Subclasses that wish to support mapping based on wsa:Action should override this method.
+ *
+ * @param action string representation of WS-Addressing Action header value
+ *
+ * @return a method name, or null if no mapping is configured for the specified wsa:Action
+ */
+ protected String lookupMethodNameFromAction( String action )
+ {
+ return null;
}
}
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/DefaultMethodMap.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/DefaultMethodMap.java?rev=227033&r1=227032&r2=227033&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/DefaultMethodMap.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/DefaultMethodMap.java Tue Aug 2 09:28:49 2005
@@ -15,9 +15,7 @@
*=============================================================================*/
package org.apache.ws.resource.handler;
-
import org.apache.ws.resource.metadataexchange.v2004_09.MetadataExchangeConstants;
-
import javax.xml.namespace.QName;
import java.util.HashMap;
import java.util.Map;
@@ -30,78 +28,7 @@
public class DefaultMethodMap
extends AbstractSoapMethodNameMap
{
-
- private static final Map METHOD_MAP = initMap();
-
- private static Map initMap()
- {
- Map map = new HashMap( );
- addWsrpOperations( map );
- addWsrlOperations( map );
- addWsxOperations( map );
- return map;
- }
-
- private static void addWsrpOperations( Map map )
- {
- //draft 01
- map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA, "GetResourceProperty", org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
- "getResourceProperty" );
- map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA, "QueryResourceProperties", org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
- "queryResourceProperties" );
- map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA, "SetResourceProperties", org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
- "setResourceProperties" );
- map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA, "GetMultipleResourceProperties", org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
- "getMultipleResourceProperties" );
-
- //draft 05
- map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA, "GetResourceProperty", org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
- "getResourceProperty" );
- map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA, "QueryResourceProperties", org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
- "queryResourceProperties" );
- map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA, "SetResourceProperties", org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
- "setResourceProperties" );
- map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA, "GetMultipleResourceProperties", org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
- "getMultipleResourceProperties" );
-
- map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA, "GetResourcePropertyDocument", org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
- "getResourcePropertyDocument" );
- map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA, "InsertResourceProperties", org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
- "insertResourceProperties" );
- map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA, "UpdateResourceProperties", org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
- "updateResourceProperties" );
- map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA, "DeleteResourceProperties", org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
- "deleteResourceProperties" );
-
- }
-
- private static void addWsrlOperations( Map map )
- {
- //draft 01
- map.put( new QName( org.apache.ws.resource.lifetime.v2004_06.ResourceLifetimeConstants.NSURI_WSRL_SCHEMA, "SetTerminationTime", org.apache.ws.resource.lifetime.v2004_06.ResourceLifetimeConstants.NSPREFIX_WSRL_SCHEMA ),
- "setTerminationTime" );
- map.put( new QName( org.apache.ws.resource.lifetime.v2004_06.ResourceLifetimeConstants.NSURI_WSRL_SCHEMA, "Destroy", org.apache.ws.resource.lifetime.v2004_06.ResourceLifetimeConstants.NSPREFIX_WSRL_SCHEMA ),
- "destroy" );
-
- //draft 04
- map.put( new QName( org.apache.ws.resource.lifetime.v2004_11.ResourceLifetimeConstants.NSURI_WSRL_SCHEMA, "SetTerminationTime", org.apache.ws.resource.lifetime.v2004_11.ResourceLifetimeConstants.NSPREFIX_WSRL_SCHEMA ),
- "setTerminationTime" );
- map.put( new QName( org.apache.ws.resource.lifetime.v2004_11.ResourceLifetimeConstants.NSURI_WSRL_SCHEMA, "Destroy", org.apache.ws.resource.lifetime.v2004_11.ResourceLifetimeConstants.NSPREFIX_WSRL_SCHEMA ),
- "destroy" );
- }
-
- /**
- * Adds the WS-MetadataExchange operation and Action String to the map
- * @param map
- */
- private static void addWsxOperations(Map map )
- {
- //put this in as string for looking up the "Get/Request" operation
- map.put(MetadataExchangeConstants.ACTION_GET_REQUEST,"get");
- //put this in as string for looking up the "GetMetadata/Request" operation
- map.put(MetadataExchangeConstants.ACTION_GETMETADATA_REQUEST, "getMetadata");
- }
-
+ private static final Map METHOD_MAP = initMap( );
private SoapMethodNameMap m_parent;
/**
@@ -126,18 +53,7 @@
return (String) METHOD_MAP.get( request );
}
- /**
- * Returns a Default name for a method based on a request's WS-Addressing Action Header.
- *
- * @param action String representation of WS-Addressing Action Header Value
- * @return The name of the operation OR null if there is no Action registered.
- */
- public String lookupMethodNameFromAction(String action)
- {
- return (String) METHOD_MAP.get( action );
- }
-
- /**
+ /**
* DOCUMENT_ME
*
* @return DOCUMENT_ME
@@ -145,5 +61,117 @@
public SoapMethodNameMap getParent( )
{
return m_parent;
+ }
+
+ /**
+ * Returns a Default name for a method based on a request's WS-Addressing Action Header.
+ *
+ * @param action String representation of WS-Addressing Action Header Value
+ * @return The name of the operation OR null if there is no Action registered.
+ */
+ public String lookupMethodNameFromAction( String action )
+ {
+ return (String) METHOD_MAP.get( action );
+ }
+
+ private static void addWsrlOperations( Map map )
+ {
+ //draft 01
+ map.put( new QName( org.apache.ws.resource.lifetime.v2004_06.ResourceLifetimeConstants.NSURI_WSRL_SCHEMA,
+ "SetTerminationTime",
+ org.apache.ws.resource.lifetime.v2004_06.ResourceLifetimeConstants.NSPREFIX_WSRL_SCHEMA ),
+ "setTerminationTime" );
+ map.put( new QName( org.apache.ws.resource.lifetime.v2004_06.ResourceLifetimeConstants.NSURI_WSRL_SCHEMA,
+ "Destroy",
+ org.apache.ws.resource.lifetime.v2004_06.ResourceLifetimeConstants.NSPREFIX_WSRL_SCHEMA ),
+ "destroy" );
+
+ //draft 04
+ map.put( new QName( org.apache.ws.resource.lifetime.v2004_11.ResourceLifetimeConstants.NSURI_WSRL_SCHEMA,
+ "SetTerminationTime",
+ org.apache.ws.resource.lifetime.v2004_11.ResourceLifetimeConstants.NSPREFIX_WSRL_SCHEMA ),
+ "setTerminationTime" );
+ map.put( new QName( org.apache.ws.resource.lifetime.v2004_11.ResourceLifetimeConstants.NSURI_WSRL_SCHEMA,
+ "Destroy",
+ org.apache.ws.resource.lifetime.v2004_11.ResourceLifetimeConstants.NSPREFIX_WSRL_SCHEMA ),
+ "destroy" );
+ }
+
+ private static void addWsrpOperations( Map map )
+ {
+ //draft 01
+ map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA,
+ "GetResourceProperty",
+ org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
+ "getResourceProperty" );
+ map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA,
+ "QueryResourceProperties",
+ org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
+ "queryResourceProperties" );
+ map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA,
+ "SetResourceProperties",
+ org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
+ "setResourceProperties" );
+ map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA,
+ "GetMultipleResourceProperties",
+ org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
+ "getMultipleResourceProperties" );
+
+ //draft 05
+ map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA,
+ "GetResourceProperty",
+ org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
+ "getResourceProperty" );
+ map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA,
+ "QueryResourceProperties",
+ org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
+ "queryResourceProperties" );
+ map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA,
+ "SetResourceProperties",
+ org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
+ "setResourceProperties" );
+ map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA,
+ "GetMultipleResourceProperties",
+ org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
+ "getMultipleResourceProperties" );
+
+ map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA,
+ "GetResourcePropertyDocument",
+ org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
+ "getResourcePropertyDocument" );
+ map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA,
+ "InsertResourceProperties",
+ org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
+ "insertResourceProperties" );
+ map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA,
+ "UpdateResourceProperties",
+ org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
+ "updateResourceProperties" );
+ map.put( new QName( org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSURI_WSRP_SCHEMA,
+ "DeleteResourceProperties",
+ org.apache.ws.resource.properties.v2004_06.ResourcePropertiesConstants.NSPREFIX_WSRP_SCHEMA ),
+ "deleteResourceProperties" );
+ }
+
+ /**
+ * Adds the WS-MetadataExchange operation and Action String to the map
+ * @param map
+ */
+ private static void addWsxOperations( Map map )
+ {
+ //put this in as string for looking up the "Get/Request" operation
+ map.put( MetadataExchangeConstants.ACTION_GET_REQUEST, "get" );
+
+ //put this in as string for looking up the "GetMetadata/Request" operation
+ map.put( MetadataExchangeConstants.ACTION_GETMETADATA_REQUEST, "getMetadata" );
+ }
+
+ private static Map initMap( )
+ {
+ Map map = new HashMap( );
+ addWsrpOperations( map );
+ addWsrlOperations( map );
+ addWsxOperations( map );
+ return map;
}
}
Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java?rev=227033&r1=227032&r2=227033&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java Tue Aug 2 09:28:49 2005
@@ -30,7 +30,6 @@
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl;
-
import javax.xml.namespace.QName;
import javax.xml.rpc.JAXRPCException;
import javax.xml.rpc.handler.GenericHandler;
@@ -60,585 +59,615 @@
* @author Sal Campana
*/
public abstract class ResourceHandler
- extends GenericHandler
+ extends GenericHandler
{
- private static final Log LOG = LogFactory.getLog( ResourceHandler.class );
+ private static final Log LOG = LogFactory.getLog( ResourceHandler.class );
+
+ /**
+ * DOCUMENT_ME
+ */
+ public static final Messages MSG = MessagesImpl.getInstance( );
+
+ /**
+ * DOCUMENT_ME
+ */
+ private static final String WSRF_RESPONSE_XMLOBJECT_LIST = "WSRF_RESPONSE_XMLOBJECT_LIST";
+
+ /**
+ * DOCUMENT_ME
+ */
+ public static final String SERVICE_OPT_WSDL_TARGET_NAMESPACE = "wsdlTargetNamespace";
+
+ /**
+ * DOCUMENT_ME
+ */
+ public static final String SERVICE_OPT_SERVICE_CLASS_NAME = "serviceClassName";
+
+ /** DOCUMENT_ME */
+ public static final String HANDLER_OPT_VALIDATE_REQUEST_XML = "validateRequestXml";
+
+ static
+ {
+ ExceptionUtils.addCauseMethodName( "getLinkedCause" ); // for JAXRPCException
+ }
+
+ private Map m_handlerOptions;
+
+ /**
+ * This handler acts as the pivot and does not process any SOAP header elements.
+ *
+ * @return the names of the SOAP header elements that this handler processes
+ */
+ public QName[] getHeaders( )
+ {
+ return new QName[0];
+ }
+
+ /**
+ * Deserializes the incoming SOAP request to an XMLBean and dispatches it to the appropriate service. It is required
+ * that the request meet the following criteria: <ol> <li>SOAP Header contains the header elements required by
+ * WS-Addressing (either 2003/03 or 2004/08)</li> <li>SOAP Body contains no more than one body element</li> </ol>
+ */
+ public boolean handleRequest( MessageContext msgContext )
+ {
+ try
+ {
+ LOG.debug( MSG.getMessage( Keys.RECEIVED_REQUEST ) );
+ SOAPMessageContext soapMsgContext = (SOAPMessageContext) msgContext;
+ SOAPEnvelope envelope = soapMsgContext.getMessage( ).getSOAPPart( ).getEnvelope( );
+ if ( LOG.isDebugEnabled( ) )
+ {
+ LOG.debug( "Received SOAP request: \n" + envelope );
+ }
+
+ org.apache.ws.util.soap.Body body = getSoapBody( envelope );
+
+ ResourceContext resourceContext = createResourceContext( soapMsgContext );
+ String addressingAction = resourceContext.getRequestAction( );
+ SoapMethodNameMap methodnameMap = new ServiceSoapMethodNameMap( resourceContext );
+ String methodNameFromAction =
+ methodnameMap.getMethodNameFromAction( addressingAction );
+ List responseBodyElems = new ArrayList( );
+
+ Class serviceClass = getServiceClassName( resourceContext );
+ WsrfService service = createService( serviceClass, resourceContext );
+ XmlObject[] childElems = XmlBeanUtils.getChildElements( body.getXmlObject( ) );
+ Method serviceMethod = null;
+
+ if ( childElems.length > 1 )
+ {
+ throw new FaultException( Soap1_1Constants.FAULT_CLIENT,
+ "SOAP request Body contains more than one body element - this service requires that all SOAP requests contain at most one body element." );
+ }
+
+ XmlObject requestXBean;
+ if ( childElems.length == 0 ) // empty Body
+ {
+ requestXBean = null;
+ if ( methodNameFromAction != null )
+ {
+ // try to find a method based on the wsa:Action...
+ serviceMethod = getServiceMethod( service, methodNameFromAction );
+ }
+ else // empty Body and unmapped wsa:Action
+ {
+ throw new FaultException( Soap1_1Constants.FAULT_CLIENT,
+ "No SOAP Body elements were defined, and the value of the WS-Addressing Action header was not recognized - unable to dispatch request." );
+ }
+ }
+ else // childElems.length == 1
+ {
+ requestXBean = toDocumentXmlBean( childElems[0] );
+ validateRequestXml( requestXBean );
+ if ( methodNameFromAction != null )
+ {
+ serviceMethod = getServiceMethod( service, methodNameFromAction, requestXBean ); //get method based on Action
+ }
+ else
+ {
+ serviceMethod = getServiceMethod( service, requestXBean ); //get method based solely on request elem
+ }
+ }
- /**
- * DOCUMENT_ME
- */
- public static final Messages MSG = MessagesImpl.getInstance();
-
- /**
- * DOCUMENT_ME
- */
- private static final String WSRF_RESPONSE_XMLOBJECT_LIST = "WSRF_RESPONSE_XMLOBJECT_LIST";
-
- /**
- * DOCUMENT_ME
- */
- public static final String SERVICE_OPT_WSDL_TARGET_NAMESPACE = "wsdlTargetNamespace";
-
- /**
- * DOCUMENT_ME
- */
- public static final String SERVICE_OPT_SERVICE_CLASS_NAME = "serviceClassName";
-
- public static final String HANDLER_OPT_VALIDATE_REQUEST_XML = "validateRequestXml";
-
- static
- {
- ExceptionUtils.addCauseMethodName( "getLinkedCause" ); // for JAXRPCException
- }
-
- private Map m_handlerOptions;
-
- public void init( HandlerInfo handlerInfo )
- {
- Map handlerConfig = handlerInfo.getHandlerConfig();
- m_handlerOptions = handlerConfig != null ? handlerConfig : new HashMap();
- }
-
- /**
- * This handler acts as the pivot and does not process any SOAP header elements.
- *
- * @return the names of the SOAP header elements that this handler processes
- */
- public QName[] getHeaders()
- {
- return new QName[0];
- }
-
- /**
- * Deserializes the incoming SOAP request to an XMLBean and dispatches it to the appropriate service. It is required
- * that the request meet the following criteria: <ol> <li>SOAP Header contains the header elements required by
- * WS-Addressing (either 2003/03 or 2004/08)</li> <li>SOAP Body contains no more than one body element</li> </ol>
- */
- public boolean handleRequest( MessageContext msgContext )
- {
- try
- {
- LOG.debug( MSG.getMessage( Keys.RECEIVED_REQUEST ) );
- SOAPMessageContext soapMsgContext = (SOAPMessageContext) msgContext;
- SOAPEnvelope envelope = soapMsgContext.getMessage().getSOAPPart().getEnvelope();
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( "Received SOAP request: \n" + envelope );
- }
- org.apache.ws.util.soap.Body body = getSoapBody( envelope );
-
- ResourceContext resourceContext = createResourceContext( soapMsgContext );
- String addressingAction = resourceContext.getRequestAction();
- SoapMethodNameMap methodnameMap = new ServiceSoapMethodNameMap( resourceContext );
- String methodNameFromAction = methodnameMap.getMethodNameFromAction( addressingAction );
- List responseBodyElems = new ArrayList();
-
- Class serviceClass = getServiceClassName( resourceContext );
- WsrfService service = createService( serviceClass, resourceContext );
- XmlObject[] childElems = XmlBeanUtils.getChildElements( body.getXmlObject() );
- Method serviceMethod = null;
-
- if ( childElems.length > 1 )
- {
- throw new FaultException( Soap1_1Constants.FAULT_CLIENT,
- "SOAP request Body contains more than one body element - this service requires that all SOAP requests contain at most one body element." );
- }
- XmlObject requestXBean;
- if ( childElems.length == 0 ) // empty Body
- {
- requestXBean = null;
- if ( methodNameFromAction != null )
- {
- // try to find a method based on the wsa:Action...
- serviceMethod = getServiceMethod( service, methodNameFromAction );
- }
- else // empty Body and unmapped wsa:Action
- {
- throw new FaultException( Soap1_1Constants.FAULT_CLIENT,
- "No SOAP Body elements were defined, and the value of the WS-Addressing Action header was not recognized - unable to dispatch request." );
- }
- }
- else // childElems.length == 1
- {
- requestXBean = toDocumentXmlBean( childElems[0] );
- validateRequestXml( requestXBean );
- if ( methodNameFromAction != null )
- {
- serviceMethod = getServiceMethod( service, methodNameFromAction, requestXBean ); //get method based on Action
- }
- else
- {
- serviceMethod = getServiceMethod( service, requestXBean ); //get method based solely on request elem
- }
- }
- LOG.debug( MSG.getMessage( Keys.INVOKING_SERVICE_METHOD, serviceMethod.getName() ) );
- XmlObject responseXBean = invokeServiceMethod( serviceMethod, service, requestXBean, serviceClass );
- if ( responseXBean != null )
- {
- responseBodyElems.add( responseXBean );
- }
- if ( !responseBodyElems.isEmpty() )
- {
- msgContext.setProperty( WSRF_RESPONSE_XMLOBJECT_LIST, responseBodyElems );
- }
- }
- catch ( Exception e )
- {
- handleException( e );
- }
- return false; // short-circuit any remaining Handlers in chain
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param messageContext DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public boolean handleResponse( MessageContext messageContext )
- {
- try
- {
- LOG.debug( MSG.getMessage( Keys.HANDLING_RESPONSE ) );
- SOAPEnvelope responseEnvelope = getResponseEnvelope( (SOAPMessageContext) messageContext );
- List responseBodyElems = (List) messageContext.getProperty( WSRF_RESPONSE_XMLOBJECT_LIST );
- LOG.debug( MSG.getMessage( Keys.FOUND_RESP_ELEMS, Integer.toString( responseBodyElems.size() ) ) );
- if ( responseBodyElems != null )
- {
- SOAPBody responseBody = responseEnvelope.getBody();
- for ( int i = 0; i < responseBodyElems.size(); i++ )
- {
- XmlObject responseBodyElem = (XmlObject) responseBodyElems.get( i );
- SOAPBodyElement[] soapBodyElements = createSOAPBodyElements( responseBodyElem );
- for ( int j = 0; j < soapBodyElements.length; j++ )
- {
- SOAPBodyElement soapBodyElement = soapBodyElements[j];
- responseBody.addChildElement( soapBodyElement );
- }
- }
- }
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( "Sending SOAP response: \n" + responseEnvelope );
- }
- }
- catch ( Exception e )
- {
- handleException( e );
- }
- return false; // short-circuit any remaining Handlers in chain
- }
-
- /**
- * Creates a {@link ResourceContext} for this request.
- *
- * @param soapMsgContext the JAX-RPC SOAP message context for this request
- *
- * @return a ResourceContext for this request
- */
- protected abstract ResourceContext createResourceContext( SOAPMessageContext soapMsgContext )
- throws Exception;
-
- /**
- * DOCUMENT_ME
- *
- * @param responseBodyElem DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- protected abstract SOAPBodyElement[] createSOAPBodyElements( XmlObject responseBodyElem );
-
- /**
- * DOCUMENT_ME
- *
- * @param resourceContext DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- protected Class getServiceClassName( ResourceContext resourceContext )
- throws ResourceContextException,
- ClassNotFoundException
- {
- String serviceClassName = resourceContext.getResourceHome().getServiceClassName();
- LOG.debug( MSG.getMessage( Keys.RETRIEVED_SERVICE_CLASSNAME, serviceClassName ) );
- if ( serviceClassName == null )
- {
- throw new IllegalStateException( MSG.getMessage( Keys.SERVICE_OPT_UNDEFINED_IN_HOME,
- SERVICE_OPT_SERVICE_CLASS_NAME ) );
- }
- return Class.forName( serviceClassName );
- }
-
- /**
- * @param resourceContext
- * @param key
- *
- * @return the service option string
- */
- protected final String getServiceOption( ResourceContext resourceContext,
- String key )
- {
- return (String) resourceContext.getProperty( key );
- }
-
- /**
- * DOCUMENT_ME
- *
- * @param soapMsgContext DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- protected SOAPEnvelope getResponseEnvelope( SOAPMessageContext soapMsgContext )
- {
- return ( getEnvelope( getResponseMessage( soapMsgContext ) ) );
- }
-
- /**
- * @param soapMsgContext the response's JAX-RPC message context
- *
- * @return response JAX-RPC SOAP message
- */
- protected SOAPMessage getResponseMessage( SOAPMessageContext soapMsgContext )
- {
- SOAPMessage soapMsg = soapMsgContext.getMessage();
- if ( soapMsg == null )
- {
- soapMsg = createSOAPMessage();
- soapMsgContext.setMessage( soapMsg );
- }
-
- return ( soapMsg );
- }
-
- private void validateRequestXml( XmlObject requestXBean )
- {
- boolean validateRequestXml = Boolean.valueOf( getHandlerOption( HANDLER_OPT_VALIDATE_REQUEST_XML, "true" ) )
- .booleanValue();
- if ( validateRequestXml && !( requestXBean instanceof XmlAnyTypeImpl ) )
- {
- XmlOptions validateOptions = new XmlOptions();
- List errorList = new ArrayList();
- validateOptions.setErrorListener( errorList );
- boolean isValid = requestXBean.validate( validateOptions );
- if ( !isValid )
- {
- QName bodyElemName = XmlBeanUtils.getName( requestXBean );
- StringBuffer strBuf = new StringBuffer( "Request body element " );
- strBuf.append( toString( bodyElemName ) );
- strBuf.append( " is not valid as per its schema: \n\n" );
- for ( int i = 0; i < errorList.size(); i++ )
- {
- strBuf.append( "\t\t" );
- strBuf.append( i + 1 );
- strBuf.append( ") " );
- strBuf.append( errorList.get( i ) );
- strBuf.append( "\n" );
- }
- strBuf.append( "\n" );
- throw new FaultException( Soap1_1Constants.FAULT_CLIENT, strBuf.toString() );
- }
- }
- }
-
- private void handleException( Exception e )
- {
- if ( e instanceof SOAPFaultException )
- {
- throw (SOAPFaultException) e;
- }
- else
- {
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( MSG.getMessage( Keys.INTERNAL_SERVER_ERROR ) );
- e.printStackTrace();
- }
- throw new FaultException( Soap1_1Constants.FAULT_SERVER, MSG.getMessage( Keys.INTERNAL_SERVER_ERROR ) );
- }
- }
-
- private XmlObject toDocumentXmlBean( XmlObject xBean )
- throws XmlException
- {
- // TODO (performance): probably should change method signatures to take types instead of documents to avoid this
- return XmlObject.Factory.parse( xBean.xmlText( new XmlOptions().setSaveOuter() ) );
- }
-
- /**
- * Returns a facade-wrapped SOAPBody
- *
- * @param envelope
- *
- * @return a facade-wrapped SOAPBody
- *
- * @throws XmlException
- */
- private org.apache.ws.util.soap.Body getSoapBody( SOAPEnvelope envelope ) throws XmlException
- {
- org.apache.ws.util.soap.Envelope envelopeWrapper = null;
- XmlObject envelopeDocXmlBean = XmlObject.Factory.parse( envelope.toString() );
- if ( envelopeDocXmlBean instanceof org.w3.x2003.x05.soapEnvelope.EnvelopeDocument )
- {
- envelopeWrapper =
- new org.apache.ws.util.soap.Envelope(
- (org.w3.x2003.x05.soapEnvelope.EnvelopeDocument) envelopeDocXmlBean );
- }
- else if ( envelopeDocXmlBean instanceof org.xmlsoap.schemas.soap.envelope.EnvelopeDocument )
- {
- envelopeWrapper =
- new org.apache.ws.util.soap.Envelope(
- (org.xmlsoap.schemas.soap.envelope.EnvelopeDocument) envelopeDocXmlBean );
- }
- else
- {
- throw new IllegalArgumentException(
- "Unknown version of SOAPEnvelope: " + envelopeDocXmlBean.getClass().getName() );
- }
-
- return envelopeWrapper.getBody();
- }
-
- /**
- * This method is used when there are no parameters to a method
- *
- * @param service The service to find the method on.
- * @param methodNameFromAction The method name we are looking for.
- *
- * @return The Method object
- */
- private Method getServiceMethod( WsrfService service, String methodNameFromAction )
- {
- Method serviceMethod = null;
- LOG.debug( "Based on the request, looking for method named: " + methodNameFromAction + " in service " +
- service.getClass().getName() +
- " with no params." );
- Method[] methods = service.getClass().getMethods();
- for ( int i = 0; i < methods.length; i++ )
- {
- Method method = methods[i];
- if ( method.getName().equals( methodNameFromAction ) )
- {
- if ( method.getParameterTypes().length == 0 )
- {
- serviceMethod = method;
- break;
- }
- else
- {
- LOG.warn( "Found method named: " + methodNameFromAction + " in service " +
- service.getClass().getName() +
- " with " +
- method.getParameterTypes().length +
- " param types, expected 0 param type." );
- }
- }
- }
-
- if ( serviceMethod == null )
- {
- throw new RuntimeException( MSG.getMessage( Keys.BAD_REQUEST_BODY_ELEMENT,
- methodNameFromAction,
- service.getClass().getName() ) );
- }
-
- LOG.debug( MSG.getMessage( Keys.FOUND_SERVICE_METHOD, serviceMethod.getName() ) );
- return serviceMethod;
- }
-
- private XmlObject invokeServiceMethod( Method serviceMethod, WsrfService service, XmlObject requestXBean,
- Class serviceClass )
- throws Exception
- {
- XmlObject responseXBean = null;
- Object[] params = toObjectArray( requestXBean );
- try
- {
- responseXBean = (XmlObject) serviceMethod.invoke( service, params );
- }
- catch ( InvocationTargetException ite )
- {
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( MSG.getMessage( Keys.ERROR_INVOKING_METHOD_ON_SERVICE,
- serviceMethod.getName(),
- serviceClass.getName() ) );
- if ( ite.getCause() != null )
- {
- ite.getCause().printStackTrace();
- }
+ LOG.debug( MSG.getMessage( Keys.INVOKING_SERVICE_METHOD,
+ serviceMethod.getName( ) ) );
+ XmlObject responseXBean = invokeServiceMethod( serviceMethod, service, requestXBean, serviceClass );
+ if ( responseXBean != null )
+ {
+ responseBodyElems.add( responseXBean );
+ }
+
+ if ( !responseBodyElems.isEmpty( ) )
+ {
+ msgContext.setProperty( WSRF_RESPONSE_XMLOBJECT_LIST, responseBodyElems );
+ }
+ }
+ catch ( Exception e )
+ {
+ handleException( e );
+ }
+
+ return false; // short-circuit any remaining Handlers in chain
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param messageContext DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ public boolean handleResponse( MessageContext messageContext )
+ {
+ try
+ {
+ LOG.debug( MSG.getMessage( Keys.HANDLING_RESPONSE ) );
+ SOAPEnvelope responseEnvelope = getResponseEnvelope( (SOAPMessageContext) messageContext );
+ List responseBodyElems = (List) messageContext.getProperty( WSRF_RESPONSE_XMLOBJECT_LIST );
+ LOG.debug( MSG.getMessage( Keys.FOUND_RESP_ELEMS,
+ Integer.toString( responseBodyElems.size( ) ) ) );
+ if ( responseBodyElems != null )
+ {
+ SOAPBody responseBody = responseEnvelope.getBody( );
+ for ( int i = 0; i < responseBodyElems.size( ); i++ )
+ {
+ XmlObject responseBodyElem = (XmlObject) responseBodyElems.get( i );
+ SOAPBodyElement[] soapBodyElements = createSOAPBodyElements( responseBodyElem );
+ for ( int j = 0; j < soapBodyElements.length; j++ )
+ {
+ SOAPBodyElement soapBodyElement = soapBodyElements[j];
+ responseBody.addChildElement( soapBodyElement );
+ }
+ }
+ }
+
+ if ( LOG.isDebugEnabled( ) )
+ {
+ LOG.debug( "Sending SOAP response: \n" + responseEnvelope );
+ }
+ }
+ catch ( Exception e )
+ {
+ handleException( e );
+ }
+
+ return false; // short-circuit any remaining Handlers in chain
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param handlerInfo DOCUMENT_ME
+ */
+ public void init( HandlerInfo handlerInfo )
+ {
+ Map handlerConfig = handlerInfo.getHandlerConfig( );
+ m_handlerOptions = ( handlerConfig != null ) ? handlerConfig : new HashMap( );
+ }
+
+ /**
+ * Creates a {@link ResourceContext} for this request.
+ *
+ * @param soapMsgContext the JAX-RPC SOAP message context for this request
+ *
+ * @return a ResourceContext for this request
+ */
+ protected abstract ResourceContext createResourceContext( SOAPMessageContext soapMsgContext )
+ throws Exception;
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param responseBodyElem DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ protected abstract SOAPBodyElement[] createSOAPBodyElements( XmlObject responseBodyElem );
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param resourceContext DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ protected Class getServiceClassName( ResourceContext resourceContext )
+ throws ResourceContextException,
+ ClassNotFoundException
+ {
+ String serviceClassName = resourceContext.getResourceHome( ).getServiceClassName( );
+ LOG.debug( MSG.getMessage( Keys.RETRIEVED_SERVICE_CLASSNAME, serviceClassName ) );
+ if ( serviceClassName == null )
+ {
+ throw new IllegalStateException( MSG.getMessage( Keys.SERVICE_OPT_UNDEFINED_IN_HOME,
+ SERVICE_OPT_SERVICE_CLASS_NAME ) );
+ }
+
+ return Class.forName( serviceClassName );
+ }
+
+ /**
+ * @param resourceContext
+ * @param key
+ *
+ * @return the service option string
+ */
+ protected final String getServiceOption( ResourceContext resourceContext,
+ String key )
+ {
+ return (String) resourceContext.getProperty( key );
+ }
+
+ /**
+ * DOCUMENT_ME
+ *
+ * @param soapMsgContext DOCUMENT_ME
+ *
+ * @return DOCUMENT_ME
+ */
+ protected SOAPEnvelope getResponseEnvelope( SOAPMessageContext soapMsgContext )
+ {
+ return ( getEnvelope( getResponseMessage( soapMsgContext ) ) );
+ }
+
+ /**
+ * @param soapMsgContext the response's JAX-RPC message context
+ *
+ * @return response JAX-RPC SOAP message
+ */
+ protected SOAPMessage getResponseMessage( SOAPMessageContext soapMsgContext )
+ {
+ SOAPMessage soapMsg = soapMsgContext.getMessage( );
+ if ( soapMsg == null )
+ {
+ soapMsg = createSOAPMessage( );
+ soapMsgContext.setMessage( soapMsg );
+ }
+
+ return ( soapMsg );
+ }
+
+ /**
+ * @param soapMsg a SAAJ SOAP message
+ *
+ * @return
+ */
+ private SOAPEnvelope getEnvelope( SOAPMessage soapMsg )
+ {
+ try
+ {
+ return soapMsg.getSOAPPart( ).getEnvelope( );
+ }
+ catch ( SOAPException soape )
+ {
+ throw new JAXRPCException( "Failed to get SOAPEnvelope from request SOAPMessage.", soape );
+ }
+ }
+
+ /**
+ * This method is used when there are no parameters to a method
+ *
+ * @param service The service to find the method on.
+ * @param methodNameFromAction The method name we are looking for.
+ *
+ * @return The Method object
+ */
+ private Method getServiceMethod( WsrfService service,
+ String methodNameFromAction )
+ {
+ Method serviceMethod = null;
+ LOG.debug( "Based on the request, looking for method named: " + methodNameFromAction + " in service "
+ + service.getClass( ).getName( ) + " with no params." );
+ Method[] methods = service.getClass( ).getMethods( );
+ for ( int i = 0; i < methods.length; i++ )
+ {
+ Method method = methods[i];
+ if ( method.getName( ).equals( methodNameFromAction ) )
+ {
+ if ( method.getParameterTypes( ).length == 0 )
+ {
+ serviceMethod = method;
+ break;
}
- if ( ite.getCause() != null )
+ else
{
- throw (Exception) ite.getCause();
+ LOG.warn( "Found method named: " + methodNameFromAction + " in service "
+ + service.getClass( ).getName( ) + " with " + method.getParameterTypes( ).length
+ + " param types, expected 0 param type." );
+ }
+ }
+ }
+
+ if ( serviceMethod == null )
+ {
+ throw new RuntimeException( MSG.getMessage( Keys.BAD_REQUEST_BODY_ELEMENT,
+ methodNameFromAction,
+ service.getClass( ).getName( ) ) );
+ }
+
+ LOG.debug( MSG.getMessage( Keys.FOUND_SERVICE_METHOD,
+ serviceMethod.getName( ) ) );
+ return serviceMethod;
+ }
+
+ /**
+ * Finds the method based on the requestXBean name
+ *
+ * @param service
+ * @param requestXBean
+ *
+ * @return
+ */
+ private Method getServiceMethod( WsrfService service,
+ XmlObject requestXBean )
+ {
+ QName bodyElemName = XmlBeanUtils.getName( requestXBean );
+ if ( bodyElemName == null )
+ {
+ throw new FaultException( Soap1_1Constants.FAULT_CLIENT,
+ MSG.getMessage( Keys.BAD_REQUEST_BODY_ELEMENT_NOPARAM ) );
+ }
+
+ if ( LOG.isDebugEnabled( ) )
+ {
+ LOG.debug( MSG.getMessage( Keys.DERIVE_SERVICE_NAME_FROM_REQ,
+ toString( bodyElemName ) ) );
+ }
+
+ String serviceMethodName = service.getMethodNameMap( ).getMethodName( bodyElemName );
+ return getServiceMethod( service, serviceMethodName, requestXBean );
+ }
+
+ private Method getServiceMethod( WsrfService service,
+ String methodName,
+ XmlObject param )
+ {
+ Method serviceMethod = null;
+ LOG.debug( "Based on the request, looking for method named: " + methodName + " in service "
+ + service.getClass( ).getName( ) + " with a single param of type: "
+ + param.getClass( ).getName( ) );
+ Method[] methods = service.getClass( ).getMethods( );
+ for ( int i = 0; i < methods.length; i++ )
+ {
+ Method method = methods[i];
+ if ( method.getName( ).equals( methodName ) )
+ {
+ if ( method.getParameterTypes( ).length == 1 )
+ {
+ if ( method.getParameterTypes( )[0].isInstance( param ) )
+ {
+ serviceMethod = method;
+ break;
+ }
+ else
+ {
+ LOG.warn( "Found method named: " + methodName + " in service "
+ + service.getClass( ).getName( ) + " with a single param of type: "
+ + method.getParameterTypes( )[0].getName( )
+ + " , however the request param was of type: " + param.getClass( ).getName( ) );
+ }
}
else
{
- throw ite;
+ LOG.warn( "Found method named: " + methodName + " in service " + service.getClass( ).getName( )
+ + " with " + method.getParameterTypes( ).length
+ + " params; expected method to have exactly one param." );
+ }
+ }
+ }
+
+ if ( serviceMethod == null ) // method not found
+ {
+ QName bodyElemName = XmlBeanUtils.getName( param );
+ throw new FaultException( Soap1_1Constants.FAULT_CLIENT,
+ MSG.getMessage( Keys.BAD_REQUEST_BODY_ELEMENT,
+ toString( bodyElemName ) ) );
+ }
+
+ LOG.debug( MSG.getMessage( Keys.FOUND_SERVICE_METHOD,
+ serviceMethod.getName( ) ) );
+ return serviceMethod;
+ }
+
+ /**
+ * Returns a facade-wrapped SOAPBody
+ *
+ * @param envelope
+ *
+ * @return a facade-wrapped SOAPBody
+ *
+ * @throws XmlException
+ */
+ private org.apache.ws.util.soap.Body getSoapBody( SOAPEnvelope envelope )
+ throws XmlException
+ {
+ org.apache.ws.util.soap.Envelope envelopeWrapper = null;
+ XmlObject envelopeDocXmlBean = XmlObject.Factory.parse( envelope.toString( ) );
+ if ( envelopeDocXmlBean instanceof org.w3.x2003.x05.soapEnvelope.EnvelopeDocument )
+ {
+ envelopeWrapper =
+ new org.apache.ws.util.soap.Envelope( (org.w3.x2003.x05.soapEnvelope.EnvelopeDocument) envelopeDocXmlBean );
+ }
+ else if ( envelopeDocXmlBean instanceof org.xmlsoap.schemas.soap.envelope.EnvelopeDocument )
+ {
+ envelopeWrapper =
+ new org.apache.ws.util.soap.Envelope( (org.xmlsoap.schemas.soap.envelope.EnvelopeDocument) envelopeDocXmlBean );
+ }
+ else
+ {
+ throw new IllegalArgumentException( "Unknown version of SOAPEnvelope: "
+ + envelopeDocXmlBean.getClass( ).getName( ) );
+ }
+
+ return envelopeWrapper.getBody( );
+ }
+
+ private void handleException( Exception e )
+ {
+ if ( e instanceof SOAPFaultException )
+ {
+ throw (SOAPFaultException) e;
+ }
+ else
+ {
+ if ( LOG.isDebugEnabled( ) )
+ {
+ LOG.debug( MSG.getMessage( Keys.INTERNAL_SERVER_ERROR ) );
+ e.printStackTrace( );
+ }
+
+ throw new FaultException( Soap1_1Constants.FAULT_SERVER,
+ MSG.getMessage( Keys.INTERNAL_SERVER_ERROR ) );
+ }
+ }
+
+ private XmlObject invokeServiceMethod( Method serviceMethod,
+ WsrfService service,
+ XmlObject requestXBean,
+ Class serviceClass )
+ throws Exception
+ {
+ XmlObject responseXBean = null;
+ Object[] params = toObjectArray( requestXBean );
+ try
+ {
+ responseXBean = (XmlObject) serviceMethod.invoke( service, params );
+ }
+ catch ( InvocationTargetException ite )
+ {
+ if ( LOG.isDebugEnabled( ) )
+ {
+ LOG.debug( MSG.getMessage( Keys.ERROR_INVOKING_METHOD_ON_SERVICE,
+ serviceMethod.getName( ),
+ serviceClass.getName( ) ) );
+ if ( ite.getCause( ) != null )
+ {
+ ite.getCause( ).printStackTrace( );
+ }
+ }
+
+ if ( ite.getCause( ) != null )
+ {
+ throw (Exception) ite.getCause( );
+ }
+ else
+ {
+ throw ite;
+ }
+ }
+
+ if ( ( responseXBean == null ) && ( serviceMethod.getReturnType( ) != void.class ) )
+ {
+ // don't allow service method to return null
+ LOG.error( "Service method " + serviceMethod.getName( ) + " in class " + serviceClass.getName( )
+ + " returned null - this is not allowed." );
+ throw new IllegalStateException( );
+ }
+
+ return responseXBean;
+ }
+
+ private XmlObject toDocumentXmlBean( XmlObject xBean )
+ throws XmlException
+ {
+ // TODO (performance): probably should change method signatures to take types instead of documents to avoid this
+ return XmlObject.Factory.parse( xBean.xmlText( new XmlOptions( ).setSaveOuter( ) ) );
+ }
+
+ private Object[] toObjectArray( Object obj )
+ {
+ return ( obj != null ) ? new Object[]
+ {
+ obj
+ } : new Object[0];
+ }
+
+ private static String toString( QName name )
+ {
+ StringBuffer strBuf = new StringBuffer( );
+ strBuf.append( name.getLocalPart( ) );
+ if ( name.getNamespaceURI( ) != null )
+ {
+ strBuf.append( "@" );
+ strBuf.append( name.getNamespaceURI( ) );
+ }
+
+ return strBuf.toString( );
+ }
+
+ private String getHandlerOption( String optionName,
+ String defaultValue )
+ {
+ Object value = ( m_handlerOptions != null ) ? m_handlerOptions.get( optionName ) : null;
+ return ( value != null ) ? value.toString( ) : defaultValue;
+ }
+
+ private SOAPMessage createSOAPMessage( )
+ {
+ try
+ {
+ return MessageFactory.newInstance( ).createMessage( );
+ }
+ catch ( SOAPException soape )
+ {
+ throw new JAXRPCException( MSG.getMessage( Keys.FAILED_TO_CREATE_SOAPMESSAGE ), soape );
+ }
+ }
+
+ private WsrfService createService( Class serviceClass,
+ ResourceContext resourceContext )
+ throws Exception
+ {
+ LOG.debug( MSG.getMessage( Keys.CREATING_INSTANCE_OF_SERVICE, serviceClass ) );
+ Constructor serviceCtor = serviceClass.getConstructor( new Class[]
+ {
+ ResourceContext.class
+ } );
+ WsrfService service = null;
+ try
+ {
+ service = (WsrfService) serviceCtor.newInstance( new Object[]
+ {
+ resourceContext
+ } );
+ }
+ catch ( InvocationTargetException ite )
+ {
+ throw (Exception) ite.getCause( );
+ }
+
+ return service;
+ }
+
+ private void validateRequestXml( XmlObject requestXBean )
+ {
+ boolean validateRequestXml =
+ Boolean.valueOf( getHandlerOption( HANDLER_OPT_VALIDATE_REQUEST_XML, "true" ) ).booleanValue( );
+ if ( validateRequestXml && !( requestXBean instanceof XmlAnyTypeImpl ) )
+ {
+ XmlOptions validateOptions = new XmlOptions( );
+ List errorList = new ArrayList( );
+ validateOptions.setErrorListener( errorList );
+ boolean isValid = requestXBean.validate( validateOptions );
+ if ( !isValid )
+ {
+ QName bodyElemName = XmlBeanUtils.getName( requestXBean );
+ StringBuffer strBuf = new StringBuffer( "Request body element " );
+ strBuf.append( toString( bodyElemName ) );
+ strBuf.append( " is not valid as per its schema: \n\n" );
+ for ( int i = 0; i < errorList.size( ); i++ )
+ {
+ strBuf.append( "\t\t" );
+ strBuf.append( i + 1 );
+ strBuf.append( ") " );
+ strBuf.append( errorList.get( i ) );
+ strBuf.append( "\n" );
}
- }
- if ( responseXBean == null && serviceMethod.getReturnType() != void.class )
- {
- // don't allow service method to return null
- LOG.error(
- "Service method " + serviceMethod.getName() + " in class " + serviceClass.getName() +
- " returned null - this is not allowed." );
- throw new IllegalStateException();
- }
- return responseXBean;
- }
-
- private Object[] toObjectArray( Object obj )
- {
- return obj != null ? new Object[]
- {
- obj
- } : new Object[0];
- }
-
- /**
- * @param soapMsg a SAAJ SOAP message
- *
- * @return
- */
- private SOAPEnvelope getEnvelope( SOAPMessage soapMsg )
- {
- try
- {
- return soapMsg.getSOAPPart().getEnvelope();
- }
- catch ( SOAPException soape )
- {
- throw new JAXRPCException( "Failed to get SOAPEnvelope from request SOAPMessage.", soape );
- }
- }
-
- /**
- * Finds the method based on the requestXBean name
- *
- * @param service
- * @param requestXBean
- *
- * @return
- */
- private Method getServiceMethod( WsrfService service,
- XmlObject requestXBean )
- {
- QName bodyElemName = XmlBeanUtils.getName( requestXBean );
- if ( bodyElemName == null )
- {
- throw new FaultException( Soap1_1Constants.FAULT_CLIENT,
- MSG.getMessage( Keys.BAD_REQUEST_BODY_ELEMENT_NOPARAM ) );
- }
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( MSG.getMessage( Keys.DERIVE_SERVICE_NAME_FROM_REQ, toString( bodyElemName ) ) );
- }
- String serviceMethodName = service.getMethodNameMap().getMethodName( bodyElemName );
- return getServiceMethod( service, serviceMethodName, requestXBean );
- }
-
- private Method getServiceMethod( WsrfService service, String methodName, XmlObject param )
- {
- Method serviceMethod = null;
- LOG.debug( "Based on the request, looking for method named: " + methodName + " in service " +
- service.getClass().getName() +
- " with a single param of type: " +
- param.getClass().getName() );
- Method[] methods = service.getClass().getMethods();
- for ( int i = 0; i < methods.length; i++ )
- {
- Method method = methods[i];
- if ( method.getName().equals( methodName ) )
- {
- if ( method.getParameterTypes().length == 1 )
- {
- if ( method.getParameterTypes()[0].isInstance( param ) )
- {
- serviceMethod = method;
- break;
- }
- else
- {
- LOG.warn( "Found method named: " + methodName + " in service " +
- service.getClass().getName() +
- " with a single param of type: " +
- method.getParameterTypes()[0].getName() +
- " , however the request param was of type: " +
- param.getClass().getName() );
- }
- }
- else
- {
- LOG.warn( "Found method named: " + methodName + " in service " +
- service.getClass().getName() +
- " with " +
- method.getParameterTypes().length +
- " params; expected method to have exactly one param." );
- }
- }
- }
- if ( serviceMethod == null ) // method not found
- {
- QName bodyElemName = XmlBeanUtils.getName( param );
+
+ strBuf.append( "\n" );
throw new FaultException( Soap1_1Constants.FAULT_CLIENT,
- MSG.getMessage( Keys.BAD_REQUEST_BODY_ELEMENT, toString( bodyElemName ) ) );
- }
- LOG.debug( MSG.getMessage( Keys.FOUND_SERVICE_METHOD, serviceMethod.getName() ) );
- return serviceMethod;
- }
-
- private static String toString( QName name )
- {
- StringBuffer strBuf = new StringBuffer();
- strBuf.append( name.getLocalPart() );
- if ( name.getNamespaceURI() != null )
- {
- strBuf.append( "@" );
- strBuf.append( name.getNamespaceURI() );
- }
- return strBuf.toString();
- }
-
- private SOAPMessage createSOAPMessage()
- {
- try
- {
- return MessageFactory.newInstance().createMessage();
- }
- catch ( SOAPException soape )
- {
- throw new JAXRPCException( MSG.getMessage( Keys.FAILED_TO_CREATE_SOAPMESSAGE ), soape );
- }
- }
-
- private WsrfService createService( Class serviceClass,
- ResourceContext resourceContext )
- throws Exception
- {
- LOG.debug( MSG.getMessage( Keys.CREATING_INSTANCE_OF_SERVICE, serviceClass ) );
- Constructor serviceCtor = serviceClass.getConstructor( new Class[]
- {
- ResourceContext.class
- } );
- WsrfService service = null;
- try
- {
- service = (WsrfService) serviceCtor.newInstance( new Object[]
- {
- resourceContext
- } );
- }
- catch ( InvocationTargetException ite )
- {
- throw (Exception) ite.getCause();
- }
- return service;
- }
-
- private String getHandlerOption( String optionName, String defaultValue )
- {
- Object value = m_handlerOptions != null ? m_handlerOptions.get( optionName ) : null;
- return value != null ? value.toString() : defaultValue;
- }
+ strBuf.toString( ) );
+ }
+ }
+ }
}